mirror of
https://github.com/db9979/tidefront.git
synced 2026-12-06 21:04:12 +01:00
35 lines
1.8 KiB
SQL
35 lines
1.8 KiB
SQL
CREATE TABLE "formation_template" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"player_id" integer NOT NULL,
|
|
"name" text NOT NULL,
|
|
"units" jsonb NOT NULL,
|
|
"mission_type" text,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "morning_summary" (
|
|
"player_id" integer PRIMARY KEY NOT NULL,
|
|
"enabled" boolean DEFAULT false NOT NULL,
|
|
"minute_of_day" integer DEFAULT 420 NOT NULL,
|
|
"time_zone" text DEFAULT 'Europe/Berlin' NOT NULL,
|
|
"push" boolean DEFAULT false NOT NULL,
|
|
"last_sent_day" text,
|
|
"last_sent_at" timestamp with time zone,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "summary_entry" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"player_id" integer NOT NULL,
|
|
"kind" text NOT NULL,
|
|
"title" text NOT NULL,
|
|
"body" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "formation_template" ADD CONSTRAINT "formation_template_player_id_player_id_fk" FOREIGN KEY ("player_id") REFERENCES "public"."player"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "morning_summary" ADD CONSTRAINT "morning_summary_player_id_player_id_fk" FOREIGN KEY ("player_id") REFERENCES "public"."player"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "summary_entry" ADD CONSTRAINT "summary_entry_player_id_player_id_fk" FOREIGN KEY ("player_id") REFERENCES "public"."player"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "formation_template_name" ON "formation_template" USING btree ("player_id",lower("name"));--> statement-breakpoint
|
|
CREATE INDEX "summary_entry_player" ON "summary_entry" USING btree ("player_id","created_at"); |