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

The first migration is always rolled back on Windows #213

Closed
2joy opened this issue Apr 20, 2021 · 1 comment · Fixed by #496
Closed

The first migration is always rolled back on Windows #213

2joy opened this issue Apr 20, 2021 · 1 comment · Fixed by #496
Assignees
Labels

Comments

@2joy
Copy link

2joy commented Apr 20, 2021

20210329163410_initial_migration.txt

Synthetic first migration example for demonstration.

-- migrate:up
CREATE SCHEMA IF NOT EXISTS up;

-- migrate:down
CREATE SCHEMA IF NOT EXISTS down;

On Windows, the first migration will always be rolled back and both schemes will appear in the database.
On Linux all is fine.
This behavior was seen only in the first migration. If you add a migration before it, even one consisting of only comments, the down schema will not be created.

! UPDATE:
I figured out what was causing the poblem. These are Windows line breaks (\r\n). I attach a file created on Windows, with it the same behavior occurs under Linux.

@amacneil
Copy link
Owner

Definitely sounds like a bug. I don't have time to investigate right now, but I have a feeling it's probably something to do with our migration parsing logic in https://github.com/amacneil/dbmate/blob/main/pkg/dbmate/migration.go#L57 .

A good place to start would be adding a unit test specifically testing \r\n line endings.

@dossy dossy added the bug label Nov 15, 2023
dossy added a commit to dossy/dbmate that referenced this issue Nov 16, 2023
@dossy dossy self-assigned this Nov 16, 2023
dossy added a commit to dossy/dbmate that referenced this issue Nov 16, 2023
dossy added a commit that referenced this issue Nov 16, 2023
* chore: add failing tests that demonstrate the issue

* fix: correct migration parsing regexps

Fixes #213.

* fix: satisfy linter

* fix: use unique test table names in test migrations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants