Pgpkgmigrations#437
Conversation
| with: | ||
| python-version: "3.x" | ||
| - name: Install build | ||
| working-directory: /home/runner/work/pgstac/pgstac/src/pgstac-migrate |
There was a problem hiding this comment.
Can we just make these relative paths so they don't encode specifics of how Github Actions work?
| working-directory: /home/runner/work/pgstac/pgstac/src/pgstac-migrate | |
| working-directory: src/pgstac-migrate |
| - name: Setup Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: "3.x" |
There was a problem hiding this comment.
This could/should be setup-uv per the copilot instructions
| uv run --extra dev ruff check src/pypgstac tests | ||
| uv run --extra dev ruff format --check src/pypgstac tests |
There was a problem hiding this comment.
Not for this PR, but we should prefer dependency groups over extras, as it keeps the packaging story cleaner.
| -t, --to VERSION Target base version. | ||
| -o, --overwrite Replace an existing migration file. | ||
| -d, --debug Print the generated migra SQL before wrapping it. | ||
| -d, --debug Print the generated wrapped migration SQL after creation. |
There was a problem hiding this comment.
| -d, --debug Print the generated wrapped migration SQL after creation. | |
| -d, --debug Print the generated wrapped migration SQL after creation. |
There was a problem hiding this comment.
Since this is intended to be published to PyPI, the README should include instructions for using it from there?
There was a problem hiding this comment.
Are we intending on removing this functionality, eventually, in favor of the standalone package? If so we should throw some deprecation warnings on import (IMO).
| "fire>=0.7.0", | ||
| "hydraters>=0.1.0", | ||
| "orjson>=3.11.0", | ||
| "pgstac-migrate>=0.9.11.dev0,<0.10", |
There was a problem hiding this comment.
Any reason to have the ceiling on the dependency?
Technical Context
pgstac.X.Y.Z.sql/pgstac.X.Y.Z-A.B.C.sqltopgstac--X.Y.Z.sql/pgstac--X.Y.Z--A.B.C.sql. Any tooling or scripts that reference migration files by the old dotted naming convention will need to be updated. Thepypgstac migrateCLI and Python API continue to work without changes.Description
This PR introduces
pgstac-migrate, a new lightweight standalone Python package that owns all of PgSTAC's runtime migration logic, and backsstageversion/makemigrationwith pgpkg for reproducible SQL assembly and diff-based migration generation.Migration filename canonicalization
All migration files are renamed to use the double-dash separator:
pgstac.0.9.10.sql → pgstac--0.9.10.sql
pgstac.0.9.10-0.9.11.sql → pgstac--0.9.10--0.9.11.sql
This matches the standard PostgreSQL extension file naming convention (
<extension>--<version>.sql,<extension>--<from>--<to>.sql), removes ambiguity between version separators and the dots in version numbers, and improves interoperability with extension tooling like pgpkg.New
pgstac-migratepackagesrc/pgstac-migrate/is a focused package that can be installed independently ofpypgstac:pgstac-migrate migrate [--to VERSION] [--dry-run], plusinfo,versions,plan,build-artifactpgstac_migrate.api.migrate(target, conninfo, ...)— usable directly without the full pypgstac stackmigrations.tar.zstbundle at publish time. This ships at 74 KB versus the 8.1 MB of raw SQL thatpypgstacpreviously bundled via a symlink — roughly a 110× reduction in migration payload. Those bytes move entirely out ofpypgstacand intopgstac-migrate.pypgstac migrateis maintained as a compatibility wrapper — with planned deprecationpypgstac migratecontinues to work exactly as before;Migrate.run_migration()now delegates topgstac_migrate.api.migrate()internally. No changes to calling code are required. This compatibility surface will be maintained for the near term but is planned for deprecation in a future minor release. Users should begin migrating topgstac-migrateCLI or API directly.pgpkg-backed
stageversionandmakemigrationThe in-container scripts now use
pgpkgfor SQL assembly and migration diffing, replacing the previous approach that usedmigraagainst two live databases. The optionalPGPKG_LOCAL_REPO_DIR/PGPKG_REPO_DIRenvironment variable allows testing against a local pgpkg checkout; default behavior resolves pgpkg from PyPI with no local setup required.Reviewers: please focus on
src/pgstac-migrate/(new package structure and API surface),src/pypgstac/src/pypgstac/migrate.py(delegation wiring), and the cross-surface parity test atsrc/pgstac-migrate/tests/test_parity.pywhich asserts both tools produce identical ordered SQL for all migration paths.Checklist
src/pgstac-migrate/tests/— CLI delegation, API, version source, and cross-surface plan parity (7 parametrized cases asserting pgstac-migrate catalog and pypgstac MigrationPath produce identical SQL file sequences)src/pypgstac/tests/test_migrate_wrapper.py— delegation and compat layer coveragescripts/container-scripts/testwired to run pgstac-migrate tests in CICHANGELOG.mdanddocs/src/release-notes.mdupdated;CONTRIBUTING.mdupdated to reflect two PyPI packages and new release workflow;CLAUDE.mdandAGENTS.mdupdated with pgstac-migrate architecture and migration-engineer workflowAI tool usage