import { MigrationInterface, QueryRunner } from 'typeorm'; export class AddsArticlesTable1775010269415 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`--sql CREATE TABLE articles ( id BIGSERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL UNIQUE, description TEXT NOT NULL, cover_image_url TEXT NOT NULL, content TEXT NOT NULL, author_id BIGINT NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT now(), updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), external_id UUID NOT NULL DEFAULT gen_random_uuid() UNIQUE, FOREIGN KEY (author_id) REFERENCES users (id) ON DELETE CASCADE ); --end-sql`); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`--sql DROP TABLE articles; --end-sql`); } }