CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
0023_sponsors.sql
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 08420cd | 1 | -- Gluecron migration 0023: Sponsors (Block I6). |
| 2 | -- | |
| 3 | -- Lightweight sponsorship model: | |
| 4 | -- sponsorship_tiers — the maintainer's published tiers (amount, description, benefit) | |
| 5 | -- sponsorships — ongoing or one-time support relationships | |
| 6 | -- | |
| 7 | -- Payment rails are out of scope — we store the intent + any external | |
| 8 | -- provider/transaction reference. The UI surfaces a "Sponsor" button on user | |
| 9 | -- profiles that have at least one active tier. | |
| 10 | ||
| 11 | --> statement-breakpoint | |
| 12 | CREATE TABLE IF NOT EXISTS "sponsorship_tiers" ( | |
| 13 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | |
| 14 | "maintainer_id" uuid NOT NULL, | |
| 15 | "name" text NOT NULL, -- "Coffee", "Champion", "Patron" | |
| 16 | "description" text NOT NULL DEFAULT '', | |
| 17 | "monthly_cents" integer NOT NULL, -- 500 = $5/mo; 0 = one-time-only | |
| 18 | "one_time_allowed" boolean NOT NULL DEFAULT true, | |
| 19 | "is_active" boolean NOT NULL DEFAULT true, | |
| 20 | "created_at" timestamp DEFAULT now() NOT NULL, | |
| 21 | CONSTRAINT "sponsor_tiers_maintainer_fk" FOREIGN KEY ("maintainer_id") REFERENCES "users"("id") ON DELETE cascade | |
| 22 | ); | |
| 23 | ||
| 24 | --> statement-breakpoint | |
| 25 | CREATE INDEX IF NOT EXISTS "sponsor_tiers_maintainer" ON "sponsorship_tiers" ("maintainer_id", "is_active"); | |
| 26 | ||
| 27 | --> statement-breakpoint | |
| 28 | CREATE TABLE IF NOT EXISTS "sponsorships" ( | |
| 29 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | |
| 30 | "sponsor_id" uuid NOT NULL, -- the user paying | |
| 31 | "maintainer_id" uuid NOT NULL, -- the user receiving | |
| 32 | "tier_id" uuid, -- optional (custom amounts allowed) | |
| 33 | "amount_cents" integer NOT NULL, | |
| 34 | "kind" text NOT NULL, -- one_time | monthly | |
| 35 | "note" text, -- public or private thank-you note | |
| 36 | "is_public" boolean NOT NULL DEFAULT true, | |
| 37 | "external_ref" text, -- stripe/provider txn id | |
| 38 | "cancelled_at" timestamp, | |
| 39 | "created_at" timestamp DEFAULT now() NOT NULL, | |
| 40 | CONSTRAINT "sponsorships_sponsor_fk" FOREIGN KEY ("sponsor_id") REFERENCES "users"("id") ON DELETE cascade, | |
| 41 | CONSTRAINT "sponsorships_maintainer_fk" FOREIGN KEY ("maintainer_id") REFERENCES "users"("id") ON DELETE cascade | |
| 42 | ); | |
| 43 | ||
| 44 | --> statement-breakpoint | |
| 45 | CREATE INDEX IF NOT EXISTS "sponsorships_maintainer" ON "sponsorships" ("maintainer_id", "created_at"); | |
| 46 | --> statement-breakpoint | |
| 47 | CREATE INDEX IF NOT EXISTS "sponsorships_sponsor" ON "sponsorships" ("sponsor_id", "created_at"); |