Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(db): Remove begin when assembling migrations #5148

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

tmessi
Copy link
Member

@tmessi tmessi commented Oct 3, 2024

When building the set of migrations to run as part of executing the
database migrate or database init, the migrations are collected and
combined to run within a database transaction. As such the begin and
commit statements in the migration files should get removed from the
final set of statements that get executed. However, when the migrations
files were updated to include copyright and license headers, this broke
the logic that would strip out the begin statement.

While this does not cause any issue with executing the statements in a
single transaction, it does result in noise in the database server's
logs, with log messages like:

BEGIN WARNING:  25001: there is already a transaction in progress
BEGIN LOCATION:  BeginTransactionBlock, xact.c:3778

This commit fixes the logic to correctly strip the begin for files
that have the header lines.

@tmessi tmessi force-pushed the tmessi-fix-migration-begin-warning branch from c626e69 to 6e6f73f Compare December 19, 2024 17:05
@tmessi tmessi added this to the 0.19.x milestone Dec 19, 2024
@tmessi tmessi marked this pull request as ready for review December 19, 2024 17:06
@tmessi tmessi requested a review from a team as a code owner December 19, 2024 17:06
When building the set of migrations to run as part of executing the
`database migrate` or `database init`, the migrations are collected and
combined to run within a database transaction. As such the `begin` and
`commit` statements in the migration files should get removed from the
final set of statements that get executed. However, when the migrations
files were updated to include copyright and license headers, this broke
the logic that would strip out the `begin` statement.

While this does not cause any issue with executing the statements in a
single transaction, it does result in noise in the database server's
logs, with log messages like:

    BEGIN WARNING:  25001: there is already a transaction in progress
    BEGIN LOCATION:  BeginTransactionBlock, xact.c:3778

This commit fixes the logic to correctly strip the `begin` for files
that have the header lines.
@tmessi tmessi force-pushed the tmessi-fix-migration-begin-warning branch from 6e6f73f to 5d116b3 Compare January 8, 2025 15:07
@tmessi tmessi merged commit 71af25f into main Jan 8, 2025
64 of 65 checks passed
@tmessi tmessi deleted the tmessi-fix-migration-begin-warning branch January 8, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants