1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | -- Reconcile the `organizations` table with the code that writes to it.
--
-- Two Drizzle definitions both mapped to this one physical table:
--
-- src/db/schema.ts slug NOT NULL, created_by_id NOT NULL,
-- billing_email — matches migration 0003, i.e.
-- matches the real database.
-- src/db/schema-extensions.ts display_name, website, location, is_verified,
-- and NEITHER not-null column — describes a
-- table this repo has never created.
--
-- drizzle.config.ts includes only schema.ts and deploys run db:migrate (never
-- db:push), so schema-extensions has never been part of the migration
-- pipeline. src/routes/orgs.tsx imports from schema-extensions, so
-- POST /orgs/new inserted display_name/website (columns that do not exist)
-- while omitting slug/created_by_id (NOT NULL, no default). Organization
-- creation has therefore never succeeded — it fails on the first missing
-- column every time.
--
-- Adding the columns rather than deleting the fields: the create form collects
-- a display name and a website, and dropping them would silently discard what
-- the user typed. All four are nullable (is_verified defaulted) so this is
-- additive and safe to run against a populated table.
ALTER TABLE "organizations" ADD COLUMN IF NOT EXISTS "display_name" text;
--> statement-breakpoint
ALTER TABLE "organizations" ADD COLUMN IF NOT EXISTS "website" text;
--> statement-breakpoint
ALTER TABLE "organizations" ADD COLUMN IF NOT EXISTS "location" text;
--> statement-breakpoint
ALTER TABLE "organizations" ADD COLUMN IF NOT EXISTS "is_verified" boolean DEFAULT false NOT NULL;
|