File tree 2 files changed +11
-3
lines changed
src/prefect/server/database/migrations
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -91,8 +91,8 @@ def dry_run_migrations() -> None:
91
91
render_as_batch = dialect .name == "sqlite" ,
92
92
# Each migration is its own transaction
93
93
transaction_per_migration = True ,
94
+ template_args = {"dialect" : dialect .name },
94
95
)
95
-
96
96
with context .begin_transaction ():
97
97
context .run_migrations ()
98
98
@@ -104,7 +104,6 @@ def do_run_migrations(connection: AsyncEngine) -> None:
104
104
Args:
105
105
connection: a database engine.
106
106
"""
107
-
108
107
context .configure (
109
108
connection = connection ,
110
109
target_metadata = target_metadata ,
@@ -123,6 +122,7 @@ def do_run_migrations(connection: AsyncEngine) -> None:
123
122
render_as_batch = dialect .name == "sqlite" ,
124
123
# Each migration is its own transaction
125
124
transaction_per_migration = True ,
125
+ template_args = {"dialect" : dialect .name },
126
126
)
127
127
128
128
with context .begin_transaction ():
Original file line number Diff line number Diff line change @@ -16,10 +16,18 @@ down_revision = ${repr(down_revision)}
16
16
branch_labels = ${ repr (branch_labels)}
17
17
depends_on = ${ repr (depends_on)}
18
18
19
+ <%
20
+ sqlite = dialect == " sqlite"
21
+ postgresql = dialect == " postgresql"
22
+ %>
23
+
19
24
20
25
def upgrade():
26
+ ${ ' op.execute("PRAGMA foreign_keys=OFF")' if sqlite else " " }
21
27
${ upgrades if upgrades else " pass" }
22
-
28
+ ${ ' op.execute("PRAGMA foreign_keys=ON") ' if sqlite else " " }
23
29
24
30
def downgrade():
31
+ ${ ' op.execute("PRAGMA foreign_keys=OFF")' if sqlite else " " }
25
32
${ downgrades if downgrades else " pass" }
33
+ ${ ' op.execute("PRAGMA foreign_keys=ON")' if sqlite else " " }
You can’t perform that action at this time.
0 commit comments