Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/db/sql/2026-11-initiative-max-members.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Clears the one initiative whose max_members is 0, so the check added in the
-- same change (initiative_max_members_check: null or > 0) can be created. The
-- API has refused 0 for a while ("zero would be an initiative nobody can
-- join"); null means uncapped. In production the only such row is archived
-- with no applications, so the change reaches nobody.
--
-- Run against production BEFORE that change deploys, or push fails adding the
-- check. One transaction; a second run changes nothing.

begin;

update "initiative" set "max_members" = null, "updated_at" = now()
where "max_members" <= 0;

commit;
8 changes: 3 additions & 5 deletions packages/db/src/schemas/club-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
integer,
index,
} from "drizzle-orm/pg-core";
import { sql } from "drizzle-orm";
import { initiatives } from "./initiatives";

// The public roster on `/` and `/projects`. Separate from `initiative`, which
Expand Down Expand Up @@ -35,10 +34,9 @@ export const clubProjects = pgTable(
// they ever sign in, and past leads have graduated.
leadName: text("lead_name"),
summary: text("summary").notNull(),
tech: text("tech")
.array()
.notNull()
.default(sql`'{}'::text[]`),
// No array default: drizzle-kit reads it back in a different spelling and
// re-applied it on every push. The seed, the only writer, always sets it.
tech: text("tech").array().notNull(),
repoUrl: text("repo_url"),
joinUrl: text("join_url"),
capacityNote: text("capacity_note"),
Expand Down
4 changes: 3 additions & 1 deletion packages/db/src/schemas/initiatives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {
index,
unique,
uniqueIndex,
check,
} from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm";
import { relations, sql } from "drizzle-orm";
import { users } from "./auth";

// Club initiatives: things a project leader runs year-round that members
Expand Down Expand Up @@ -99,6 +100,7 @@ export const initiatives = pgTable(
(table) => [
index("initiative_leader_idx").on(table.leaderUserId),
index("initiative_status_idx").on(table.status),
check("initiative_max_members_check", sql`${table.maxMembers} > 0`),
],
);

Expand Down
Loading