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 db migration with postgres #1679
Conversation
PostgreSQL (and Oracle and SQLite) use sequences for autoincrement columns. If no sequence is given, one will be created automatically which clashes with the required one in `models.py` We have to create the required sequence manually but only if the backend supports it. Actually this affects all migration scripts which create columns with an auto_increment attribute. Fixes #1676
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.
lgtm. Thanks!
migrations/versions/48ee74b8a7c8_.py
Outdated
def upgrade(): | ||
try: | ||
create_seq('tokenowner_seq') |
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.
Looks good! But could you wrap this call in a try-except block? This way, if creating the sequence fails for any reason, we will at least create the tokenowner table.
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.
fixed in beb31af
Codecov Report
@@ Coverage Diff @@
## branch-3.0 #1679 +/- ##
==============================================
- Coverage 96.98% 96.93% -0.05%
==============================================
Files 148 148
Lines 17849 17738 -111
==============================================
- Hits 17310 17195 -115
- Misses 539 543 +4
Continue to review full report at Codecov.
|
Looks good, thanks! |
PostgreSQL (and Oracle and SQLite) use sequences for autoincrement columns.
If no sequence is given, one will be created automatically which clashes
with the required one in
models.py
We have to create the required sequence manually but only if the backend
supports it.
Actually this affects all migration scripts which create columns with an
auto_increment attribute.
Fixes #1676