Initial Commit
This commit is contained in:
26
migrations/1774988438124-adds-user-table.ts
Normal file
26
migrations/1774988438124-adds-user-table.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user