mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
registerMigrationWithDisabledForeignKeyChecks documentation
This commit is contained in:
1 parent
c1169f0d2c
commit
ea2f202e4d
1 file changed
+2
-2
@@ -2215,11 +2215,11 @@ try migrator.migrate(dbQueue) // or migrator.migrate(dbPool)
|
||||
|
||||
SQLite does not support many schema changes, and won't let you drop a table column with "ALTER TABLE ... DROP COLUMN ...", for example.
|
||||
|
||||
Yet any kind of schema change is still possible. The SQLite documentation explains in detail how to do so: https://www.sqlite.org/lang_altertable.html#otheralter. This technique requires the temporary disabling of foreign key checks, and is supported by the `withDisabledForeignKeyChecks` argument:
|
||||
Yet any kind of schema change is still possible. The SQLite documentation explains in detail how to do so: https://www.sqlite.org/lang_altertable.html#otheralter. This technique requires the temporary disabling of foreign key checks, and is supported by the `registerMigrationWithDisabledForeignKeyChecks` function:
|
||||
|
||||
```swift
|
||||
// Add a NOT NULL constraint on persons.name:
|
||||
migrator.registerMigration("AddNotNullCheckOnName", withDisabledForeignKeyChecks: true) { db in
|
||||
migrator.registerMigrationWithDisabledForeignKeyChecks("AddNotNullCheckOnName") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE new_persons (id INTEGER PRIMARY KEY, name TEXT NOT NULL);" +
|
||||
"INSERT INTO new_persons SELECT * FROM persons;" +
|
||||
|
||||
Reference in new issue
Block a user