Colorful roles
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`);
+ }
+
+}
|