I have a django app that was utilizing an external app reference. we no longer need this app reference, so we want to remove the dependency. I am able to generate the migrations to remove the foreign keys to models within the app we are removing, but I cannot remove the requirement reference in the app because it is referenced in the earlier migrations.
Does anyone have a known solution to removing app requirements like this?
to provide an example, say I have an external app that has the following model:
class ExternalInfo(models.Model):
random_field = CharField()
and in your project application, you have a customer record:
class Customer(models.Model):
name = CharField()
external_info = ForegnKey(external_app.ExternalInfo, null=True)
migration 0001 of the application creates the foreign key to the model in the external app. 10 months go by, and 10 migrations later, you need to remove external_info from the customer model, and you want to remove the external_app from the project. How do I remove this dependency without breaking older migrations?
Ok, so my workaround this issue was to do the following steps in order:
following these steps both upgrading existing databases, and building from scratch result in the same database schema. (excluding that I now need to find a way to get rid of the tables the app had created, anyone have ideas on best approach? I was thinking of writing a migrations.RunSql to drop the tables, but they won't exist in newly created databases)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With