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

feat: migration box now supports autocommit DDL changes #818

Merged
merged 4 commits into from
Oct 31, 2024

Conversation

aeneasr
Copy link
Member

@aeneasr aeneasr commented Oct 31, 2024

To better support CockroachDB, a new migration type ("autocommit") has been added. Autocommit migrations will not be executed in a transaction, which resolves issues in when running large DDL changes in crdb transactions.

To use this feature, just prefix the file extension with .autocommit:

1234_name.up.autocommit.sql < does not run in transaction
1234_name.up.sql < runs in transaction

Works with all combinations:

1234_name.postgres.up.autocommit.sql

Related Issue or Design Document

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact [email protected]) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

@aeneasr aeneasr requested review from zepatrik and alnr October 31, 2024 10:49
To better support CockroachDB, a new migration type ("autocommit") has been added. Autocommit migrations will not be executed in a transaction, which resolves issues in when running large DDL changes in crdb transactions.

To use this feature, just add `.autocommit` to the filename:

```
1234_name.autocommit.up.sql < does not run in transaction
1234_name.up.sql < runs in transaction
```

Works with all combinations:

```
1234_name.postgres.autocommit.up.sql
```
@aeneasr aeneasr force-pushed the migrator-cockroach-ddl branch from e3d8c16 to 0dd59c2 Compare October 31, 2024 11:02
popx/match.go Outdated
"github.com/gobuffalo/pop/v6"
)

var mrx = regexp.MustCompile(`^(\d+)_([^.]+)(\.[a-z0-9]+)?\.(up|down)(|\.autocommit)\.(sql|fizz)$`)
Copy link
Member

Choose a reason for hiding this comment

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

As we're not using fizz, we can just completely remove it?

Suggested change
var mrx = regexp.MustCompile(`^(\d+)_([^.]+)(\.[a-z0-9]+)?\.(up|down)(|\.autocommit)\.(sql|fizz)$`)
var mrx = regexp.MustCompile(`^(\d+)_([^.]+)(\.[a-z0-9]+)?\.(up|down)(|\.autocommit)\.sql$`)

Copy link
Member Author

Choose a reason for hiding this comment

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

added

@aeneasr aeneasr merged commit 934758e into master Oct 31, 2024
9 checks passed
@aeneasr aeneasr deleted the migrator-cockroach-ddl branch October 31, 2024 14:22
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