-
Notifications
You must be signed in to change notification settings - Fork 86
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
Cleanup migrations #142
Cleanup migrations #142
Conversation
Thanks for having a look at this! I'll have a look within the next week (hopefully). |
I was too curious and ended up looking at it now. Turns out it's database backend-dependent. With SQLite it works fine; with PostgreSQL it fails (at least for me). By the way, for me it works fine when Reproduction instructionsPerhaps annoyingly, since I've only got it to fail on PostgreSQL, reproducing it requires you to have PostgreSQL, and all the corresponding setup. I put the offending configuration in a commit on my fork, on a branch called git clone git@github.com:czlee/django-dynamic-preferences.git
cd django-dynamic-preferences
git checkout migrations-psql
# Create and activate virtual environment (these are the commands I use, in case it matters)
# vex -m --python=python3.6 django-dynamic-preferences
python -m venv venv
source venv/bin/activate
# I think you have to use the requirements.txt in the example directory, right?
cd example
pip install -r requirements.txt
# Create database (if you haven't already); I called it 'preferences' in settings.py
createdb preferences
python manage.py migrate
python manage.py flush What does
|
Well, this is a fantastic insight. I only tried on SQLite, and knowing it fails on postgres will help reproduce the issue, thanks! |
@czlee I think I found a proper solution: I removed every remains of the user models from Everything should work fine and consistently now. I tried it locally with a postgres database, and applying and reverting migrations work as expected. Can you try this locally and tell me how it goes for you/review the PR if you have the time. I know it includes some unrelated CI/Django2 stuff, but it was blocking me while working on this. If it works, I'll merge and publish a release and, hopefully, this will be behind us! |
687d6a9
to
833bac5
Compare
833bac5
to
983330b
Compare
983330b
to
f40a00e
Compare
Thanks! This works when migrating a blank database, as in, the As expected, it neither helps nor harms my existing installation. I agree with the approach you've taken and described in the changelog, that is, the manual workaround of dropping the So it looks good to me with respect to #140. 😃 I tried it both with the example project, and my actual project. Thanks again! |
1.6 (2018-06-17) **************** - Fixed #141 and #141: migrations issues (see below) - Dropped support for django < 1.11 - Dropped support for Python 3.4 - Better namespaces for urls Better namespaces for urls -------------------------- Historically, the package included multiple urls. To ensure compatibility with django 2 and better namespacing, you should update any references to those urls as described below: +-------------------------------------+-------------------------------------+ | Old url | New url | +=====================================+=====================================+ | dynamic_preferences.global | dynamic_preferences:global | +-------------------------------------+-------------------------------------+ | dynamic_preferences.global.section | dynamic_preferences:global.section | +-------------------------------------+-------------------------------------+ | dynamic_preferences.user | dynamic_preferences:user | +-------------------------------------+-------------------------------------+ | dynamic_preferences.user.section | dynamic_preferences:user.section | +-------------------------------------+-------------------------------------+ Migration cleanup ----------------- This version includes a proper fix for migration issues. Full background is available at https://github.com/EliotBerriot/django-dynamic-preferences/pull/142, but here is the gist of it: 1. Early versions of dynamic_preferences included the user and global preferences models in the same app 2. The community requested a way to disable user preferences. The only way to do that was to move the user preference model in a dedicated app (dynamic_preferences_user 3. A migration was written to handle that transparently, but this was not actually possible to have something that worked for both existing and new installations 4. Thus, we ended up with issues such as #140 or #141, inconsistent db state, tables lying around in the database, etc. I'd like to apologize to everyone impacted. By trying to make 3. completely transparent to everyone and avoid a manual migration step for new installations, I actually made things worse. This release should fix all that: any remains of the user app was removed from the main app migrations. For any new user, it will be like nothing happened. For existing installations with user preferences disabled, there is nothing to do, apart from deleting the `dynamic_preferences_users_userpreferencemodel` table in your database. For existing installations with user preferences enabled, there is nothing to do. You should have ``'dynamic_preferences.users.apps.UserPreferencesConfig'`` in your installed apps. If ``python manage.py migrate`` fails with ``django.db.utils.ProgrammingError: relation "dynamic_preferences_users_userpreferencemodel" already exists``, this probably means you are upgrading for a really old release. In such event, simply skip the initial migration for the ``dynamic_preferences_user`` app by running ``python manage.py migrate dynamic_preferences_users 0001 --fake``. Many thanks to all people who helped clearing this mess, especially @czlee.
release 1.6 pushed on pypi :) |
See #141 and #140.
CC @czlee @marcofvera @gonvaled
I cannot seem to reproduce the issue you are facing using the example project.
here is what I do:
On the migrate part, this is the output I get:
If I remove
db.sqlite3
and try this again, withoutdynamic_preferences.users.apps.UserPreferencesConfig
inexample/settings.py
, I get the same output (without thedynamic_preferences_users
part, of course).python manage.py flush
works as well.I'm not saying there is no issue in the package. There is probably one, and having the table lying around in the DB even if the user app is not installed is problematic.
However, I'm never encountering the same issues as you described in your comments (Here, for instance). Thus, I'm a bit blocked :/
By any chance, would someone facing the issue be able to share the complete and minimum set of instructions to reproduce this reliably?