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

Migrations Broken With django-pyodbc-driver #583

Closed
beh9540 opened this issue Apr 12, 2018 · 10 comments
Closed

Migrations Broken With django-pyodbc-driver #583

beh9540 opened this issue Apr 12, 2018 · 10 comments
Assignees
Labels

Comments

@beh9540
Copy link

beh9540 commented Apr 12, 2018

When running migrations on a new project using django-pyodbc-driver, migrations fail due to the changing of the primary keys from AutoField to BigAutoField in this migration because of the limited capability of SQL Server to edit an IDENTITY property.

I'm able to work around this by manually changing the migrations (obviously not preferred) but I'm curious if you'd be open to collapsing this in the future? I'd be happy to work on putting a PR together.

@jleclanche
Copy link
Member

A migration reset seems a bit like overkill at this point to be honest :/

@synasius
Copy link
Contributor

Totally agree with @jleclanche

@beh9540 you might consider using MIGRATION_MODULES setting to override migrations for the oauth2_provider app. This way you can maintain your own migrations for an external package.

See https://docs.djangoproject.com/en/2.0/ref/settings/#std:setting-MIGRATION_MODULES

@beh9540
Copy link
Author

beh9540 commented Apr 12, 2018

@synasius yeah that's what I'm doing now, but I figured it'd be worth bringing up for anyone else who might run into this in the future.

@synasius
Copy link
Contributor

It might be useful to add a page somewhere in the docs about this use case to help those that need to override migrations.
@beh9540 do you think it would help?

@n2ygk
Copy link
Member

n2ygk commented Apr 27, 2018

@jleclanche @synasius We are also seeing this problem with pyodbc.

What's the reluctance about doing a migration reset? It seems like the cleanest fix. The current clutter of automigrations is messy and I don't think there's any value in maintaining history of old database structure; other than in git.

I don't see how this would cause problems for anybody, would make the package cleaner, and would solve the pyodbc problem.

Anyone who has had the package for a while has already migrated their models and new users don't need that history. Am I missing something?

oauth2_provider/migrations/0001_initial.py
oauth2_provider/migrations/0002_08_updates.py
oauth2_provider/migrations/0003_auto_20160316_1503.py
oauth2_provider/migrations/0004_auto_20160525_1623.py
oauth2_provider/migrations/0005_auto_20170514_1141.py
oauth2_provider/migrations/0006_auto_20171214_2232.py
oauth2_provider/migrations/__init__.py

@n2ygk
Copy link
Member

n2ygk commented Apr 28, 2018

@jleclanche I've been looking more at recent commits and see that in fact you have been editing auto migrations. I'm curious what the reason for doing it that way is vs. removing and making a single new initial migration that matches the current models. Is this to help users upgrade from an older installed version of the toolkit? If so, do the edited migrations lead to any problems with that? What if a user is at the 0004 level and then upgrades from there. Can the edits cause a problem?

The current migrations break django-pyodbc-azure due to AutoFields becoming BigAutoFields due to a restriction in MS SQL Server so I'm trying to understand how to solve this without having to special case every single project that uses pyodbc. One of my coworkers has in fact proposed further edits to the migrations to fix this, but I thought that was not the right way to go. Maybe I'm wrong. Wouldn't be the first time;-)

I'm just trying to understand the methodology, not criticize.
Thanks.

@n2ygk n2ygk self-assigned this May 12, 2018
@n2ygk n2ygk added the bug label May 12, 2018
@jleclanche
Copy link
Member

@n2ygk When a non-sql change happens in the migration state, django generates migrations because it detects model changes, but those aren't necessarily required.

Migrations themselves are a burden on the code; require extra maintenance, etc. I'm currently trying to wipe them off another django project which has far, far too many of them causing a lot of issues.

@n2ygk
Copy link
Member

n2ygk commented Jul 30, 2018

This is a MS SQL issue, not DOT. Closing.

@jbaltodano2019
Copy link

I have the problem "the backend doesn't support altering from/to AutoField" when adding the oauth2_provider . I've not found any solution to that issue,. can you help me with it?

@jbaltodano2019
Copy link

When running migrations on a new project using django-pyodbc-driver, migrations fail due to the changing of the primary keys from AutoField to BigAutoField in this migration because of the limited capability of SQL Server to edit an IDENTITY property.

I'm able to work around this by manually changing the migrations (obviously not preferred) but I'm curious if you'd be open to collapsing this in the future? I'd be happy to work on putting a PR together.

what your solution is? what is the modification you do to the migration file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants