add from to notification model (#14102)

This commit is contained in:
Pedro Guzman
2025-11-24 09:24:38 +01:00
committed by GitHub
parent 0cb12021ef
commit f67bfb9f92
9 changed files with 83 additions and 15 deletions

View File

@@ -96,7 +96,7 @@
"constraint": false,
"primary": false,
"unique": false,
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_deleted_at\" ON \"notification_provider\" (deleted_at) WHERE deleted_at IS NULL"
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_deleted_at\" ON \"notification_provider\" (\"deleted_at\") WHERE deleted_at IS NULL"
},
{
"keyName": "notification_provider_pkey",
@@ -133,6 +133,15 @@
"nullable": false,
"mappedType": "text"
},
"from": {
"name": "from",
"type": "text",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "text"
},
"channel": {
"name": "channel",
"type": "text",
@@ -290,7 +299,7 @@
"constraint": false,
"primary": false,
"unique": false,
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_receiver_id\" ON \"notification\" (receiver_id) WHERE deleted_at IS NULL"
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_receiver_id\" ON \"notification\" (\"receiver_id\") WHERE deleted_at IS NULL"
},
{
"keyName": "IDX_notification_idempotency_key_unique",
@@ -299,7 +308,7 @@
"constraint": false,
"primary": false,
"unique": false,
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_notification_idempotency_key_unique\" ON \"notification\" (idempotency_key) WHERE deleted_at IS NULL"
"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",
@@ -308,7 +317,7 @@
"constraint": false,
"primary": false,
"unique": false,
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_id\" ON \"notification\" (provider_id) WHERE deleted_at IS NULL"
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_id\" ON \"notification\" (\"provider_id\") WHERE deleted_at IS NULL"
},
{
"keyName": "IDX_notification_deleted_at",
@@ -317,7 +326,7 @@
"constraint": false,
"primary": false,
"unique": false,
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_deleted_at\" ON \"notification\" (deleted_at) WHERE deleted_at IS NULL"
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_deleted_at\" ON \"notification\" (\"deleted_at\") WHERE deleted_at IS NULL"
},
{
"keyName": "notification_pkey",

View File

@@ -0,0 +1,13 @@
import { Migration } from '@mikro-orm/migrations';
export class Migration20251121123942 extends Migration {
override async up(): Promise<void> {
this.addSql(`alter table if exists "notification" add column if not exists "from" text null;`);
}
override async down(): Promise<void> {
this.addSql(`alter table if exists "notification" drop column if exists "from";`);
}
}

View File

@@ -6,6 +6,8 @@ export const Notification = model.define("notification", {
id: model.id({ prefix: "noti" }).primaryKey(),
// This can be an email, phone number, or username, depending on the channel.
to: model.text().searchable(),
// This can be an email, phone number, or username, depending on the channel.
from: model.text().searchable().nullable(),
channel: model.text(),
// The template name in the provider's system.
template: model.text().nullable(),