💾 Archived View for iich.space › src › db › migrations › 1631949334.ts captured on 2021-12-04 at 18:04:22.
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
import { Migration } from '../migrate'; export const migration: Migration = { down: (db) => { db.exec(` UPDATE posts SET threadId = NULL WHERE posts.type = 0; UPDATE posts SET boardId = NULL WHERE posts.type = 1; ALTER TABLE posts DROP COLUMN type; `); }, up: (db) => { db.exec(` ALTER TABLE posts ADD type INTEGER DEFAULT NULL; UPDATE posts SET type = 0 WHERE boardId IS NOT NULL; UPDATE posts SET type = 1 WHERE threadId IS NOT NULL; UPDATE posts SET boardId = ( SELECT boardId FROM posts AS threads WHERE posts.threadId = threads.id) WHERE posts.type = 1; UPDATE posts SET threadId = posts.id WHERE posts.type = 0; `); }, version: 1631949334, };