xataio / pgroll

PostgreSQL zero-downtime migrations made easy
https://www.xata.io
Apache License 2.0
2.97k stars 54 forks source link

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

Closed andrew-farries closed 2 months ago

andrew-farries commented 2 months ago

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