Add make schema target loading 3 sample MySQL DBs#12
Merged
Conversation
`make schema` loads: - chinook (lerocha/chinook-database, MIT) — 11 tables, FKs, indexes - employees (datacharmer/test_db, CC BY-SA 3.0) — 6 tables + 2 views - sakila (dev.mysql.com, BSD-style) — 16 tables + 7 views Each loader fetches the upstream artefact (curl for chinook + sakila, git clone for employees), pipes the schema into the local mysql client, and cleans up. `make schema-drop` removes all three. Implementation notes: - The employees dump uses `source load_X.dump;` to bring in row-data, but mysql 8 rejects `source` outside interactive mode and we don't need the data for schema management anyway. `grep -v '^source '` strips those lines before piping. - Chinook and employees round-trip cleanly through dump → plan (no drift). - Sakila currently fails to round-trip because pingcap's parser does not recognise the GEOMETRY column type used by `address.location`. Tracked in TODO.md. AGENTS.md gets a docs section showing how to point myschema at each sample DB; TODO.md ticks off the Makefile schema-target item and adds the geometry-parser follow-up. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12 +/- ##
=======================================
Coverage 35.78% 35.78%
=======================================
Files 24 24
Lines 1520 1520
=======================================
Hits 544 544
Misses 864 864
Partials 112 112 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
winebarrel
added a commit
that referenced
this pull request
May 2, 2026
Three inline comments, all valid.
parser/directive.go
- anyDirectivePattern now allows optional whitespace between the
colon and the directive name. A formatting slip like
`-- myschema: renamed-from old` previously didn't even match the
pattern, so the directive was silently ignored. The per-directive
regex (renameDirectivePattern) stays strict, so such lines turn
into "malformed directive" errors at validation. (Copilot #1.)
diff/rename.go
- applyTableRenames / applyColumnRenames / applyIndexRenames each
pre-validate that no two desired entries declare the same
RenameFrom source via new duplicate*RenameSource helpers. Today
a stray duplicate produced a confusing "source ... not found"
error after the first rename mutated current; now it surfaces
a dedicated "source ... is referenced by multiple ..." error
before any mutation. (Copilot #2.)
AGENTS.md
- The "in scope" entry for renamed-from now correctly states that
`RENAME INDEX` is MySQL 5.7+, only `RENAME COLUMN` is 8.0+.
Project baseline is 8.0 (INVISIBLE indexes, CHECK constraints),
so the 8.0-only RENAME COLUMN sits inside that envelope. The
earlier "all 8.0+" wording was factually wrong. (Copilot #3.)
Tests
- parser/directive_test.go: TestValidateDirectivesRejectsSpaceAfterColon
covers the new validator behaviour for `-- myschema: name`.
- diff/rename_test.go: TestDiffRenameDuplicateSourceErrors covers
the duplicate-source guard for the column-rename path (table
and index paths share the same shape and helper).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
make schemaloads three permissively-licensed MySQL sample databases into separate databases on the local server, ready for ad-hocmyschema dump/planagainst realistic schemas.Targets:
make schema— load all threemake load-chinook/make load-employees/make load-sakila— load onemake schema-drop— remove all threeImplementation notes
source load_X.dump;lines are stripped withgrep -v '^source 'before piping. mysql 8 rejectssourceoutside interactive mode, and we don't need the data for schema management.dump→plan→-- No changes).geometrycolumn type onaddress.location. Tracked in TODO.md.Test plan
make schemaloads all three (Chinook 11 tables, employees 6 tables + 2 views, sakila 16 tables + 7 views)make schema-dropremoves themmyschema dumpagainst Chinook / employees / sakila worksmyschema planround-trip is clean for Chinook + employees🤖 Generated with Claude Code