12 lines
1.2 KiB
SQL
12 lines
1.2 KiB
SQL
CREATE TABLE "group_access_windows" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"group_id" uuid NOT NULL,
|
|
"start_minute_of_week" integer NOT NULL,
|
|
"end_minute_of_week" integer NOT NULL,
|
|
"created_at" timestamp (3) with time zone DEFAULT now() NOT NULL,
|
|
CONSTRAINT "group_access_windows_minute_range_check" CHECK ("group_access_windows"."start_minute_of_week" >= 0 and "group_access_windows"."start_minute_of_week" < 10080 and "group_access_windows"."end_minute_of_week" >= 0 and "group_access_windows"."end_minute_of_week" < 10080 and "group_access_windows"."start_minute_of_week" <> "group_access_windows"."end_minute_of_week")
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "app_settings" ADD COLUMN "scheduled_access_denied_message" text DEFAULT 'Your group is only allowed access from {next_start} to {next_end}.' NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE "group_access_windows" ADD CONSTRAINT "group_access_windows_group_id_groups_id_fk" FOREIGN KEY ("group_id") REFERENCES "public"."groups"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "group_access_windows_group_idx" ON "group_access_windows" USING btree ("group_id"); |