I use Django 1.8.7 and PostgreSQL and had the following model:
class Permission(models.Model):
name = models.CharField(max_length=255)
template = models.ForeignKey(Template, related_name='permissions')
The I have added RenameModel operation:
migrations.RenameModel(
old_name='Permission',
new_name='TemplatePermission',
),
Looks that all work OK but sequence name for TemplatePermission.id field still myapp_permission_id_seq:
postgres=# \d+ myapp_templatepermission
Table "public.myapp_templatepermission"
Column | Type | Modifiers | Storage | Description
-------------+------------------------+--------------------------------------------------------------+----------+-------------
id | integer | not null default nextval('myapp_permission_id_seq'::regclass) | plain |
...
It there right way to rename sequence? Is it a bug in Django (I had found very similar bug report and patch for Django 1.8.x and Oracle)?
In my case I manually created sql migration script. However, this might not work if you decide to use different db.
operations = [
migrations.RenameModel(
old_name='Permission',
new_name='TemplatePermission',
),
migrations.RunSQL('alter sequence myapp_permission_id_seq rename to myapp_templatepermission_id_seq;'),
]
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