mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-22 13:23:07 +00:00
- pnpm db:seed:projecao now also imports SITUAÇÃO -> politicalTrend, DOBRADINHAS -> stateDeputy + stateDeputies + dobradinhaNotes, LIDERANÇAS -> name-only contact + leadership (statewide slug dedupe), ASSESSOR RESPONSÁVEL -> campaignUser + advisors (Edizio=coordinator, Solla=candidate, placeholder @planilha.invalid emails), ENCAMINHAMENTOS -> nextSteps, OBSERVAÇÃO -> strengths/risks (curated). PRIORITÁRIAS overrides MAPA GERAL when non-empty; Salvador stays skipped; relationships are unions; re-run is idempotent. - parseSituationCell + splitNameCell (noise/collective/action filters, honorific protection, parenthetical extraction) with unit tests. - Contact.phone optional (migration 20260724_175500_contact_phone_optional); phone invariant hooks skip phone-less contacts; invite flows guard. - candidate role now eligible for municipality/action-plan advisors (eligibleCampaignStaffWhere) per product decision.
20 lines
812 B
TypeScript
20 lines
812 B
TypeScript
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
|
|
|
/**
|
|
* Makes contact.phone nullable so name-only records can exist (e.g. leaderships
|
|
* imported from the projection sheet, E4R fase 2). UI flows keep requiring the
|
|
* phone via their zod schemas; only the collection/database constraint relaxes.
|
|
* Idempotent: DROP NOT NULL is a no-op when the column is already nullable.
|
|
*/
|
|
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
|
await db.execute(sql`
|
|
ALTER TABLE "contact" ALTER COLUMN "phone" DROP NOT NULL;
|
|
`)
|
|
}
|
|
|
|
export async function down({ db }: MigrateDownArgs): Promise<void> {
|
|
// Restoring NOT NULL fails if phone-less rows exist — remove them first by hand.
|
|
await db.execute(sql`
|
|
ALTER TABLE "contact" ALTER COLUMN "phone" SET NOT NULL;
|
|
`)
|
|
}
|