-- Add slice_uri column to actor table to associate actors with specific slices ALTER TABLE "actor" ADD COLUMN "slice_uri" TEXT; -- Create a new primary key that includes both did and slice_uri -- First drop the existing primary key ALTER TABLE "actor" DROP CONSTRAINT "actor_pkey"; -- Add the new composite primary key ALTER TABLE "actor" ADD PRIMARY KEY ("did", "slice_uri"); -- Create new indexes for slice-based queries CREATE INDEX IF NOT EXISTS idx_actor_slice_uri ON "actor"("slice_uri"); CREATE INDEX IF NOT EXISTS idx_actor_slice_handle ON "actor"("slice_uri", "handle"); CREATE INDEX IF NOT EXISTS idx_actor_slice_indexed_at ON "actor"("slice_uri", "indexed_at"); -- Update existing records to have a default slice_uri (if any exist) -- This will need to be handled manually or with a data migration -- For now, we'll leave existing records as-is since they'll have NULL slice_uri