mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-27 06:13:06 +00:00
- campoParties.ts + committed election-aggregates artifact v2 (campo federal votes, federal tally, 2022 majoritarian presidente/governador) - global campaignGoals (state goal + margin) with staff-only read / unrestricted-write access - municipalityPotential.ts (teto do campo, captura, share intracampo, roll-off, proportional state-goal decomposition) and goalCoverage.ts (meta vs comprometido semantics locked this session) - UI: dashboard + list overview 'Cobertura da meta' metric, new list column, detail page 'Conta da cadeira' card - /simplify pass: dropped dead per-request TI-warning computation, O(1) potential lookup, deduped near-identical election loaders/tally types/ percent formatters
38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
import { MigrateDownArgs, MigrateUpArgs, sql } from '@payloadcms/db-postgres'
|
|
|
|
/**
|
|
* Adds the `campaignGoals` global (E8 "conta da cadeira" — state-level vote
|
|
* goal + margin used to decompose a per-municipality suggested goal).
|
|
*
|
|
* Hand-written rather than `migrate:create`-generated: the committed snapshot
|
|
* chain has no `.json` for the last several migrations (2026-07-23/24 —
|
|
* `add_vote_estimate_scenarios`, `remodel_municipalities`,
|
|
* `add_state_deputy`, `reconcile_municipality_remodel`,
|
|
* `drop_municipality_vote_goals`, `contact_phone_optional` all shipped
|
|
* hand-written SQL without regenerating the drizzle-kit snapshot), so the
|
|
* schema differ has no accurate "before" state for `municipality`/`contact`
|
|
* and asks to disambiguate unrelated historical renames. This migration only
|
|
* adds a brand-new table, so it's written directly following the pattern of
|
|
* `20260719_054706_add_privacy_policy_global` (idempotent guard is
|
|
* unnecessary — Payload never lets two migrations with the same name run
|
|
* twice, and the table cannot already exist).
|
|
*/
|
|
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
|
await db.execute(sql`
|
|
CREATE TABLE "campaign_goals" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"state_goal" numeric NOT NULL,
|
|
"margin" numeric,
|
|
"base_year" numeric,
|
|
"note" varchar,
|
|
"updated_at" timestamp(3) with time zone,
|
|
"created_at" timestamp(3) with time zone
|
|
);
|
|
`)
|
|
}
|
|
|
|
export async function down({ db }: MigrateDownArgs): Promise<void> {
|
|
await db.execute(sql`
|
|
DROP TABLE "campaign_goals" CASCADE;
|
|
`)
|
|
}
|