diff --git a/src/db/migrations/.snapshot-movie_web.json b/src/db/migrations/.snapshot-movie_web.json index 4b40879..4a6d346 100644 --- a/src/db/migrations/.snapshot-movie_web.json +++ b/src/db/migrations/.snapshot-movie_web.json @@ -587,12 +587,12 @@ "columns": { "id": { "name": "id", - "type": "uuid", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "uuid" + "mappedType": "text" }, "application_theme": { "name": "application_theme", diff --git a/src/db/migrations/Migration20231122231620.ts b/src/db/migrations/Migration20231122231620.ts new file mode 100644 index 0000000..ec603f8 --- /dev/null +++ b/src/db/migrations/Migration20231122231620.ts @@ -0,0 +1,14 @@ +import { Migration } from '@mikro-orm/migrations'; + +export class Migration20231122231620 extends Migration { + + async up(): Promise { + this.addSql('alter table "user_settings" alter column "id" type text using ("id"::text);'); + } + + async down(): Promise { + this.addSql('alter table "user_settings" alter column "id" drop default;'); + this.addSql('alter table "user_settings" alter column "id" type uuid using ("id"::text::uuid);'); + } + +} diff --git a/src/db/models/UserSettings.ts b/src/db/models/UserSettings.ts index 22fbfa3..4014255 100644 --- a/src/db/models/UserSettings.ts +++ b/src/db/models/UserSettings.ts @@ -1,10 +1,9 @@ import { Entity, PrimaryKey, Property } from '@mikro-orm/core'; -import { randomUUID } from 'crypto'; @Entity({ tableName: 'user_settings' }) export class UserSettings { - @PrimaryKey({ name: 'id', type: 'uuid' }) - id: string = randomUUID(); + @PrimaryKey({ name: 'id', type: 'text' }) + id!: string; @Property({ name: 'application_theme', nullable: true }) applicationTheme?: string | null;