Update UserSettings primary key to text, to match user

This commit is contained in:
William Oldham
2023-11-22 23:16:52 +00:00
parent 4bf2e658f7
commit d3aa4847f8
3 changed files with 18 additions and 5 deletions

View File

@@ -587,12 +587,12 @@
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
"type": "uuid", "type": "text",
"unsigned": false, "unsigned": false,
"autoincrement": false, "autoincrement": false,
"primary": false, "primary": false,
"nullable": false, "nullable": false,
"mappedType": "uuid" "mappedType": "text"
}, },
"application_theme": { "application_theme": {
"name": "application_theme", "name": "application_theme",

View File

@@ -0,0 +1,14 @@
import { Migration } from '@mikro-orm/migrations';
export class Migration20231122231620 extends Migration {
async up(): Promise<void> {
this.addSql('alter table "user_settings" alter column "id" type text using ("id"::text);');
}
async down(): Promise<void> {
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);');
}
}

View File

@@ -1,10 +1,9 @@
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'; import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
import { randomUUID } from 'crypto';
@Entity({ tableName: 'user_settings' }) @Entity({ tableName: 'user_settings' })
export class UserSettings { export class UserSettings {
@PrimaryKey({ name: 'id', type: 'uuid' }) @PrimaryKey({ name: 'id', type: 'text' })
id: string = randomUUID(); id!: string;
@Property({ name: 'application_theme', nullable: true }) @Property({ name: 'application_theme', nullable: true })
applicationTheme?: string | null; applicationTheme?: string | null;