27 lines
792 B
TypeScript
27 lines
792 B
TypeScript
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
export class AddsUserTable1774988438124 implements MigrationInterface {
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`--sql
|
|
CREATE TYPE user_role AS ENUM ('admin', 'internal', 'user');
|
|
|
|
CREATE TABLE users (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
email TEXT NOT NULL UNIQUE,
|
|
role user_role NOT NULL DEFAULT 'user',
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
external_id UUID NOT NULL DEFAULT gen_random_uuid()
|
|
);
|
|
--end-sql`);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`--sql
|
|
DROP TABLE users;
|
|
DROP TYPE user_role;
|
|
--end-sql`);
|
|
}
|
|
}
|