feat: disciple link

This commit is contained in:
Krispire Admin
2026-08-07 22:46:08 +05:30
parent 4553725d4e
commit afcdd7ef19
21 changed files with 863 additions and 23 deletions
@@ -0,0 +1,19 @@
-- Direct-disciple linkage. Śrīla Prabhupāda's own initiated disciples have
-- started joining the platform; an admin links their account to the matching
-- row in the Mongo `disciples` collection so the site can mark them
-- authentically (a badge on their profile, a highlight in /disciples).
--
-- disciple_id holds the Mongo ObjectID hex (24 chars). It's a cross-store
-- reference, so no foreign key is possible — the admin endpoint validates the
-- id exists in Mongo before writing, and a dangling id degrades gracefully
-- (the name simply doesn't hydrate).
--
-- The partial UNIQUE index enforces the one-to-one rule: a given disciple can
-- be claimed by at most one account, so two users can't both present as the
-- same disciple. NULLs are unconstrained, which leaves the overwhelming
-- majority of users unaffected and keeps the index tiny.
ALTER TABLE users
ADD COLUMN IF NOT EXISTS disciple_id TEXT;
CREATE UNIQUE INDEX IF NOT EXISTS users_disciple_id_key
ON users (disciple_id) WHERE disciple_id IS NOT NULL;