feat(schema): SchemaDiffer + cli/schemaDiff.php + composer schema:diff (#419, ADR-0009 impl)#422
Merged
Merged
Conversation
#419, ADR-0009 impl) ADR-0009 (#416) で Option C 採用、FT17 (#417) で実装した schema-diff CLI を framework に port。商用 feasibility report (#401) の "最大の実務 懸念" (migration 機構の欠如) に対する operator-applied resolution。 ### Code - class/xion/SchemaDiffer.php 新規 (pure-static、DB-agnostic) - diff(\$live, \$definition, \$driver): array{newTables, newColumns, warnings, inSync} - cli/schemaDiff.php 新規 (PDO + stdout/stderr 分離 CLI) - introspectMysql / introspectSqlite で driver 自動検出 - stdout = applied SQL only、stderr = annotation + warning - --dsn / --user / --pass / --help - class/xion/SchemaCompiler.php - 4 helper を private → public (mysqlCreateTable / sqliteCreateTable / mysqlColumn / sqliteColumn) - composer.json に "schema:diff" alias ### Tests tests/Unit/Xion/SchemaDifferTest.php 10 cases: - in-sync / new-table (MySQL+SQLite) / new-column (MySQL+SQLite) / bool default propagation / extra-column warning / extra-table warning / multi-warnings accumulate / inSync flag ### ADR cross-link docs/adr/0009-schema-migration-story.md の "Implementation tracking" section を更新: 本 PR # と F-5 follow-up issue 番号を明記。 ### Out of scope (per ADR-0009) - Drop / type-change / rename / constraint-change → warning のみ、SQL emit しない (operator hand-write) - Auto-apply (operator が常に実行する flow を維持) - Add-index path (本 PR に含めない、別 follow-up #421 で) ### Verification - composer test 138/138 (128 → 138、+10) - composer test:http 24/24 (1 expected skip) - composer analyze (Phan) exit 0 - composer format:check exit 0 - composer schema:diff -- --dsn=mysql:host=... で in-sync 確認、column drop → ALTER TABLE 出力、table drop → CREATE TABLE 出力 を live verify Closes #419. 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.
ADR-0009 (#416) で採用した Option C を実装。FT17 (#417 / PR #418) で trial 検証済み、本 PR で framework に port。
Code
Tests
`tests/Unit/Xion/SchemaDifferTest.php` 10 cases (in-sync / new-table / new-column / bool default / extra-column warning / extra-table warning / multi-warnings / inSync flag)。
Out of scope
ADR-0009 cross-link
`docs/adr/0009-schema-migration-story.md` の "Implementation tracking" section に本 PR + F-5 follow-up を明記。
Test plan
Closes #419.