CREATE TABLE "shell_layouts" (
	"tenant_id" uuid NOT NULL,
	"user_id" uuid NOT NULL,
	"device_class" text NOT NULL,
	"payload" jsonb NOT NULL,
	"version" integer DEFAULT 1 NOT NULL,
	"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
	CONSTRAINT "shell_layouts_tenant_id_user_id_device_class_pk" PRIMARY KEY("tenant_id","user_id","device_class")
);
--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "force_shell" text;--> statement-breakpoint
ALTER TABLE "user_preferences" ADD COLUMN "ui_shell" text DEFAULT 'os' NOT NULL;--> statement-breakpoint
ALTER TABLE "shell_layouts" ADD CONSTRAINT "shell_layouts_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "shell_layouts" ADD CONSTRAINT "shell_layouts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD CONSTRAINT "tenant_settings_force_shell_check" CHECK ("tenant_settings"."force_shell" IN ('classic','os') OR "tenant_settings"."force_shell" IS NULL);--> statement-breakpoint
ALTER TABLE "user_preferences" ADD CONSTRAINT "user_preferences_ui_shell_check" CHECK (ui_shell IN ('classic','os'));