perf(test): activate schema-dump fast path (WS-6)

mysql-client is now installed on the dev host (brew install
mysql-client + PATH=/opt/homebrew/opt/mysql-client/bin), which
unblocks the fast path that session 2.7 prepared but couldn't
activate.

Changes:
- api/database/schema/mysql-schema.sql committed (current state, 122 KB,
  1749 lines, all 155 migration records).
- api/database/schema/.gitignore removed: the dump is no longer opt-in,
  it's the default code path (active in dev + CI).
- Makefile schema-dump target simplified: drops the docker exec mysqldump
  workaround in favour of plain `php artisan schema:dump`. Now also runs
  migrate to head first so the dump always reflects the latest migration
  set without manual prep.
- CLAUDE.md "Schema dumps" rewritten: "opt-in fast path" → "CI fast
  path", reflects that the dump is committed by default and contributors
  regenerate via `make schema-dump` after adding migrations.

Backfill test wall-time, 4 classes combined:
- Session 2.7 baseline: 127.90s
- This session:          27.55s (78% reduction)

Per class (PHPUnit Duration):
- FormFieldBindingMigrationTest:        4.59s  (2 tests)
- ConditionalLogicBackfillTest:         5.45s  (4 tests)
- FormFieldOptionsBackfillTest:        12.25s  (9 tests)
- FormFieldValidationRuleBackfillTest: 10.75s  (6 tests)

Full suite knock-on: 209.95s → 89.16s (-57%) — every RefreshDatabase
test pays the up-front migrate cost, which `schema:dump` collapses
from ~6s × N to a single ~1s SQL load.

Refs: WS-6 session 2.7 deviation #3 cleanup, Q1 closure

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-28 15:12:43 +02:00
parent fe110ba761
commit 82259f8942
4 changed files with 1790 additions and 43 deletions

View File

@@ -83,22 +83,16 @@ test-db-create:
test: test-db-create
@cd api && php artisan test
# Regenerate api/database/schema/mysql-schema.sql from the current
# crewli_test schema. Runs mysqldump INSIDE the bm_mysql Docker
# container, so contributors don't need mysqldump on the host.
# Regenerate api/database/schema/mysql-schema.sql via Laravel's native
# `schema:dump` command. Brings crewli_test to head first so the dump
# always reflects the latest migration set. Requires mysql-client on
# host PATH (see CLAUDE.md "Schema dumps (CI fast path)").
#
# Workflow: this target dumps WHATEVER state crewli_test is currently
# in. Run `make test-db-create` (creates DB), then put it at the desired
# state — typically by running the test suite, which migrates the test
# DB to head — then `make schema-dump`.
#
# See CLAUDE.md "Schema dumps" — commit the regenerated dump alongside
# any new migrations so CI / fast-path migrate:fresh stays in sync.
schema-dump:
@echo "$(GREEN)Regenerating api/database/schema/mysql-schema.sql from current crewli_test state...$(NC)"
@docker exec bm_mysql mysqldump --no-tablespaces --skip-add-locks --skip-comments --skip-set-charset --tz-utc -u root -proot crewli_test --routines --no-data 2>/dev/null > /tmp/crewli-schema-structure.sql
@docker exec bm_mysql mysqldump --no-tablespaces --skip-add-locks --skip-comments --skip-set-charset --tz-utc -u root -proot crewli_test migrations --no-create-info 2>/dev/null > /tmp/crewli-schema-migrations.sql
@cat /tmp/crewli-schema-structure.sql /tmp/crewli-schema-migrations.sql > api/database/schema/mysql-schema.sql
@rm /tmp/crewli-schema-structure.sql /tmp/crewli-schema-migrations.sql
@echo "$(GREEN)✓ api/database/schema/mysql-schema.sql updated$(NC)"
# After adding a new migration: run `make schema-dump` and commit the
# regenerated dump alongside the migration.
schema-dump: test-db-create
@echo "$(GREEN)Migrating crewli_test to head...$(NC)"
@cd api && DB_DATABASE=crewli_test php artisan migrate --force --quiet
@echo "$(GREEN)Regenerating api/database/schema/mysql-schema.sql...$(NC)"
@cd api && DB_DATABASE=crewli_test php artisan schema:dump --database=mysql
@echo "$(YELLOW)Note: Commit the updated schema dump alongside any new migrations.$(NC)"