Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated AppUser primary key type #329

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions migrations/.snapshot-cathedral.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
"columns": {
"id": {
"name": "id",
"type": "char(254)",
"type": "uuid",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 254,
"mappedType": "character"
"mappedType": "uuid"
},
"name": {
"name": "name",
Expand Down Expand Up @@ -158,13 +157,12 @@
"columns": {
"app_user_id": {
"name": "app_user_id",
"type": "char(254)",
"type": "uuid",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"length": 254,
"mappedType": "character"
"mappedType": "uuid"
},
"organization_id": {
"name": "organization_id",
Expand Down
29 changes: 29 additions & 0 deletions migrations/Migration20240818015511.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Migration } from '@mikro-orm/migrations';

export class Migration20240818015511 extends Migration {

override async up(): Promise<void> {
this.addSql('alter table "app_user_organization_role" drop constraint "app_user_organization_role_app_user_id_foreign";');

this.addSql('alter table "app_user" alter column "id" drop default;');
this.addSql('alter table "app_user" alter column "id" type uuid using ("id"::text::uuid);');

this.addSql('alter table "app_user_organization_role" alter column "app_user_id" drop default;');
this.addSql('alter table "app_user_organization_role" alter column "app_user_id" type uuid using ("app_user_id"::text::uuid);');
this.addSql('alter table "app_user_organization_role" add constraint "app_user_organization_role_app_user_id_foreign" foreign key ("app_user_id") references "app_user" ("id") on delete cascade;');
}

override async down(): Promise<void> {
this.addSql('alter table "app_user" alter column "id" type text using ("id"::text);');

this.addSql('alter table "app_user_organization_role" alter column "app_user_id" type text using ("app_user_id"::text);');

this.addSql('alter table "app_user_organization_role" drop constraint "app_user_organization_role_app_user_id_foreign";');

this.addSql('alter table "app_user" alter column "id" type char(254) using ("id"::char(254));');

this.addSql('alter table "app_user_organization_role" alter column "app_user_id" type char(254) using ("app_user_id"::char(254));');
this.addSql('alter table "app_user_organization_role" add constraint "app_user_organization_role_app_user_id_foreign" foreign key ("app_user_id") references "app_user" ("id") on delete cascade;');
}

}
2 changes: 1 addition & 1 deletion server/data/models/AppUserSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AppUser from "../../domain/application/AppUser.js";
export default new EntitySchema<AppUser>({
class: AppUser,
properties: {
id: { type: 'character varying', primary: true, length: 254 },
id: { type: 'uuid', primary: true },
name: { type: 'character varying', nullable: false, length: 254 },
creationDate: { type: 'datetime', nullable: false },
lastLoginDate: { type: 'datetime', nullable: true },
Expand Down
Loading