💾 Archived View for iich.space › src › db › migrations › 1631499262.ts captured on 2022-03-01 at 16:03:21.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

import { Migration } from '../migrate';

export const migration: Migration = {
  down: (db) => {
    db.exec(`
DROP TABLE boards;
DROP TABLE posts;
`);
  },
  up: (db) => {
    db.exec(`
CREATE TABLE boards (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name VARCHAR(16),
  createdAt DATETIME DEFAULT (DATETIME('now', 'localtime')),
  updatedAt DATETIME DEFAULT (DATETIME('now', 'localtime'))
);

CREATE TABLE posts (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  comment VARCHAR(1024),
  createdAt DATETIME DEFAULT (DATETIME('now', 'localtime')),
  updatedAt DATETIME DEFAULT (DATETIME('now', 'localtime')),
  boardId INTEGER
    REFERENCES boards (id)
    ON DELETE SET NULL ON UPDATE CASCADE,
  threadId INTEGER
    REFERENCES posts (id)
    ON DELETE SET NULL ON UPDATE CASCADE
);
`);
  },
  version: 1631499262,
};