Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 1dc1da1

Browse files
Changes to PRAGMA
1 parent ef200a3 commit 1dc1da1

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

migrations/env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def run_migrations_offline() -> None:
3535
target_metadata=target_metadata,
3636
literal_binds=True,
3737
dialect_opts={"paramstyle": "named"},
38+
transactional_ddl=True,
3839
)
3940

4041
with context.begin_transaction():

src/codegate/db/connection.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ def set_sqlite_pragma(dbapi_connection, connection_record):
4545
[SQLite docs](https://www.sqlite.org/foreignkeys.html)
4646
[SO](https://stackoverflow.com/questions/2614984/sqlite-sqlalchemy-how-to-enforce-foreign-keys)
4747
"""
48-
# Only enable foreign keys if the connection record has the flag set to True
49-
if connection_record.info.get("enable_fks", False):
50-
cursor = dbapi_connection.cursor()
51-
cursor.execute("PRAGMA foreign_keys=ON")
52-
cursor.close()
48+
cursor = dbapi_connection.cursor()
49+
cursor.execute("PRAGMA foreign_keys=ON")
50+
cursor.close()
5351

5452

5553
class DbCodeGate:
@@ -80,7 +78,6 @@ def __init__(self, sqlite_path: Optional[str] = None):
8078
"isolation_level": "AUTOCOMMIT", # Required for SQLite
8179
}
8280
self._async_db_engine = create_async_engine(**engine_dict)
83-
self._async_db_engine.connect().connection.connection_record.info["enable_fks"] = True
8481

8582
def does_db_exist(self):
8683
return self._db_path.is_file()

0 commit comments

Comments
 (0)