summary refs log tree commit diff
path: root/src/util/migration/postgres/1763630755675-default-activities-to-empty-array.ts
blob: cc4b53372e9f7fb8112228db5bdf1af5b5bd01ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { MigrationInterface, QueryRunner } from "typeorm";

export class DefaultActivitiesToEmptyArray1763630755675 implements MigrationInterface {
	name = "DefaultActivitiesToEmptyArray1763630755675";

	public async up(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "activities" SET NOT NULL`);
		await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "activities" SET DEFAULT '[]'`);
	}

	public async down(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "activities" DROP DEFAULT`);
		await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "activities" DROP NOT NULL`);
	}
}