Skip to content

feat(cli): add named-migration subcommand for PostgreSQL backend - #47

Merged
vistart merged 6 commits into
release/v1.0.0.dev16from
feature/named-migration-system
Jun 30, 2026
Merged

vistart merged 6 commits into
release/v1.0.0.dev16from
feature/named-migration-system

Conversation

@vistart

@vistart vistart commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds the named-migration CLI subcommand to the PostgreSQL backend adapter, enabling PostgreSQL users to leverage the named migration system introduced in core python-activerecord (PR #109).

Changes:

  • CLI adapter (cli/named_migration.py): Registers named-migration subcommand with PostgreSQL-specific connection config and delegates to rhosocial.activerecord.backend.migration.cli.handle_named_migration. Supports both sync (PostgreSQLBackend) and async (AsyncPostgreSQLBackend) execution.
  • Examples (examples/named_migrations/): PostgreSQL-specific migration examples:
    • migrations.py: V001CreateUsers, V002CreatePosts, V003CreateCustomTable
    • expressions.py: DDL expressions with PostgreSQL data types
    • run_basic.py / run_chain.py: Programmatic API usage
    • demo_basic.sh / demo_chain.sh / demo_all.sh: Shell demo scripts

Type of change

  • feat: A new feature

Breaking Change

  • No breaking changes

Impact on End-Users:
No backward-incompatible changes. The named-migration subcommand is a new addition.

Impact on Backend Developers (Custom Implementations):
No backward-incompatible changes are expected for backend developers using custom implementations.

Related Repositories/Packages

Testing

  • N/A — Migration CLI tests require a live PostgreSQL database

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Changelog fragment: changelog.d/<pr_number>.added.md
  • I have verified that my changes do not introduce SQL injection vulnerabilities

Additional Notes

This is the PostgreSQL plugin counterpart of the core migration feature (PR #109). The adapter is thin (~120 lines) — all core migration logic, dry-run validation, and record store management live in rhosocial.activerecord.backend.migration.

vistart and others added 2 commits June 24, 2026 23:14
Registers the 'named-migration' CLI subcommand for the PostgreSQL backend.
Delegates to the shared implementation in
rhosocial.activerecord.backend.migration.cli.

- cli/named_migration.py: parser + handler adapter
- cli/__init__.py: register in COMMAND_NAMES and register_commands()
…ripts for PostgreSQL

- Extend named_migration.py adapter with --async support (AsyncPostgresBackend)
- Add extensive CLI epilog with 12 scenario examples and demo script references
- Create examples/named_migrations/ with migrations.py, expressions.py, run_basic.py, run_chain.py
- Add demo_basic.sh, demo_chain.sh, demo_all.sh end-to-end shell scripts
- expressions.py uses PostgresSerialType and PostgresCharacterVaryingType
@codecov

codecov Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.43243% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.90%. Comparing base (fb975d5) to head (02cfff2).

Files with missing lines Patch % Lines
...ecord/backend/impl/postgres/cli/named_migration.py 28.57% 25 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           release/v1.0.0.dev16      #47      +/-   ##
========================================================
- Coverage                 71.02%   70.90%   -0.13%     
========================================================
  Files                       276      277       +1     
  Lines                     11253    11290      +37     
  Branches                   1825     1828       +3     
========================================================
+ Hits                       7993     8005      +12     
- Misses                     2643     2668      +25     
  Partials                    617      617              
Flag Coverage Δ
postgres-18 70.90% <32.43%> (-0.13%) ⬇️
python-3.14 70.90% <32.43%> (-0.13%) ⬇️
unittests 70.90% <32.43%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vistart vistart self-assigned this Jun 30, 2026
@sonarqubecloud

Copy link
Copy Markdown

@vistart
vistart merged commit e691dc4 into release/v1.0.0.dev16 Jun 30, 2026
15 of 17 checks passed
@vistart vistart mentioned this pull request Aug 15, 2026
8 of 12 tasks
vistart added a commit that referenced this pull request Aug 15, 2026
* feat(cli): add named-migration subcommand (PostgreSQL adapter)

Registers the 'named-migration' CLI subcommand for the PostgreSQL backend.
Delegates to the shared implementation in
rhosocial.activerecord.backend.migration.cli.

- cli/named_migration.py: parser + handler adapter
- cli/__init__.py: register in COMMAND_NAMES and register_commands()

* feat(migration): add --async support, example migrations, and demo scripts for PostgreSQL

- Extend named_migration.py adapter with --async support (AsyncPostgresBackend)
- Add extensive CLI epilog with 12 scenario examples and demo script references
- Create examples/named_migrations/ with migrations.py, expressions.py, run_basic.py, run_chain.py
- Add demo_basic.sh, demo_chain.sh, demo_all.sh end-to-end shell scripts
- expressions.py uses PostgresSerialType and PostgresCharacterVaryingType

* chore: add changelog fragment for PR #47

* chore: add parameterized migration, async, incompatible, and single-transaction demo scripts for PostgreSQL

* fix(postgres): use positional arg instead of keyword 'size' for PostgresCharacterVaryingType

* ci: trigger rebuild
@vistart
vistart deleted the feature/named-migration-system branch October 1, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant