chore: Migrate notification module to DML (#7835)

This commit is contained in:
Stevche Radevski
2024-07-01 11:17:32 +02:00
committed by GitHub
parent c661180c44
commit 9daec5d7ac
11 changed files with 161 additions and 177 deletions

View File

@@ -50,7 +50,40 @@
"autoincrement": false,
"primary": false,
"nullable": false,
"default": "'{}'",
"mappedType": "array"
},
"created_at": {
"name": "created_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"updated_at": {
"name": "updated_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"length": 6,
"mappedType": "datetime"
}
},
"name": "notification_provider",
@@ -198,6 +231,27 @@
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"updated_at": {
"name": "updated_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"length": 6,
"mappedType": "datetime"
}
},
"name": "notification",
@@ -209,15 +263,15 @@
"composite": false,
"primary": false,
"unique": false,
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_receiver_id\" ON \"notification\" (receiver_id)"
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_receiver_id\" ON \"notification\" (receiver_id) WHERE deleted_at IS NULL"
},
{
"keyName": "IDX_notification_idempotency_key",
"keyName": "IDX_notification_idempotency_key_unique",
"columnNames": [],
"composite": false,
"primary": false,
"unique": false,
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_idempotency_key\" ON \"notification\" (idempotency_key)"
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_notification_idempotency_key_unique\" ON \"notification\" (idempotency_key) WHERE deleted_at IS NULL"
},
{
"keyName": "IDX_notification_provider_id",
@@ -225,7 +279,7 @@
"composite": false,
"primary": false,
"unique": false,
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_id\" ON \"notification\" (provider_id)"
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_id\" ON \"notification\" (provider_id) WHERE deleted_at IS NULL"
},
{
"keyName": "notification_pkey",

View File

@@ -0,0 +1,23 @@
import { Migration } from "@mikro-orm/migrations"
export class Migration20240628075401 extends Migration {
async up(): Promise<void> {
this.addSql(
'alter table if exists "notification_provider" add column if not exists "created_at" timestamptz not null default now(), add column "updated_at" timestamptz not null default now(), add column "deleted_at" timestamptz null;'
)
this.addSql(
'alter table if exists "notification_provider" alter column "channels" type text[] using ("channels"::text[]);'
)
this.addSql(
'alter table if exists "notification_provider" alter column "channels" set default \'{}\';'
)
this.addSql(
'alter table if exists "notification" add column if not exists "updated_at" timestamptz not null default now(), add column "deleted_at" timestamptz null;'
)
this.addSql('drop index if exists "IDX_notification_idempotency_key";')
this.addSql(
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_notification_idempotency_key_unique" ON "notification" (idempotency_key) WHERE deleted_at IS NULL;'
)
}
}