Add "--check-heads" option to "current" command#1739
Conversation
|
One test started to fail when I added additional tests. I don't know why and I don't think tests should be able to influence other tests in this way. I probably did something wrong, but don't know what. 🙈 |
|
I was also considering to add a |
im not a huge fan of digging in that level of richness here, the idiomatic way to do that kind of thing would be: why re-implement all that in some less full featured way |
zzzeek
left a comment
There was a problem hiding this comment.
thanks for the PR! minor changes
sqla-tester
left a comment
There was a problem hiding this comment.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision f8c9a1f of this pull request into gerrit so we can run tests and reviews and stuff
|
New Gerrit review created for change f8c9a1f: https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265 |
sqla-tester
left a comment
There was a problem hiding this comment.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 955f9b7 of this pull request into gerrit so we can run tests and reviews and stuff
|
Patchset 955f9b7 added to existing Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265 |
sqla-tester
left a comment
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
OK great, I've applied some last minute changes on this end.
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
| :param config: a :class:`.Config` instance. | ||
|
|
||
| :param check_heads: Check if all head revisions are applied to the | ||
| database. Exit with an error if this is not the case. |
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
.. versionadded:: 1.17.1
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
| if check_heads and ( | ||
| set(context.get_current_heads()) != set(script.get_heads()) | ||
| ): | ||
| raise util.CommandError("Database is not on all head revisions") |
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
like alembic check, will add a subclass here
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
| :tickets: 1705 | ||
|
|
||
| Added ``--check-heads`` option to ``current`` command which | ||
| checks if all head revisions are applied to the database. |
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
will mention the cookbook recipe here
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
|
|
||
| Added ``--check-heads`` option to ``current`` command which | ||
| checks if all head revisions are applied to the database. | ||
| The command exists with a non-zero exit code if this is not the |
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
typo exists
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
| Added ``--check-heads`` option to ``current`` command which | ||
| checks if all head revisions are applied to the database. | ||
| The command exists with a non-zero exit code if this is not the | ||
| case. |
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
pull request courtesy Stefan Scherfke
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
| ["a3", "b2"], | ||
| argnames="revs", | ||
| ) | ||
| def test_check_heads_fail(self, revs): |
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
nice job
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
| assert_raises_message( | ||
| util.CommandError, | ||
| "Database is not on all head revisions", | ||
| command.current, |
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
there might be some test cleanup error occurring, investigating
it looks like test_doesnt_create_alembic_version was relying on test ordering to work, fixed that test separately.
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
|
Michael Bayer (zzzeek) wrote: recheck View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265 |
sqla-tester
left a comment
There was a problem hiding this comment.
Federico Caselli (CaselIT) wrote:
code review left on gerrit
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
- tests/test_command.py (line 1601): not sure if this was intended
sqla-tester
left a comment
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
code review left on gerrit
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
- tests/test_command.py (line 1601): it was, I had a shutil.rmtree() there which was deleting the whole class-level fixture and only passing because of randomness. these new tests started throwing it all off, so i fixed this test to only delete the file that it created.
|
Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265 has been merged. Congratulations! :) |
sqla-tester
left a comment
There was a problem hiding this comment.
Federico Caselli (CaselIT) wrote:
code review left on gerrit
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6265
- tests/test_command.py (line 1601): ok!
Added :paramref:`.command.current.check_heads` parameter to :func:`.command.current` command, available from the command line via the ``--check-heads`` option to ``alembic current``. This tests if all head revisions are applied to the database and raises :class:`.DatabaseNotAtHead` (or from the command line, exits with a non-zero exit code) if this is not the case. The parameter operates equvialently to the cookbook recipe :ref:`cookbook_check_heads`. Pull request courtesy Stefan Scherfke. Fixes: sqlalchemy#1705 Closes: sqlalchemy#1739 Pull-request: sqlalchemy#1739 Pull-request-sha: 955f9b7 Change-Id: I1173217ff6a4927226ec9e7b8c7ef67c6431d728
Add
--check-headsoption tocurrentcommad to check if all head revisions are applied to the database.Description
Fixes: #1705
Checklist
This pull request is:
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
Fixes: #<issue number>in the commit messageinclude a complete example of how the feature would look.
Fixes: #<issue number>in the commit messageHave a nice day!