Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

582 B
Raw Blame
import { Migration } from 'kysely';

export const createDocumentStatesTable: Migration = {
  up: async (db) => {
    await db.schema
      .createTable('document_states')
      .addColumn('id', 'text', (col) =>
        col
          .notNull()
          .primaryKey()
          .references('documents.id')
          .onDelete('cascade')
      )
      .addColumn('state', 'blob', (col) => col.notNull())
      .addColumn('revision', 'integer', (col) => col.notNull())
      .execute();
  },
  down: async (db) => {
    await db.schema.dropTable('document_states').execute();
  },
};