Commit 9c0387f39bc870f8b2bf9677821a6d840da45992
1 parent
891e24cf
deactivate the foreign key constraint during migration
Showing
1 changed file
with
6 additions
and
2 deletions
Show diff stats
database/alter_table.anubis
| @@ -222,8 +222,9 @@ public define Maybe(One) | @@ -222,8 +222,9 @@ public define Maybe(One) | ||
| 222 | }, | 222 | }, |
| 223 | true then | 223 | true then |
| 224 | with tempNameTable = tableName + "_temp", | 224 | with tempNameTable = tableName + "_temp", |
| 225 | + forget(sql_query(db, "PRAGMA foreign_keys = 0;")); | ||
| 225 | forget(sql_query(db, "DROP TABLE " + tempNameTable)); | 226 | forget(sql_query(db, "DROP TABLE " + tempNameTable)); |
| 226 | - if my_sql_query(db, "CREATE TEMP TABLE " + tempNameTable + " AS SELECT * from " + fullTableName, log) is failure then failure else | 227 | + with result = if my_sql_query(db, "CREATE TEMP TABLE " + tempNameTable + " AS SELECT * from " + fullTableName, log) is failure then failure else |
| 227 | if my_sql_query(db, "DROP TABLE " + fullTableName, log) is failure then failure else | 228 | if my_sql_query(db, "DROP TABLE " + fullTableName, log) is failure then failure else |
| 228 | if my_sql_query(db, newTableQuery , log) is failure then failure else | 229 | if my_sql_query(db, newTableQuery , log) is failure then failure else |
| 229 | if sql_query(db, "SELECT * FROM " + tempNameTable) is | 230 | if sql_query(db, "SELECT * FROM " + tempNameTable) is |
| @@ -244,7 +245,10 @@ public define Maybe(One) | @@ -244,7 +245,10 @@ public define Maybe(One) | ||
| 244 | ok(_,_,_) then logInfo(log, " --> ok."); success(unique) | 245 | ok(_,_,_) then logInfo(log, " --> ok."); success(unique) |
| 245 | } | 246 | } |
| 246 | } | 247 | } |
| 247 | - } | 248 | + }, |
| 249 | + | ||
| 250 | + forget(sql_query(db, "PRAGMA foreign_keys = 1;")); | ||
| 251 | + result | ||
| 248 | } | 252 | } |
| 249 | else | 253 | else |
| 250 | success(unique) | 254 | success(unique) |