mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-26 13:19:34 +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]
|
||||
category text [not null]
|
||||
type text [not null]
|
||||
title_key text
|
||||
title text
|
||||
content_key text [not null]
|
||||
content_params jsonb
|
||||
content text
|
||||
title text [not null]
|
||||
content text [not null]
|
||||
dedupe_key text
|
||||
action_url text
|
||||
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,
|
||||
"tag": "0096_add_notification_title",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 97,
|
||||
"version": "7",
|
||||
"when": 1774361934253,
|
||||
"tag": "0097_simplify_notification_columns",
|
||||
"breakpoints": true
|
||||
}
|
||||
],
|
||||
"version": "6"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 { createdAt, timestamptz, updatedAt } from './_helpers';
|
||||
@@ -22,17 +22,10 @@ export const notifications = pgTable(
|
||||
/** Specific scenario type, e.g. `budget_exhausted`, `subscription_expiring` */
|
||||
type: text('type').notNull(),
|
||||
|
||||
/** i18n key for notification title, rendered via react-i18next */
|
||||
titleKey: text('title_key'),
|
||||
/** Pre-rendered title text, used for email subject and i18n fallback */
|
||||
title: text('title'),
|
||||
|
||||
/** 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'),
|
||||
/** Notification title, used for email subject and inbox display */
|
||||
title: text('title').notNull(),
|
||||
/** Notification body text */
|
||||
content: text('content').notNull(),
|
||||
|
||||
/** Idempotency key — same (userId, dedupeKey) pair prevents duplicate notifications */
|
||||
dedupeKey: text('dedupe_key'),
|
||||
|
||||
Reference in New Issue
Block a user