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

How to resolve extending AbstractApplication model in automatic deployment #669

Open
anuj9196 opened this issue Nov 23, 2018 · 2 comments
Open

Comments

@anuj9196
Copy link

anuj9196 commented Nov 23, 2018

I'm using this plugin in my application and now have written a model in which I need to add AbstractApplication as foreign key.

Since, I can't use it directly. I created a blank model extending AbstractApplication.

class CustomApplication(AbstractApplication):
    pass

Then I run following commands before actually using it in the application.

manage.py makemigrationa
manage.py migrate

then added CustomApplication to settings.py

Then created my required model and used settings.OAUTH2_PROVIDER_APPLICATION_MODEL as ForeignKey.

class MyModel(models.Model):
    application = models.ForeignKey(settings.OAUTH2_PROVIDER_APPLICATION_MODEL, ...)

again run makemigrations and migrate command.

This was done on local development environment. But how to resolve this in automatic deployment?

In deployment there will be OAUTH2_PROVIDER_APPLICATION_MODEL in settings.py before migrating the migrations and thus will create issue.

@KyrumX
Copy link

KyrumX commented Nov 26, 2018

+1

@cedriclevarlet
Copy link

@anuj9196 I understand this was opened a while ago but this might come to be useful for others in the future. Your migrations should be kept across different environments and therefore be distributed along with your code.

As such you should only ever run the makemigrations command after a change in one of your models. This will generate a migration file which you should commit and distribute along with your code.

Once you distribute said code, you should only have to run the migrate command in automatic deployment.

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

No branches or pull requests

3 participants