-
I'm trying to find a an example of applying multiple upgrade statements but can't find any working examples. I have something like this right now, but it does not work, only const DB_NAME = 'my-db';
const version1 = [
`CREATE TABLE "journal_entries" (
"id" INTEGER UNIQUE,
"date" INTEGER NOT NULL,
"text" TEXT,
"attachment" BLOB,
PRIMARY KEY("id" AUTOINCREMENT)
);`
];
const version2 = [
`ALTER TABLE "journal_entries" ADD COLUMN "attachment_2" BLOB;`
];
await sqlite.addUpgradeStatement(DB_NAME, 1, version1);
await sqlite.addUpgradeStatement(DB_NAME, 2, version2);
// ...etc
const db = await sqlite?.createConnection(...} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I think I figured it out, you have to specify the DB version in the const db = await sqlite?.createConnection(
DB_NAME,
false,
'no-encryption',
2, // db version here
false
); One thing that I do not understand is how the sqlite plugin keeps track of which version the database is currently at. Is it safe to assume that adding upgrade statements and incrementing the version in |
Beta Was this translation helpful? Give feedback.
@khromov look at tutorials