diff options
author | JayZed <[email protected]> | 2024-07-08 17:33:43 -0400 |
---|---|---|
committer | JayZed <[email protected]> | 2024-07-08 17:33:43 -0400 |
commit | 4cc6806193127f9d6d3f2dab26969471d9bbf159 (patch) | |
tree | bfc90e4b55fa0f48f83e51c4e5947c1f7d7d7a2d /migrations/env.py | |
parent | d875dc7733c901246881325ee3a84fe5d44b10b9 (diff) | |
parent | 5886c20c9c7929bf46836a99c2d9d4eb834638bd (diff) | |
download | bazarr-4cc6806193127f9d6d3f2dab26969471d9bbf159.tar.gz bazarr-4cc6806193127f9d6d3f2dab26969471d9bbf159.zip |
Merge branch 'development' of https://github.com/morpheus65535/bazarr into development
Diffstat (limited to 'migrations/env.py')
-rw-r--r-- | migrations/env.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/migrations/env.py b/migrations/env.py index d706218a2..beddf9710 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -1,6 +1,7 @@ from flask import current_app from alembic import context +from sqlalchemy import text import logging @@ -95,8 +96,22 @@ def run_migrations_online(): ) with context.begin_transaction(): + bind = context.get_bind() + + if bind.engine.name == 'sqlite': + bind.execute(text("PRAGMA foreign_keys=OFF;")) + elif bind.engine.name == 'postgresql': + bind.execute(text("SET CONSTRAINTS ALL DEFERRED;")) + context.run_migrations() + if bind.engine.name == 'sqlite': + bind.execute(text("PRAGMA foreign_keys=ON;")) + elif bind.engine.name == 'postgresql': + bind.execute(text("SET CONSTRAINTS ALL IMMEDIATE;")) + + bind.close() + if context.is_offline_mode(): run_migrations_offline() |