wip(projects): bump migrations 110→111, 111→112 (euler claimed 110)

This commit is contained in:
mAi
2026-05-20 14:47:52 +02:00
parent e6353d907c
commit 37cdf23c32
9 changed files with 18 additions and 17 deletions

View File

@@ -144,10 +144,10 @@ Existing `'court'`/`'both'` switch arms get deleted (no live rows; if a
stale `our_side='court'` slipped through somehow, the function returns
`""` — same fallback as today for unknown values).
### §2.3 Migration `110_client_role_rework`
### §2.3 Migration `111_client_role_rework`
```sql
-- 110_client_role_rework.up.sql
-- 111_client_role_rework.up.sql (renumbered 2026-05-20 — mig 110 was claimed by m/paliad#51 project_type_other)
-- t-paliad-222 / m/paliad#47.
-- Widens projects.our_side CHECK to seven sub-role values and drops
-- the legacy 'court' / 'both' entries. Backfill is a no-op on the
@@ -442,10 +442,10 @@ projects), introduce a materialised view
`paliad.projects_derived_codes(project_id, derived_code)` refreshed by
trigger on `projects` writes. Don't pre-optimise.
### §3.3 Migration `111_projects_opponent_code`
### §3.3 Migration `112_projects_opponent_code`
```sql
-- 111_projects_opponent_code.up.sql
-- 112_projects_opponent_code.up.sql (renumbered 2026-05-20)
-- t-paliad-222 / m/paliad#50.
-- Add an opponent-code field on litigation projects. Used as the
-- middle segment when assembling auto-derived project codes from the
@@ -643,7 +643,8 @@ material pushes back. Coder shift only after head signs off.)
## §5 Implementation order (coder phase)
1. **Mig 110** (client role widen + backfill) → mig 111 (opponent_code).
1. **Mig 111** (client role widen + backfill) → mig 112 (opponent_code).
*Renumbered 2026-05-20 — mig 110 was claimed by m/paliad#51 project_type_other; boltzmann's gap-tolerant runner hard-fails on collisions so this is a strict rebump.*
Run `ls internal/db/migrations/ | tail` first to verify slot
availability (boltzmann's gap-tolerant runner means 110 is fine
even if 109 was the last applied).

View File

@@ -1,4 +1,4 @@
-- Down migration for 110_client_role_rework.
-- Down migration for 111_client_role_rework.
--
-- Restores the original 4-value CHECK ('claimant','defendant',
-- 'court','both', NULL) and backfills any rows that landed on a new

View File

@@ -1,4 +1,4 @@
-- t-paliad-222 / m/paliad#47 — Client Role rework.
-- mig 111 — t-paliad-222 / m/paliad#47 — Client Role rework.
--
-- Widens paliad.projects.our_side CHECK to seven sub-role values and
-- drops the legacy 'court' / 'both' entries. The DB column name stays

View File

@@ -1,4 +1,4 @@
-- Down migration for 111_projects_opponent_code.
-- Down migration for 112_projects_opponent_code.
BEGIN;

View File

@@ -1,4 +1,4 @@
-- t-paliad-222 / m/paliad#50 — auto-derived project codes.
-- mig 112 — t-paliad-222 / m/paliad#50 — auto-derived project codes.
--
-- Adds an opponent-code slug field on litigation projects. Used as
-- the middle segment when BuildProjectCode assembles an auto-derived

View File

@@ -161,7 +161,7 @@ type Project struct {
// chip from the project context (t-paliad-164). NULL = unknown /
// not set; Determinator falls back to free-pick.
//
// Allowed sub-roles (mig 110, t-paliad-222):
// Allowed sub-roles (mig 111, t-paliad-222):
// Active : claimant, applicant, appellant
// Reactive : defendant, respondent
// Other : third_party, other
@@ -177,7 +177,7 @@ type Project struct {
// assembles an auto-derived project code from the ancestor tree —
// e.g. EXMPL.OPNT.567.INF.CFI (t-paliad-222 / m/paliad#50). NULL
// → segment skipped silently. Only meaningful on type='litigation'
// rows; CHECK constraint (mig 111) enforces the pairing.
// rows; CHECK constraint (mig 112) enforces the pairing.
OpponentCode *string `db:"opponent_code" json:"opponent_code,omitempty"`
// Code is the auto-derived (or override) project code, computed at

View File

@@ -351,7 +351,7 @@ func TestValidateOpponentCode(t *testing.T) {
}
}
// TestValidateOurSideSubRoles pins the widened allowlist (mig 110).
// TestValidateOurSideSubRoles pins the widened allowlist (mig 111).
func TestValidateOurSideSubRoles(t *testing.T) {
valid := []string{
"", "claimant", "defendant", "applicant", "appellant",

View File

@@ -1431,7 +1431,7 @@ func insertCounterclaimEvent(ctx context.Context, tx *sqlx.Tx, projectID, userID
// Third Party / Other (third_party, other) and NULL pass through
// unchanged — the flip is meaningless without a clear active / reactive
// posture. Legacy 'court' / 'both' no longer exist in the column
// (mig 110) so they have no case arm; if a stale value sneaks in via a
// (mig 111) so they have no case arm; if a stale value sneaks in via a
// pre-migration in-memory row it falls through to the default branch
// and passes through unchanged, preserving previous behaviour.
//
@@ -1973,7 +1973,7 @@ func validateProjectStatus(s string) error {
// (t-paliad-164, widened in t-paliad-222 / m/paliad#47). Empty string
// is the explicit "clear" sentinel — callers pass the value as-is
// from the form payload, and the helper accepts it so an Update can
// null the column. The DB-level CHECK constraint (mig 110) enforces
// null the column. The DB-level CHECK constraint (mig 111) enforces
// the same set; this validation gives a clearer error than relying
// on the constraint to fire.
//
@@ -1982,7 +1982,7 @@ func validateProjectStatus(s string) error {
// Reactive (we defend) : defendant, respondent
// Third Party / Other : third_party, other
//
// Legacy 'court' / 'both' are no longer accepted (mig 110 backfills
// Legacy 'court' / 'both' are no longer accepted (mig 111 backfills
// existing rows to NULL); callers that still send them get a clear
// validation error rather than a constraint violation.
func validateOurSide(s string) error {
@@ -2043,7 +2043,7 @@ func nullableOurSide(p *string) any {
}
// opponentCodePattern matches the slug shape enforced by the
// projects_opponent_code_check constraint (mig 111): uppercase letters,
// projects_opponent_code_check constraint (mig 112): uppercase letters,
// digits, dashes, 1-16 chars. The DB CHECK is the source of truth; this
// helper surfaces a friendlier ErrInvalidInput error before the write.
var opponentCodePattern = regexp.MustCompile(`^[A-Z0-9-]{1,16}$`)

View File

@@ -276,7 +276,7 @@ func TestLegalSourcePretty(t *testing.T) {
// mapping used by addProjectVars. Post t-paliad-222: seven sub-role
// values + the gender-neutral "-Seite" / "-Partei" suffix shape on
// DE. Legacy 'court' / 'both' yield "" (the column no longer accepts
// them after mig 110, but the function defensively handles stale
// them after mig 111, but the function defensively handles stale
// in-memory values from older callers).
func TestOurSideTranslations(t *testing.T) {
cases := []struct {