-- UI settings: generic key-value store scoped by namespace (JSONB value, soft delete) -- Use namespace e.g. demo-dashboard:{userId}, feature-flags:global, saved-filters:{clientId} CREATE TABLE "uiSettings" ( id uuid PRIMARY KEY DEFAULT uuid_generate_v7(), namespace VARCHAR(255) NOT NULL, key VARCHAR(255) NOT NULL, value JSONB NOT NULL, "isDeleted" BOOLEAN NOT NULL DEFAULT FALSE, "createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(), "updatedAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(), UNIQUE(namespace, key) ); -- Index for list/filter by namespace; UNIQUE(namespace, key) already creates an index on (namespace, key) CREATE INDEX idx_uisettings_namespace ON "uiSettings"(namespace);