Something went wrong. Try again.
A fork of @slices.network/slices forked from slices.network/slices
Something went wrong. Try again.
894 B · 18 lines
SQL
at main
123456789101112131415161718-- Add slice_uri column to actor table to associate actors with specific slicesALTER TABLE "actor" ADD COLUMN "slice_uri" TEXT;
-- Create a new primary key that includes both did and slice_uri-- First drop the existing primary keyALTER TABLE "actor" DROP CONSTRAINT "actor_pkey";
-- Add the new composite primary keyALTER TABLE "actor" ADD PRIMARY KEY ("did", "slice_uri");
-- Create new indexes for slice-based queriesCREATE 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