mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🗃️ db: simplify notifications schema, drop i18n columns
Remove contentKey, contentParams, titleKey columns — store only rendered title and content.
This commit is contained in:
@@ -927,11 +927,8 @@ table notifications {
|
|||||||
user_id text [not null]
|
user_id text [not null]
|
||||||
category text [not null]
|
category text [not null]
|
||||||
type text [not null]
|
type text [not null]
|
||||||
title_key text
|
title text [not null]
|
||||||
title text
|
content text [not null]
|
||||||
content_key text [not null]
|
|
||||||
content_params jsonb
|
|
||||||
content text
|
|
||||||
dedupe_key text
|
dedupe_key text
|
||||||
action_url text
|
action_url text
|
||||||
is_read boolean [not null, default: false]
|
is_read boolean [not null, default: false]
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
ALTER TABLE "notifications" ALTER COLUMN "title" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "notifications" ALTER COLUMN "content" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "notifications" DROP COLUMN IF EXISTS "title_key";--> statement-breakpoint
|
||||||
|
ALTER TABLE "notifications" DROP COLUMN IF EXISTS "content_key";--> statement-breakpoint
|
||||||
|
ALTER TABLE "notifications" DROP COLUMN IF EXISTS "content_params";
|
||||||
13131
packages/database/migrations/meta/0097_snapshot.json
Normal file
13131
packages/database/migrations/meta/0097_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -679,6 +679,13 @@
|
|||||||
"when": 1774355637598,
|
"when": 1774355637598,
|
||||||
"tag": "0096_add_notification_title",
|
"tag": "0096_add_notification_title",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 97,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1774361934253,
|
||||||
|
"tag": "0097_simplify_notification_columns",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": "6"
|
"version": "6"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { sql } from 'drizzle-orm';
|
import { sql } from 'drizzle-orm';
|
||||||
import { boolean, index, jsonb, pgTable, text, uniqueIndex } from 'drizzle-orm/pg-core';
|
import { boolean, index, pgTable, text, uniqueIndex } from 'drizzle-orm/pg-core';
|
||||||
|
|
||||||
import { idGenerator } from '../utils/idGenerator';
|
import { idGenerator } from '../utils/idGenerator';
|
||||||
import { createdAt, timestamptz, updatedAt } from './_helpers';
|
import { createdAt, timestamptz, updatedAt } from './_helpers';
|
||||||
@@ -22,17 +22,10 @@ export const notifications = pgTable(
|
|||||||
/** Specific scenario type, e.g. `budget_exhausted`, `subscription_expiring` */
|
/** Specific scenario type, e.g. `budget_exhausted`, `subscription_expiring` */
|
||||||
type: text('type').notNull(),
|
type: text('type').notNull(),
|
||||||
|
|
||||||
/** i18n key for notification title, rendered via react-i18next */
|
/** Notification title, used for email subject and inbox display */
|
||||||
titleKey: text('title_key'),
|
title: text('title').notNull(),
|
||||||
/** Pre-rendered title text, used for email subject and i18n fallback */
|
/** Notification body text */
|
||||||
title: text('title'),
|
content: text('content').notNull(),
|
||||||
|
|
||||||
/** i18n key for frontend rendering via react-i18next */
|
|
||||||
contentKey: text('content_key').notNull(),
|
|
||||||
/** Interpolation params for the i18n key */
|
|
||||||
contentParams: jsonb('content_params').$type<Record<string, unknown>>(),
|
|
||||||
/** Pre-rendered markdown/plain text, used for email body and i18n fallback */
|
|
||||||
content: text('content'),
|
|
||||||
|
|
||||||
/** Idempotency key — same (userId, dedupeKey) pair prevents duplicate notifications */
|
/** Idempotency key — same (userId, dedupeKey) pair prevents duplicate notifications */
|
||||||
dedupeKey: text('dedupe_key'),
|
dedupeKey: text('dedupe_key'),
|
||||||
|
|||||||
Reference in New Issue
Block a user