-
Notifications
You must be signed in to change notification settings - Fork 77
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
Resolve social auth migration issue in production #242
Comments
For now, the workaround is to apply migrations from apps individually in production. |
Any chance of just "faking" the migration that fails? The fields are there, so no need to create them. https://blog.dbrgn.ch/2014/10/30/migrating-django-social-auth/ |
I made some progress with this issue. We won't be able to "fake" the migration. The database and migrations are inconsistent. Results after faking the first migration: social_django
[X] 0001_initial (2 squashed migrations)
[ ] 0002_add_related_name (2 squashed migrations)
[ ] 0003_alter_email_max_length (2 squashed migrations)
[ ] 0004_auto_20160423_0400 (2 squashed migrations)
[ ] 0005_auto_20160727_2333 (1 squashed migrations)
[ ] 0006_partial
[ ] 0007_code_timestamp
[ ] 0008_partial_timestamp Operations to perform:
Apply all migrations: social_django
Running migrations:
Rendering model states... DONE
Applying social_django.0002_add_related_name... OK
Applying social_django.0003_alter_email_max_length...Traceback (most recent call last):
File "/home/app/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "social_auth_code" does not exist The value for social_auth_code does not exist. |
I have a preliminary solution 😃. There seems to be just one table missing from the initial migration. Step 1 - fake the initial migration
Step 2 - run the following SQL to create the missing table, constraints, and indexes
Step 3 - migrate as usual
I'll do some additional checks, but I think we're back in business. Hopefully, this won't mess up the existing data. |
@raymondberg and @smandekar1, I was able to create a couple new oauth accounts just fine this morning. Could one of you verify the steps above before we run it in production? Also, I have a new pull request to add a make psql shell, #243. The command runs: docker-compose exec db psql chipy chipy You could use this psql shell to run the SQL on your dev machine. This sql was generated from: python manage.py sqlmigrate social_django 0001_initial and then trimmed back to the missing table. It's extremely similar to omab/python-social-auth#682, but we have a slightly different set of SQL commands to run. |
I was getting this after step 1. running off the chipy master. I tried migrating contenttypes alone and then step 1 worked.
step 2 returned |
@smandekar1 you will need to start with a clean database and back on tag 1.12.1 prior to Django social auth to python social auth migration. Then mock the upgrade. You could nuke the current volume, docker-compse volume rm chipy... And docker-compse image rm chipy... Then rebuild the environment. Alternatively build out a new environment typing the commands in the make file but adding the -p option. Example docker-compse -p up - - build -d. -p let's you provide a name other than that of the parent directory. Rebuilding a docker-compose env does not delete the data from the volume by design. Step 2 is running SQL directly on postgresql and does not involve social auth partial. So the error you got looks odd to me. |
Maybe we can test it on your machine Thursday night before running it on the production site. |
Sounds good, we can test it on this. I did delete the database, but I didn't delete the image and start on 1.12.1 |
Truly awesome. Thanks @elmq0022 and @smandekar1 |
Forgot to say, this is what we wound up with in prod:
|
We seem to be having the same problem in production as documented here: omab/python-social-auth#682
This our output when migrating:
The text was updated successfully, but these errors were encountered: