feat(mining-admin): add Prisma migration for notification tables
Create notifications, notification_reads, notification_user_targets tables with indexes and unique constraints. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5ee94b3672
commit
e68b5aa3d9
|
|
@ -0,0 +1,63 @@
|
|||
-- CreateEnum
|
||||
CREATE TYPE "NotificationType" AS ENUM ('SYSTEM', 'ACTIVITY', 'REWARD', 'UPGRADE', 'ANNOUNCEMENT');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "NotificationPriority" AS ENUM ('LOW', 'NORMAL', 'HIGH', 'URGENT');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "TargetType" AS ENUM ('ALL', 'SPECIFIC');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "notifications" (
|
||||
"id" TEXT NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"content" TEXT NOT NULL,
|
||||
"type" "NotificationType" NOT NULL DEFAULT 'SYSTEM',
|
||||
"priority" "NotificationPriority" NOT NULL DEFAULT 'NORMAL',
|
||||
"target_type" "TargetType" NOT NULL DEFAULT 'ALL',
|
||||
"image_url" TEXT,
|
||||
"link_url" TEXT,
|
||||
"is_enabled" BOOLEAN NOT NULL DEFAULT true,
|
||||
"requires_force_read" BOOLEAN NOT NULL DEFAULT false,
|
||||
"published_at" TIMESTAMP(3),
|
||||
"expires_at" TIMESTAMP(3),
|
||||
"created_by" TEXT NOT NULL DEFAULT 'admin',
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "notifications_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "notification_reads" (
|
||||
"id" TEXT NOT NULL,
|
||||
"notification_id" TEXT NOT NULL,
|
||||
"user_serial_num" TEXT NOT NULL,
|
||||
"read_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "notification_reads_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "notification_user_targets" (
|
||||
"id" TEXT NOT NULL,
|
||||
"notification_id" TEXT NOT NULL,
|
||||
"account_sequence" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "notification_user_targets_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "notifications_is_enabled_published_at_idx" ON "notifications"("is_enabled", "published_at");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "notifications_type_idx" ON "notifications"("type");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "notification_reads_notification_id_user_serial_num_key" ON "notification_reads"("notification_id", "user_serial_num");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "notification_reads_user_serial_num_idx" ON "notification_reads"("user_serial_num");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "notification_user_targets_notification_id_account_sequence_key" ON "notification_user_targets"("notification_id", "account_sequence");
|
||||
Loading…
Reference in New Issue