Reputation: 100
So my model used to inherit from a Message
class of django-postman
library.
Therefore my 0001_initial
migration looks like this:
class Migration(migrations.Migration):
initial = True
dependencies = [
('postman', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Message',
fields=[
('message_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='postman.Message')),
('created_at', models.DateTimeField(auto_now_add=True)),
('deliver_at', models.DateTimeField(blank=True, null=True)),
('content', models.TextField(blank=True, null=True)),
],
bases=('postman.message',),
),
]
Now I want to totally remove my own Message
model. I can remove it normally and run makemigrations
which creates 0004_delete_message
that looks like this:
class Migration(migrations.Migration):
dependencies = [
('postman', '0001_initial'),
('my_app', '0003_migrate_data_to_new_model'),
]
operations = [
migrations.DeleteModel(
name='Message',
),
]
Now the issue is that I totally want to remove django-postman
library, including from my INSTALLED_APPS
. This creates the issue of both of these migrations not being applicable because they both depend on postman.0001_initial
which doesn't exist anymore.
Is there clean way of going about that deprecation while still keeping my migrations working or do I have to manually edit my 0001_initial
and run CreateModel
for the model introduced in postman.0001_initial
, and change bases
of my model to point to that model I created?
Upvotes: 1
Views: 51
Reputation: 723
You will need to modify 0001_initial
as you suggest to conform to the state of the installed code at run time.
Upvotes: 1