summary refs log tree commit diff
path: root/src/util/migrations/postgres/1663440587650-registration_tokens.ts
blob: a794262c5d4de088a1767db0dba851d71ba3d1f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { MigrationInterface, QueryRunner } from "typeorm";

export class registrationTokens1663440587650 implements MigrationInterface {
    name = 'registrationTokens1663440587650'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`
            CREATE TABLE "valid_registration_tokens" (
                "id" character varying NOT NULL,
                "token" character varying NOT NULL,
                "created_at" TIMESTAMP NOT NULL,
                "expires_at" TIMESTAMP NOT NULL,
                CONSTRAINT "PK_aac42a46cd46369450217de1c8a" PRIMARY KEY ("id")
            )
        `);
        await queryRunner.query(`
            ALTER TABLE "members"
            ALTER COLUMN "bio" DROP DEFAULT
        `);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`
            ALTER TABLE "members"
            ALTER COLUMN "bio"
            SET DEFAULT ''
        `);
        await queryRunner.query(`
            DROP TABLE "valid_registration_tokens"
        `);
    }

}