Repository navigation
feat(migrate): Alembic and goose output for planned migrations; fix Python quoting (#148) - #163
Merged
Merged
Conversation
…ython quoting (#148) apso migrate and apso migrate generate now write the planned migration in the service's own wrapper: a TypeORM class (TypeScript), an Alembic revision in alembic/versions/ (Python, down_revision chained to the current head), or a goose SQL file in migrations/ (Go, YYYYMMDDHHMMSS_<name>.sql so it sorts with goose's own files). The plan JSON is saved beside it as before, and latestPlannedMigration finds it in each language's folder. Verify for Python and Go runs without TypeORM: Apso's DDL writer builds the deployed schema in PGlite, the seed loads, the migration's SQL runs as written, the data-loss and --check steps run as for TypeScript, and drift is a catalogDiff against a fresh build of the new .apsorc. down then runs and must give back the deployed schema. TypeScript verify is unchanged. migrateUnsupported is gone; --typeorm still needs a TypeScript service. literal) instead of """...""", which broke on SQL ending in a quoted identifier. The old sandbox generators get the same fix, and goose output fences any statement with its own ";" in StatementBegin/End. Tests: Alembic and goose snapshots for all 8 plan fixtures, py_compile of each Alembic file, and verify passing for python and go on rename-field, split-field and extract-entity with their seed and checks.
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.
Into
feat/migration-plan, not main. Fixes #148.What changes
apso migrateandapso migrate generatenow write the planned migration in the service's own format. TypeScript gets a TypeORM class (as before). Python gets an Alembic revision inalembic/versions/, withdown_revisionchained to the current head. Go gets a goose SQL file inmigrations/. The plan JSON is still saved beside it.latestPlannedMigrationandmigrationsDirknow each language's folder and file extension.YYYYMMDDHHMMSS_<snake_name>, the same as goose's own files, so goose sorts them in the right order.--checksteps run as they do for TypeScript.catalogDiffagainst a fresh PGlite build of the new.apsorc.migrateUnsupportedis removed.--typeormstill requires a TypeScript service."""...""". This applies to the new Alembic writer and to the oldPythonGenerator.generateMigration. On the Go side, goose output wraps any statement that contains its own;inStatementBegin/StatementEnd. The old Go generator gets the same wrapping.Tests
test/lib/ddl/wrappers.test.ts:python3 -m py_compileon every Alembic file. Ifpython3is missing, the test falls back to checking that each SQL literal round-trips.--accept-loss contact.fullName.answersmap andansweredPlanhelper move fromchange.test.tstotest/lib/ddl/answers.tsso both test files can use them.npm run lint: 0 errors.writePlannedMigrationload in real Alembic 1.16.4.alembic historyshows the chain, andalembic upgrade head --sqlprints the expected SQL.Not verified
PythonGenerator.generateMigration(migrate sandbox) still writesdown_revision = None, so a second sandbox migration creates a second Alembic head. I did not change this.