summary refs log tree commit diff
path: root/src/util/migration/postgres
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-07-12 20:12:37 +0200
committerRory& <root@rory.gay>2025-09-29 18:38:06 +0200
commit528662446c3377032190c117f5a3fe2fa8f3b88e (patch)
tree4d58bc6e22e74be7e47e1a8f52d1a13bf894b53b /src/util/migration/postgres
parentA little bit of formatting cleanup (diff)
downloadserver-ts-528662446c3377032190c117f5a3fe2fa8f3b88e.tar.xz
Colorful roles
Diffstat (limited to 'src/util/migration/postgres')
-rw-r--r--src/util/migration/postgres/1752321571508-RoleColors.ts14
-rw-r--r--src/util/migration/postgres/1752342900886-RoleColorsSolidColor.ts15
2 files changed, 29 insertions, 0 deletions
diff --git a/src/util/migration/postgres/1752321571508-RoleColors.ts b/src/util/migration/postgres/1752321571508-RoleColors.ts
new file mode 100644

index 000000000..687142e3c --- /dev/null +++ b/src/util/migration/postgres/1752321571508-RoleColors.ts
@@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class RoleColors1752321571508 implements MigrationInterface { + name = 'RoleColors1752321571508' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "roles" ADD "colors" text`); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "roles" DROP COLUMN "colors"`); + } + +} diff --git a/src/util/migration/postgres/1752342900886-RoleColorsSolidColor.ts b/src/util/migration/postgres/1752342900886-RoleColorsSolidColor.ts new file mode 100644
index 000000000..36c24a375 --- /dev/null +++ b/src/util/migration/postgres/1752342900886-RoleColorsSolidColor.ts
@@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class RoleColorsSolidColor1752342900886 implements MigrationInterface { + name = 'RoleColorsSolidColor1752342900886' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`UPDATE "roles" SET "colors" = jsonb_build_object('primary_color', "color") WHERE "colors" IS NULL`); + await queryRunner.query(`ALTER TABLE "roles" ALTER COLUMN "colors" SET NOT NULL`); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "roles" ALTER COLUMN "colors" DROP NOT NULL`); + } + +}