Skip to content

migrations: New migrations use transactions

Administrator requested to merge migrations-readme into master

Created by: keegancsmith

We discovered that the migration library does not use transactions, nor has it ever used transactions. The only place it uses transactions is for SetVersion, not the actual migrations. The README for the postgres driver encourages the use of transactions for multi-statement migrations. We believe it is better to just always use transactions.

We added a template for the created migrations. It uses a transaction and it includes comments with advice from the README.

Reference: The PR which added the deprecated advice https://github.com/sourcegraph/enterprise/pull/11564#pullrequestreview-123318799

Note: This PR originally used the ISOLATION LEVEL SERIALIZABLE for the transaction. However, this level requires retries by the application (which migrate does not do) and it is not appropriate for all migrations.

Merge request reports

Loading