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
fix migrate:up for migrations disabling transactions #4550
fix migrate:up for migrations disabling transactions #4550
Conversation
Bump |
@jeff-permiso Sorry for the delay. |
- also add tests for migrate:up, migrate:down when transactions are disabled
@kibertoad Sorry for the delay -- I've added tests around single up/down migrations without transactions, and refactored the method as requested. |
@kibertoad Any feedback on the tests or refactoring? Thanks much. |
exports.up = async function () {}; | ||
|
||
exports.down = async function (knex) { | ||
if (isPostgreSQL(knex)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't seem to be the right place for skipping the test, could you move it into a test itself? there are plenty of examples of how db-specific tests are handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to test
); | ||
}); | ||
|
||
it('should run', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this test those migrations to simply not fail with an error? can we also assert that they actually did what we expect them to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migrations don't actually do anything other than throw an error if called within a transaction. Added a comment to that effect.
}); | ||
|
||
it('should not error if all migrations have already been undone', function () { | ||
return knex.migrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be rewritten into async/await?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated PR with requests
); | ||
}); | ||
|
||
it('should run', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migrations don't actually do anything other than throw an error if called within a transaction. Added a comment to that effect.
exports.up = async function () {}; | ||
|
||
exports.down = async function (knex) { | ||
if (isPostgreSQL(knex)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to test
}); | ||
|
||
it('should not error if all migrations have already been undone', function () { | ||
return knex.migrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
What is PostgreSQL-specific for these tests, btw? Aren't transactions pretty universal? |
The method I was using to test being in a transaction wasn't. Rewrote to make more universal. |
Thanks a lot! |
does not respect configuration
due to treating the return value of getMigration as a value rather than a promise.
I could use advice on where to add tests for this behavior.