27 lines
1.2 KiB
SQL
27 lines
1.2 KiB
SQL
-- Move live-listener ownership fully to the account boundary.
|
|
--
|
|
-- `live_sources.owner_user_id` and `cookiecloud_credentials.user_id` already
|
|
-- enforce one listener configuration and one credential source per account.
|
|
-- The component-level `source_id` foreign key was therefore redundant and,
|
|
-- more importantly, made new component kinds look as though they selected
|
|
-- their own upstream listener. Components now subscribe to their owner's
|
|
-- canonical event stream and retain only their account ownership.
|
|
|
|
DROP INDEX IF EXISTS component_instances_source_idx;
|
|
|
|
ALTER TABLE component_instances
|
|
DROP CONSTRAINT IF EXISTS component_instances_owner_user_id_source_id_fkey;
|
|
|
|
ALTER TABLE component_instances
|
|
DROP COLUMN IF EXISTS source_id;
|
|
|
|
CREATE INDEX IF NOT EXISTS component_instances_owner_enabled_idx
|
|
ON component_instances(owner_user_id, enabled, created_at);
|
|
|
|
COMMENT ON TABLE live_sources IS
|
|
'One immutable Bilibili live-listener configuration per account.';
|
|
COMMENT ON TABLE cookiecloud_credentials IS
|
|
'One encrypted CookieCloud credential source per account.';
|
|
COMMENT ON TABLE component_instances IS
|
|
'Account-owned consumers of the owning account live-event stream.';
|