18 lines
1.0 KiB
SQL
18 lines
1.0 KiB
SQL
CREATE TABLE "push_notifications" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"owner_user_id" uuid NOT NULL,
|
|
"recipient_device_id" uuid NOT NULL,
|
|
"type" varchar(64) NOT NULL,
|
|
"payload" jsonb DEFAULT 'null'::jsonb,
|
|
"status" varchar(32) DEFAULT 'queued' NOT NULL,
|
|
"attempts" integer DEFAULT 0 NOT NULL,
|
|
"last_error" text,
|
|
"sent_at" timestamp with time zone,
|
|
"next_attempt_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "push_notifications" ADD CONSTRAINT "push_notifications_owner_user_id_users_id_fk" FOREIGN KEY ("owner_user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "push_notifications" ADD CONSTRAINT "push_notifications_recipient_device_id_devices_id_fk" FOREIGN KEY ("recipient_device_id") REFERENCES "public"."devices"("id") ON DELETE no action ON UPDATE no action;
|