Replace isPublic boolean with visibility enum (private/link/public) across the full stack. Add shares table to schema for future share link support. Update all services, routes, schemas, hooks, components, and tests. Plan: 32-01 (Setup Sharing System - Schema Migration) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
17 lines
972 B
SQL
17 lines
972 B
SQL
CREATE TABLE "shares" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"setup_id" integer NOT NULL,
|
|
"token" text NOT NULL,
|
|
"permission" text DEFAULT 'read' NOT NULL,
|
|
"expires_at" timestamp,
|
|
"user_id" integer,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"revoked_at" timestamp,
|
|
CONSTRAINT "shares_token_unique" UNIQUE("token")
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "setups" ADD COLUMN "visibility" text DEFAULT 'private' NOT NULL;--> statement-breakpoint
|
|
UPDATE "setups" SET "visibility" = 'public' WHERE "is_public" = true;--> statement-breakpoint
|
|
ALTER TABLE "shares" ADD CONSTRAINT "shares_setup_id_setups_id_fk" FOREIGN KEY ("setup_id") REFERENCES "public"."setups"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "shares" ADD CONSTRAINT "shares_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "setups" DROP COLUMN "is_public"; |