Skip to content

Include migrations in package#264

Merged
kaapstorm merged 9 commits intomasterfrom
nh/incl_migrations
Jan 27, 2026
Merged

Include migrations in package#264
kaapstorm merged 9 commits intomasterfrom
nh/incl_migrations

Conversation

@kaapstorm
Copy link
Contributor

@kaapstorm kaapstorm commented Jan 22, 2026

There are two things happening in this PR, and the second change takes advantage of the clean-up in the first:

  1. Logging
  2. Moving the Alembic migrations/ directory inside the commcare-export package.

The logging change replaces a custom Logger class with standard Python logging features.

The migrations/ directory is required by CheckpointManager and is currently missing unless commcare-export is installed from source. (Exports succeed, but checkpoints are not set.)

  • commcare_export/checkpoint.py now uses resources.files("commcare_export") / "migrations" and resources.as_file(...) when configuring Alembic so packaged installations can find migration files.

  • commcare_export/migrations/ is now the migrations home, and its README references the new path.

  • Packaging config includes the new subpackages and migration files so PyPI installs contain them.

🐬 Easier to review commit-by-commit.

@kaapstorm kaapstorm changed the base branch from nh/logging to master January 22, 2026 23:26
Unused outside of tests
Moves migrations into the package and updates CheckpointManager to
resolve the migration path via importlib.resources, plus packaging
updates so the migrations ship in wheels/sdists.

- commcare_export/checkpoint.py now uses
  `resources.files("commcare_export") / "migrations"` and
  `resources.as_file(...)` when configuring Alembic so packaged installs
  can find migration files.

- commcare_export/migrations/ is now the migrations home, and its README
  references the new path.

- Packaging config includes the new subpackages and migration files so
  PyPI installs contain them.
command.upgrade(cfg, revision)

with resources.as_file(self.migrations_repository) as migrations_path:
cfg = config.Config(os.path.join(migrations_path, 'alembic.ini'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is migrations_path a Path object? Given the syntax used above on line 89 I'm guessing it is.

Suggested change
cfg = config.Config(os.path.join(migrations_path, 'alembic.ini'))
cfg = config.Config(migrations_path / 'alembic.ini')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alembic's Config takes a str, but migrations_path / 'alembic.ini' returns a Traversable.

But config.Config(str(migrations_path / 'alembic.ini')) should work.

36ad4f5

@kaapstorm kaapstorm merged commit fd74faa into master Jan 27, 2026
7 checks passed
@kaapstorm kaapstorm deleted the nh/incl_migrations branch January 27, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants