···11+CREATE OR REPLACE FUNCTION service_id()
22+RETURNS text AS $$
33+SELECT 'svc_' || xata_private.xid();
44+$$ LANGUAGE sql IMMUTABLE;
55+66+CREATE TABLE "services" (
77+ "id" text PRIMARY KEY DEFAULT service_id() NOT NULL,
88+ "sandbox_id" text NOT NULL,
99+ "name" text NOT NULL,
1010+ "command" text NOT NULL,
1111+ "description" text,
1212+ "created_at" timestamp DEFAULT now() NOT NULL,
1313+ "updated_at" timestamp DEFAULT now() NOT NULL
1414+);
1515+--> statement-breakpoint
1616+ALTER TABLE "sandbox_ports" ADD COLUMN "service_id" text;--> statement-breakpoint
1717+ALTER TABLE "services" ADD CONSTRAINT "services_sandbox_id_sandboxes_id_fk" FOREIGN KEY ("sandbox_id") REFERENCES "public"."sandboxes"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
1818+CREATE UNIQUE INDEX "unique_sandbox_service" ON "services" USING btree ("name","sandbox_id");--> statement-breakpoint
1919+ALTER TABLE "sandbox_ports" ADD CONSTRAINT "sandbox_ports_service_id_services_id_fk" FOREIGN KEY ("service_id") REFERENCES "public"."services"("id") ON DELETE no action ON UPDATE no action;