Skip to content

Apply v1.0.23#211

Merged
nettrash merged 8 commits into
masterfrom
v1.0.23
Jun 5, 2026
Merged

Apply v1.0.23#211
nettrash merged 8 commits into
masterfrom
v1.0.23

Conversation

@nettrash
Copy link
Copy Markdown
Owner

@nettrash nettrash commented Jun 5, 2026

Features:

  • Production-friendly output for the compare command, enabled with --output-for-production (or OUTPUT_FOR_PRODUCTION=true in the config file). When on, the generated migration is shaped to minimise locking on a live database: indexes are built with CREATE INDEX CONCURRENTLY (the UNIQUE keyword is preserved); indexes on partitioned parents use CREATE INDEX ... ON ONLY {parent} inside the transaction, then CREATE INDEX CONCURRENTLY on each partition followed by ALTER INDEX ... ATTACH PARTITION afterwards (falling back to a single non-concurrent CREATE INDEX on the parent, with an explanatory comment, when the layout cannot be expanded safely); indexes are dropped with DROP INDEX CONCURRENTLY (kept non-concurrent for indexes on partitioned tables, where concurrent drop is illegal); and new foreign keys are added NOT VALID inside the transaction and validated with a separate VALIDATE CONSTRAINT afterwards. Every statement that cannot run inside a transaction block (CREATE/DROP INDEX CONCURRENTLY, VALIDATE CONSTRAINT, ALTER INDEX ... ATTACH PARTITION) is emitted in a clearly marked Production post-commit section after commit. Defaults to false; when off, the output is byte-for-byte identical to previous behaviour.
  • Added the OUTPUT_FOR_PRODUCTION key to the sample data/pgc.conf and documented the new flag, configuration key, and behaviour in README.md.
  • Production output is now re-runnable: every DDL form PostgreSQL supports is emitted defensively with an idempotency guard where available, so a partially-applied migration can be replayed without failing. CREATE [UNLOGGED] TABLE, CREATE [UNLOGGED] SEQUENCE, CREATE MATERIALIZED VIEW and CREATE [UNIQUE] INDEX [CONCURRENTLY] gain IF NOT EXISTS; CREATE VIEW becomes CREATE OR REPLACE VIEW; ALTER TABLE ... ADD COLUMN gains IF NOT EXISTS; and ALTER TABLE ... DROP COLUMN / DROP CONSTRAINT gain IF EXISTS. CREATE TYPE and ALTER TABLE ... ADD CONSTRAINT are left as-is (PostgreSQL has no idempotency guard for them). The rewrite is literal-, comment- and dollar-quote-aware, so quoted text, commented drops and function bodies are untouched, and it only applies when --output-for-production is on.

@nettrash nettrash added this to the v1.0.23 milestone Jun 5, 2026
@nettrash nettrash self-assigned this Jun 5, 2026
Copilot AI review requested due to automatic review settings June 5, 2026 12:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “production-friendly” compare output mode that restructures generated migrations to minimize locking on live databases, while making production-mode migrations re-runnable via SQL-aware idempotency rewrites.

Changes:

  • Introduces --output-for-production / OUTPUT_FOR_PRODUCTION to enable production-optimized compare output (concurrent index ops, FK NOT VALID + post-commit VALIDATE, partition-aware index handling, post-commit section).
  • Adds a production-mode SQL rewriting module (comparer::production) including an SQL-aware idempotency pass (make_idempotent) plus unit/integration test coverage.
  • Documents the new behavior in README and sample config, and bumps version/changelog to v1.0.23.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
README.md Documents the new flag/config key and explains production-mode behavior and constraints.
data/pgc.conf Adds OUTPUT_FOR_PRODUCTION with explanatory comments to the sample config.
CHANGELOG Adds v1.0.23 release notes describing production-mode output and rerunnable/idempotent DDL behavior.
app/src/main.rs Adds the CLI flag and threads it into the compare execution path.
app/src/config/core.rs Adds OUTPUT_FOR_PRODUCTION parsing and exposes it on Config.
app/src/config/core_tests.rs Extends config parsing tests to cover the new key and default behavior.
app/src/comparer/scanner.rs Exposes scanner helpers needed for SQL-aware rewriting (crate-visible).
app/src/comparer/production.rs New production-mode index/FK rewriting and idempotency (make_idempotent) implementation.
app/src/comparer/production_tests.rs Unit tests for production rewrite behavior and idempotency scanning.
app/src/comparer/mod.rs Exports the new production module.
app/src/comparer/core.rs Integrates production-mode behavior into script generation (post-commit section + idempotency pass).
app/src/dump/table.rs Adds index/FK planning helpers and “defer indexes” script variants to support production-mode emission.
app/src/comparer/core_tests.rs Adds integration-style tests asserting post-commit concurrent index builds and FK validate splitting.
app/Cargo.toml Bumps crate version to 1.0.23.
app/Cargo.lock Updates lockfile version entry accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG Outdated
Comment thread CHANGELOG Outdated
Comment thread app/src/comparer/core.rs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 5, 2026 12:09
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.

Comment thread README.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 5, 2026 12:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.

Comment thread app/src/comparer/production.rs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.

Comment thread app/src/comparer/core.rs
Comment thread app/src/comparer/production.rs
Comment thread app/src/dump/table.rs
@nettrash nettrash merged commit cc18ab3 into master Jun 5, 2026
17 checks passed
@nettrash nettrash deleted the v1.0.23 branch June 5, 2026 12:36
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