mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-05 05:57:43 +01:00
fix(deploy): one migration order for all three runners, and stop the prod fail-open (#359)
Migrations were enumerated three different ways. run-migration.sh sorted -V with no skip list, apply-migrations-ci.sh sorted -V WITH one, and the production deploy used a bare glob — lexicographic, which orders the 005* duplicates the opposite way. So the order production would use in a disaster-recovery rebuild was the one order CI never replayed, and a from-scratch local DB died on a duplicate CI had been skipping for months. scripts/db/migration-order.sh is now the only enumeration. The deploy also read schema_migrations with '|| true'. An empty answer does not mean 'nothing applied', it means 'could not look' — and the loop treats every unlisted file as pending, so one ssh blip would have re-applied ~150 migrations to the live database. It now fails closed. Also: - deploy-selfhost.yml re-inlined four checks instead of calling verify, making the DEPLOY gate weaker than the MERGE gate (no card-shell ratchet, i18n subset instead of the full suite). Calls verify verbatim. - .gitignore had a blanket *.sh + hand-kept negations, so every new script under scripts/ was invisible to git — it commits clean, then CI fails on a file that exists on one laptop. Anchored to the repo root. - 5 dev-only packages sat in dependencies, where dependency-audit.sh (npm audit --omit=dev) reports an ESLint advisory as a runtime critical. Moved to devDependencies. - dependabot: groups for the next / next-auth / tailwind / eslint / jest lockstep families, and @types/node major pinned to the runtime major (Node 20) — PR #356 was closed for exactly that. - Untracked 2.7 MB of committed Jest output and a .bak dropping. Verified: from-zero CI replay green (133 applied), local runner green from a fresh DB (149 applied — it could not complete at all before), lint 0 errors, typecheck clean, 7798 tests. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
114fff2622
commit
1f03185863
11 files changed
+190
-61
No files matched your search
@@ -21,6 +21,42 @@ updates:
|
||||
- "react-dom"
|
||||
- "@types/react"
|
||||
- "@types/react-dom"
|
||||
# eslint-config-next is version-locked to next; a half-bump breaks lint.
|
||||
next:
|
||||
patterns:
|
||||
- "next"
|
||||
- "eslint-config-next"
|
||||
# @auth/pg-adapter peer-depends on next-auth — the pair that produced the
|
||||
# 2026-08 advisories must move together or neither installs.
|
||||
next-auth:
|
||||
patterns:
|
||||
- "next-auth"
|
||||
- "@auth/*"
|
||||
# Tailwind v4 splits the engine from the PostCSS plugin; they share a
|
||||
# version and a config format.
|
||||
tailwind:
|
||||
patterns:
|
||||
- "tailwindcss"
|
||||
- "@tailwindcss/*"
|
||||
- "postcss"
|
||||
eslint:
|
||||
patterns:
|
||||
- "eslint"
|
||||
- "@eslint/*"
|
||||
- "eslint-plugin-*"
|
||||
jest:
|
||||
patterns:
|
||||
- "jest"
|
||||
- "jest-environment-*"
|
||||
- "@types/jest"
|
||||
- "@testing-library/*"
|
||||
ignore:
|
||||
# @types/node must track the RUNTIME major, not the newest release. CI
|
||||
# (ci.yml NODE_VERSION) and the self-host deploy both pin Node 20, so a
|
||||
# major bump types APIs production does not have — it also fails `verify`.
|
||||
# Raise this deliberately when the runtime moves. (PR #356 closed for this.)
|
||||
- dependency-name: "@types/node"
|
||||
update-types: ["version-update:semver-major"]
|
||||
commit-message:
|
||||
prefix: "deps"
|
||||
labels:
|
||||
|
||||
@@ -67,21 +67,27 @@ jobs:
|
||||
restore-keys: |
|
||||
nextjs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-
|
||||
|
||||
- name: Run ESLint
|
||||
# ONE definition of "verified" — the same bundle ci.yml runs, called
|
||||
# verbatim. These four steps used to be re-inlined here, which quietly made
|
||||
# the DEPLOY gate weaker than the MERGE gate: it omitted `lint:chrome`
|
||||
# (the card-shell ratchet) and ran only the i18n subset instead of the
|
||||
# full unit suite. A regression those cover could not block a merge but
|
||||
# could still ship. `verify` = lint + umlauts + chrome + typecheck + test
|
||||
# + build, and it already includes the i18n structure gate via `test`.
|
||||
- name: Verify (lint + umlauts + chrome + typecheck + test + build)
|
||||
if: steps.secrets.outputs.configured == 'true'
|
||||
run: npm run lint
|
||||
|
||||
- name: Check umlauts
|
||||
if: steps.secrets.outputs.configured == 'true'
|
||||
run: npm run lint:umlauts
|
||||
|
||||
- name: Type check
|
||||
if: steps.secrets.outputs.configured == 'true'
|
||||
run: npm run typecheck
|
||||
|
||||
- name: i18n structure gate
|
||||
if: steps.secrets.outputs.configured == 'true'
|
||||
run: npm run test:i18n
|
||||
run: npm run verify
|
||||
env:
|
||||
# Same build-time placeholders ci.yml uses: this step runs BEFORE
|
||||
# .env.selfhost.local is written, so strict env validation would
|
||||
# otherwise fail during compile. The deploy script rebuilds after
|
||||
# this with the real env and the release SHA; that second build is
|
||||
# warm (the .next/cache step above), so the gate costs little.
|
||||
AUTH_SECRET: ci-build-placeholder-secret-32chars
|
||||
DB_HOST: localhost
|
||||
DB_NAME: revampit_ci
|
||||
DB_USER: ci
|
||||
DB_PASSWORD: ci
|
||||
|
||||
- name: Write selfhost env
|
||||
if: steps.secrets.outputs.configured == 'true'
|
||||
|
||||
+10
-9
@@ -44,6 +44,8 @@ next-env.d.ts
|
||||
|
||||
# test results and reports
|
||||
test-results/
|
||||
test-results.json
|
||||
*.bak
|
||||
playwright-report/
|
||||
tests/e2e/.auth/
|
||||
coverage/
|
||||
@@ -108,15 +110,14 @@ tina/__generated__
|
||||
|
||||
# Uploaded files (development)
|
||||
public/uploads/
|
||||
*.sh
|
||||
# CI scripts are part of the build contract — workflows call them by path, so a
|
||||
# missing one breaks CI rather than merely being absent. Negate the whole
|
||||
# directory instead of listing them one by one; the per-file negations below
|
||||
# predate this and are kept because those scripts live outside scripts/ci/.
|
||||
!scripts/ci/*.sh
|
||||
!scripts/selfhost-deploy-revampit.sh
|
||||
!scripts/e2e-inventory-prod.sh
|
||||
!scripts/db/apply-migrations-ci.sh
|
||||
# Ad-hoc one-off scripts get dropped at the repo ROOT while debugging — keep
|
||||
# those out, but ONLY those. This used to be a blanket `*.sh` plus a hand-kept
|
||||
# list of negations, which meant every new script under scripts/ was silently
|
||||
# invisible to git: it committed clean, then CI or the deploy failed on a file
|
||||
# that only ever existed on one laptop. Everything under scripts/ is part of the
|
||||
# build/deploy contract (workflows and other scripts source it by path), so the
|
||||
# default there is tracked.
|
||||
/*.sh
|
||||
ship
|
||||
cookies.txt
|
||||
daten/
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
strapi:
|
||||
command: ["npx", "strapi", "develop"]
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
volumes:
|
||||
- ./strapi:/opt/app
|
||||
- /opt/app/node_modules
|
||||
- ./strapi/uploads:/opt/app/public/uploads
|
||||
Generated
+20
-5
@@ -11,8 +11,6 @@
|
||||
"dependencies": {
|
||||
"@auth/pg-adapter": "^1.11.3",
|
||||
"@aws-sdk/client-s3": "^3.1115.0",
|
||||
"@eslint/eslintrc": "^3.3.6",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@fleet/ai-forms": "github:maonakamoto/ai-forms#v0.1.0",
|
||||
"@sentry/nextjs": "^10.70.0",
|
||||
"@tiptap/extension-link": "^3.30.2",
|
||||
@@ -20,9 +18,6 @@
|
||||
"@tiptap/pm": "^3.30.2",
|
||||
"@tiptap/react": "^3.30.2",
|
||||
"@tiptap/starter-kit": "^3.30.2",
|
||||
"@types/busboy": "^1.5.4",
|
||||
"@types/jsonwebtoken": "^9.0.5",
|
||||
"@types/nodemailer": "^7.0.1",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"busboy": "^1.6.0",
|
||||
"clsx": "^2.1.1",
|
||||
@@ -62,6 +57,8 @@
|
||||
"zod": "^4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.3.6",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@playwright/test": "^1.62.1",
|
||||
"@swc/helpers": "0.5.23",
|
||||
"@tailwindcss/postcss": "^4.3.3",
|
||||
@@ -69,9 +66,12 @@
|
||||
"@testing-library/react": "^16.3.0",
|
||||
"@testing-library/user-event": "^14.6.5",
|
||||
"@types/bcryptjs": "^2.4.6",
|
||||
"@types/busboy": "^1.5.4",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/jsonwebtoken": "^9.0.5",
|
||||
"@types/leaflet": "^1.9.21",
|
||||
"@types/node": "^20.11.24",
|
||||
"@types/nodemailer": "^7.0.1",
|
||||
"@types/pg": "^8.23.1",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/react": "^19.2.18",
|
||||
@@ -1733,6 +1733,7 @@
|
||||
"version": "3.3.6",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.6.tgz",
|
||||
"integrity": "sha512-l2Ul9PrHsPCKcEY/ac7VgFj9D80C7S68sOKc618SyHDPK36s1XcFebXY0iTzUVn4Yq+YbwvSnDmCz9yxjX+QrA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ajv": "^6.14.0",
|
||||
@@ -1756,6 +1757,7 @@
|
||||
"version": "9.39.4",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.4.tgz",
|
||||
"integrity": "sha512-nE7DEIchvtiFTwBw4Lfbu59PG+kCofhjsKaCWzxTpt4lfRjRMqG6uMBzKXuEcyXhOHoUp9riAm7/aWYGhXZ9cw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -6263,6 +6265,7 @@
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/busboy/-/busboy-1.5.4.tgz",
|
||||
"integrity": "sha512-kG7WrUuAKK0NoyxfQHsVE6j1m01s6kMma64E+OZenQABMQyTJop1DumUWcLwAQ2JzpefU7PDYoRDKl8uZosFjw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
@@ -6474,6 +6477,7 @@
|
||||
"version": "9.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.10.tgz",
|
||||
"integrity": "sha512-asx5hIG9Qmf/1oStypjanR7iKTv0gXQ1Ov/jfrX6kS/EO0OFni8orbmGCn0672NHR3kXHwpAwR+B368ZGN/2rA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/ms": "*",
|
||||
@@ -6540,6 +6544,7 @@
|
||||
"version": "7.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-7.0.11.tgz",
|
||||
"integrity": "sha512-E+U4RzR2dKrx+u3N4DlsmLaDC6mMZOM/TPROxA0UAPiTgI0y4CEFBmZE+coGWTjakDriRsXG368lNk1u9Q0a2g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
@@ -7407,6 +7412,7 @@
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
||||
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
@@ -8281,6 +8287,7 @@
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
|
||||
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
@@ -10202,6 +10209,7 @@
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
|
||||
"integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -10245,6 +10253,7 @@
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz",
|
||||
"integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"acorn": "^8.15.0",
|
||||
@@ -10920,6 +10929,7 @@
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
|
||||
"integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
@@ -11314,6 +11324,7 @@
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
||||
"integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
@@ -11339,6 +11350,7 @@
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
|
||||
"integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"parent-module": "^1.0.0",
|
||||
@@ -16088,6 +16100,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
||||
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"callsites": "^3.0.0"
|
||||
@@ -17519,6 +17532,7 @@
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
|
||||
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
@@ -18594,6 +18608,7 @@
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
||||
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
|
||||
+5
-5
@@ -92,8 +92,6 @@
|
||||
"dependencies": {
|
||||
"@auth/pg-adapter": "^1.11.3",
|
||||
"@aws-sdk/client-s3": "^3.1115.0",
|
||||
"@eslint/eslintrc": "^3.3.6",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@fleet/ai-forms": "github:maonakamoto/ai-forms#v0.1.0",
|
||||
"@sentry/nextjs": "^10.70.0",
|
||||
"@tiptap/extension-link": "^3.30.2",
|
||||
@@ -101,9 +99,6 @@
|
||||
"@tiptap/pm": "^3.30.2",
|
||||
"@tiptap/react": "^3.30.2",
|
||||
"@tiptap/starter-kit": "^3.30.2",
|
||||
"@types/busboy": "^1.5.4",
|
||||
"@types/jsonwebtoken": "^9.0.5",
|
||||
"@types/nodemailer": "^7.0.1",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"busboy": "^1.6.0",
|
||||
"clsx": "^2.1.1",
|
||||
@@ -146,6 +141,8 @@
|
||||
"*.{ts,tsx,js,jsx}": "eslint --fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.3.6",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@playwright/test": "^1.62.1",
|
||||
"@swc/helpers": "0.5.23",
|
||||
"@tailwindcss/postcss": "^4.3.3",
|
||||
@@ -153,9 +150,12 @@
|
||||
"@testing-library/react": "^16.3.0",
|
||||
"@testing-library/user-event": "^14.6.5",
|
||||
"@types/bcryptjs": "^2.4.6",
|
||||
"@types/busboy": "^1.5.4",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/jsonwebtoken": "^9.0.5",
|
||||
"@types/leaflet": "^1.9.21",
|
||||
"@types/node": "^20.11.24",
|
||||
"@types/nodemailer": "^7.0.1",
|
||||
"@types/pg": "^8.23.1",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/react": "^19.2.18",
|
||||
|
||||
@@ -25,20 +25,12 @@ else
|
||||
fi
|
||||
|
||||
count=0
|
||||
# 005_messaging_system.sql duplicates 005c_messaging_system.sql (same triggers/tables).
|
||||
# Fresh CI DB applies 005c first (sort -V); re-running 005_messaging fails on triggers.
|
||||
SKIP_FILES=("005_messaging_system.sql")
|
||||
# Ordering + the superseded-duplicate list are shared with the local runner and
|
||||
# the production deploy — see scripts/db/migration-order.sh.
|
||||
# shellcheck source=scripts/db/migration-order.sh
|
||||
source "$ROOT/scripts/db/migration-order.sh"
|
||||
|
||||
for f in $(ls scripts/db/migrations/*.sql | sort -V); do
|
||||
base=$(basename "$f")
|
||||
skip=0
|
||||
for s in "${SKIP_FILES[@]}"; do
|
||||
if [ "$base" = "$s" ]; then skip=1; break; fi
|
||||
done
|
||||
if [ "$skip" -eq 1 ]; then
|
||||
echo "↷ skip $(basename "$f") (superseded duplicate)"
|
||||
continue
|
||||
fi
|
||||
for f in $(migration_files); do
|
||||
count=$((count + 1))
|
||||
echo "→ $(basename "$f")"
|
||||
psql -v ON_ERROR_STOP=1 -1 -f "$f" >/dev/null
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
# SSOT for WHICH migrations run and in WHAT ORDER.
|
||||
#
|
||||
# Three runners apply migrations — the local runner (run-migration.sh), the CI
|
||||
# from-zero replay (apply-migrations-ci.sh) and the production deploy
|
||||
# (selfhost-deploy-revampit.sh). They used to each decide ordering for
|
||||
# themselves, and they disagreed:
|
||||
#
|
||||
# run-migration.sh sort -V, no skip list → failed on a fresh DB
|
||||
# apply-migrations-ci.sh sort -V + skip list → green
|
||||
# selfhost-deploy bare glob (lexicographic!) → a THIRD order
|
||||
#
|
||||
# A bare glob sorts `005_messaging` before `005b`/`005c`; `sort -V` does the
|
||||
# reverse. So CI's from-zero replay never exercised the order production would
|
||||
# actually use — the one path that matters during a disaster-recovery rebuild.
|
||||
# Sourcing this file is now the only way to enumerate migrations.
|
||||
#
|
||||
# Usage:
|
||||
# source scripts/db/migration-order.sh
|
||||
# for f in $(migration_files); do ... done # full paths, ordered
|
||||
#
|
||||
# Executed directly, it prints the ordered list (handy for diffing).
|
||||
|
||||
# Byte-identical duplicates of a later file (verified with md5sum). They stay on
|
||||
# disk because applied migrations are protected — production has them recorded
|
||||
# in schema_migrations, and deleting a recorded migration breaks replay. They
|
||||
# are simply never re-applied: their objects are created by the surviving copy.
|
||||
# 004_ai_inventory_system.sql == 004b_ai_inventory_system.sql
|
||||
# 005_messaging_system.sql == 005c_messaging_system.sql
|
||||
# Only 005 needs skipping: its three CREATE TRIGGER statements are unguarded, so
|
||||
# a second application aborts. 004's lone trigger is IF NOT EXISTS-guarded and
|
||||
# is harmless either way — left in the list so this change alters no behavior
|
||||
# CI has already verified.
|
||||
MIGRATION_SUPERSEDED=("005_messaging_system.sql")
|
||||
|
||||
# Repo root, resolved from this file so callers can run from anywhere.
|
||||
MIGRATION_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
MIGRATION_DIR="$MIGRATION_ROOT/scripts/db/migrations"
|
||||
|
||||
# Prints full paths, version-sorted, superseded duplicates removed.
|
||||
migration_files() {
|
||||
local path base skipped
|
||||
for path in $(ls "$MIGRATION_DIR"/*.sql | sort -V); do
|
||||
base="$(basename "$path")"
|
||||
skipped=0
|
||||
for s in "${MIGRATION_SUPERSEDED[@]}"; do
|
||||
[ "$base" = "$s" ] && { skipped=1; break; }
|
||||
done
|
||||
[ "$skipped" -eq 1 ] && continue
|
||||
printf '%s\n' "$path"
|
||||
done
|
||||
}
|
||||
|
||||
# True when the given basename is a superseded duplicate (for callers that want
|
||||
# to log the skip rather than silently drop it).
|
||||
migration_is_superseded() {
|
||||
local s
|
||||
for s in "${MIGRATION_SUPERSEDED[@]}"; do
|
||||
[ "$1" = "$s" ] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Direct execution → print the list.
|
||||
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
|
||||
migration_files
|
||||
fi
|
||||
@@ -91,7 +91,14 @@ echo -e "${YELLOW}Running migrations (version-sorted, skipping already-applied).
|
||||
COUNT_APPLIED=0
|
||||
COUNT_SKIPPED=0
|
||||
|
||||
for path in $(ls "$MIGRATIONS_DIR"/*.sql | sort -V); do
|
||||
# Ordering + the superseded-duplicate list are shared with the CI replay and the
|
||||
# production deploy — see scripts/db/migration-order.sh. Before that file, this
|
||||
# runner had no skip list, so a from-scratch local DB died on the duplicate
|
||||
# 005_messaging_system.sql that CI had been skipping for months.
|
||||
# shellcheck source=scripts/db/migration-order.sh
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/migration-order.sh"
|
||||
|
||||
for path in $(migration_files); do
|
||||
name=$(basename "$path")
|
||||
if is_applied "$name"; then
|
||||
COUNT_SKIPPED=$((COUNT_SKIPPED + 1))
|
||||
|
||||
@@ -49,8 +49,25 @@ echo "=== ensure ffmpeg on box (chunked audio transcription) ==="
|
||||
ssh -o BatchMode=yes "$BOX" 'command -v ffmpeg >/dev/null 2>&1 || { sudo DEBIAN_FRONTEND=noninteractive apt-get -qq update && sudo DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends ffmpeg; }'
|
||||
|
||||
echo "=== apply pending migrations → prod DB ==="
|
||||
applied_list="$(printf '' | prod_psql "-tAc 'SELECT filename FROM schema_migrations'" 2>/dev/null || true)"
|
||||
for mig in "$SRC"/scripts/db/migrations/*.sql; do
|
||||
# Fail CLOSED when the applied-migrations state cannot be read. With `|| true`
|
||||
# a transient ssh/psql failure produced an EMPTY list, which does not mean
|
||||
# "nothing is applied" — it means "we could not look". The loop below treats
|
||||
# every unlisted file as pending, so an unreadable state would have re-applied
|
||||
# all ~150 migrations against the live production database.
|
||||
if ! applied_list="$(printf '' | prod_psql "-tAc 'SELECT filename FROM schema_migrations'")"; then
|
||||
echo "ERROR: could not read schema_migrations on prod — refusing to guess which"
|
||||
echo " migrations are pending (an empty answer would re-apply all of them)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Same order and same superseded-duplicate list as the CI replay and the local
|
||||
# runner. This path used a bare glob (lexicographic), which orders the 005*
|
||||
# duplicates the OPPOSITE way from `sort -V` — so the order production would use
|
||||
# during a disaster-recovery rebuild was the one order CI never exercised.
|
||||
# shellcheck source=scripts/db/migration-order.sh
|
||||
source "$SRC/scripts/db/migration-order.sh"
|
||||
|
||||
for mig in $(migration_files); do
|
||||
fname="$(basename "$mig")"
|
||||
printf '%s\n' "$applied_list" | grep -qxF "$fname" && continue
|
||||
echo " → applying $fname"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":500,"numPassedTests":7386,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":500,"numTotalTests":7386,"openHandles":[],"snapshot":{"added":0,"didUpdate":false,"failure":false,"filesAdded":0,"filesRemoved":0,"filesRemovedList":[],"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0},"startTime":1778681742734,"success":true,"testResults":[{"assertionResults":[{"ancestorTitles":["ProtocolDetailClient"],"duration":371,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"ProtocolDetailClient uses notes reprocess endpoint and body (content) in review mode","invocations":1,"location":null,"numPassingAsserts":2,"retryReasons":[],"startAt":1778681746696,"status":"passed","title":"uses notes reprocess endpoint and body (content) in review mode"},{"ancestorTitles":["ProtocolDetailClient"],"duration":148,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"ProtocolDetailClient creates all unlinked task action items in bulk","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747072,"status":"passed","title":"creates all unlinked task action items in bulk"},{"ancestorTitles":["ProtocolDetailClient"],"duration":40,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"ProtocolDetailClient shows workflow stepper with next-step guidance","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747221,"status":"passed","title":"shows workflow stepper with next-step guidance"},{"ancestorTitles":["ProtocolDetailClient"],"duration":40,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"ProtocolDetailClient shows status badge in review mode","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747262,"status":"passed","title":"shows status badge in review mode"},{"ancestorTitles":["ProtocolDetailClient"],"duration":88,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"ProtocolDetailClient shows actionable empty state when no action items were extracted","invocations":1,"location":null,"numPassingAsserts":2,"retryReasons":[],"startAt":1778681747303,"status":"passed","title":"shows actionable empty state when no action items were extracted"}],"endTime":1778681747403,"message":"","name":"/home/g/dev/revampit/src/app/admin/protocols/[id]/__tests__/ProtocolDetailClient.test.tsx","startTime":1778681745350,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":["erfassungPayloadSchema"],"duration":5,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"erfassungPayloadSchema accepts a minimal valid payload","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747821,"status":"passed","title":"accepts a minimal valid payload"},{"ancestorTitles":["erfassungPayloadSchema"],"duration":2,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"erfassungPayloadSchema rejects empty hersteller","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747826,"status":"passed","title":"rejects empty hersteller"},{"ancestorTitles":["erfassungPayloadSchema"],"duration":1,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"erfassungPayloadSchema rejects missing hersteller","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747829,"status":"passed","title":"rejects missing hersteller"},{"ancestorTitles":["erfassungPayloadSchema"],"duration":1,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"erfassungPayloadSchema rejects empty produktname","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747831,"status":"passed","title":"rejects empty produktname"},{"ancestorTitles":["erfassungPayloadSchema"],"duration":1,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"erfassungPayloadSchema rejects negative verkaufspreis","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747833,"status":"passed","title":"rejects negative verkaufspreis"},{"ancestorTitles":["erfassungPayloadSchema"],"duration":1,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"erfassungPayloadSchema accepts verkaufspreis of 0 (free item)","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747834,"status":"passed","title":"accepts verkaufspreis of 0 (free item)"},{"ancestorTitles":["erfassungPayloadSchema"],"duration":1,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"erfassungPayloadSchema rejects empty zustand","invocations":1,"location":null,"numPassingAsserts":1,"retryReasons":[],"startAt":1778681747836,"status":"passed","title":"rejects empty zustand"},{"ancestLine truncated
|
||||
Reference in new issue
Block a user