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

Distinguish inferred migrations by timestamp for statements within the same transaction #362

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

andrew-farries
Copy link
Collaborator

@andrew-farries andrew-farries commented Jun 25, 2024

Set created_at and updated_at explicitly when inserting inferred migrations into the migrations table.

When two statements are run in a transaction, we need to explicitly insert statement_timestamp() into the created_at and updated_at fields rather than relying on the table default of current_timestamp.

current_timestamp is the same for all statements in a transaction, which causes problems when ordering statements by created_at.

Fixes #361

Ensure that two statements executed in a transaction have different
timestamps in the migrations table.
When two statements are run in a transaction, we need to explicitly
insert `statement_timestamp()` into the `created_at` and `updated_at`
fields rather than relying on the table default of `current_timestamp`.

`current_timestamp` is the same for all statements in a transaction,
which causes problems when ordering statements by `created_at`.
@andrew-farries andrew-farries force-pushed the distinguish-inferred-migrations-by-timestamp branch from da0a31e to 053a0cf Compare June 25, 2024 13:12
@andrew-farries andrew-farries merged commit 7cef8b1 into main Jun 25, 2024
44 checks passed
@andrew-farries andrew-farries deleted the distinguish-inferred-migrations-by-timestamp branch June 25, 2024 13:57
This pull request was closed.
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.

Inferred migrations should distinguish by timestamp between statements executed in a single transaction
2 participants