Enable foreign keys
This commit is contained in:
parent
884e3eb30b
commit
904a010abf
1 changed files with 10 additions and 2 deletions
|
@ -73,7 +73,10 @@ class FilesDB {
|
|||
// we need to write query based on that field
|
||||
static const columnMMdVisibility = 'mmd_visibility';
|
||||
|
||||
static final initializationScript = [...createTable(filesTable)];
|
||||
static final initializationScript = [
|
||||
enableForeignKeys(),
|
||||
...createTable(filesTable),
|
||||
];
|
||||
static final migrationScripts = [
|
||||
...alterDeviceFolderToAllowNULL(),
|
||||
...alterTimestampColumnTypes(),
|
||||
|
@ -118,6 +121,10 @@ class FilesDB {
|
|||
return await openDatabaseWithMigration(path, dbConfig);
|
||||
}
|
||||
|
||||
static String enableForeignKeys() {
|
||||
return "PRAGMA foreign_keys = ON;";
|
||||
}
|
||||
|
||||
// SQL code to create the database table
|
||||
static List<String> createTable(String tableName) {
|
||||
return [
|
||||
|
@ -390,7 +397,8 @@ class FilesDB {
|
|||
CREATE TABLE IF NOT EXISTS $embeddingsTable (
|
||||
$columnGeneratedID INTEGER PRIMARY KEY,
|
||||
$columnEmbedding TEXT NOT NULL,
|
||||
$columnUpdationTime INTEGER NOT NULL DEFAULT -1
|
||||
$columnUpdationTime INTEGER NOT NULL DEFAULT -1,
|
||||
FOREIGN KEY($columnGeneratedID) REFERENCES $filesTable($columnGeneratedID)
|
||||
);
|
||||
'''
|
||||
];
|
||||
|
|
Loading…
Add table
Reference in a new issue