forked from s3lph/matemat
fix: sqlite constraint migration
This commit is contained in:
parent
dd65b5c4d0
commit
51adba2e25
1 changed files with 5 additions and 1 deletions
|
@ -74,10 +74,12 @@ class DatabaseWrapper(object):
|
|||
|
||||
# Enable foreign key enforcement
|
||||
cursor = self._sqlite_db.cursor()
|
||||
cursor.execute('PRAGMA foreign_keys = 1')
|
||||
cursor.execute('PRAGMA foreign_keys=ON')
|
||||
|
||||
def _upgrade(self, from_version: int, to_version: int) -> None:
|
||||
with self.transaction() as c:
|
||||
c.execute('PRAGMA foreign_keys=OFF')
|
||||
c.execute('PRAGMA legacy_alter_table=ON')
|
||||
if from_version <= 1 and to_version >= 2:
|
||||
migrate_schema_1_to_2(c)
|
||||
if from_version <= 2 and to_version >= 3:
|
||||
|
@ -98,6 +100,8 @@ class DatabaseWrapper(object):
|
|||
migrate_schema_8_to_9(c)
|
||||
if from_version <= 9 and to_version >= 10:
|
||||
migrate_schema_9_to_10(c)
|
||||
c.execute('PRAGMA foreign_key_check')
|
||||
c.execute('PRAGMA foreign_keys=ON')
|
||||
|
||||
def connect(self) -> None:
|
||||
if self.is_connected():
|
||||
|
|
Loading…
Reference in a new issue