mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
move table unique constraint
This commit is contained in:
@@ -65,10 +65,6 @@ export default async function migration() {
|
||||
`ALTER TABLE resources ADD COLUMN resourceGuid TEXT DEFAULT 'PLACEHOLDER';`
|
||||
).run();
|
||||
|
||||
db.prepare(
|
||||
`CREATE UNIQUE INDEX resources_resourceGuid_unique ON resources ('resourceGuid');`
|
||||
).run();
|
||||
|
||||
// 2. Select all rows
|
||||
const rows = db.prepare(`SELECT resourceId FROM resources`).all() as {
|
||||
resourceId: number;
|
||||
@@ -82,6 +78,10 @@ export default async function migration() {
|
||||
for (const row of rows) {
|
||||
updateStmt.run(randomUUID(), row.resourceId);
|
||||
}
|
||||
|
||||
db.prepare(
|
||||
`CREATE UNIQUE INDEX resources_resourceGuid_unique ON resources ('resourceGuid');`
|
||||
).run();
|
||||
})();
|
||||
|
||||
console.log(`${version} migration complete`);
|
||||
|
||||
Reference in New Issue
Block a user