Open meshy opened 5 years ago
We ran into some issues when upgrading from version 3. This updates the release notes to help clarify the process.
You may be interested in the migration we wrote (in another app) to get this going:
from __future__ import unicode_literals from django.db import migrations EXISTS_SQL = """ SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE tablename = '{old}' ); """ DROP_TABLE_SQL = 'DROP TABLE {new};' RENAME_SQL = 'ALTER TABLE {old} RENAME TO {new};' def forward(apps, schema_editor): with schema_editor.connection.cursor() as cursor: tables = ( 'notifications_noticequeuebatch', 'notifications_noticesetting', 'notifications_noticetype', ) for old_table in tables: new_table = 'pinax_' + old_table cursor.execute(EXISTS_SQL.format(old=old_table)) (old_table_exists,) = cursor.fetchone() if old_table_exists: cursor.execute(DROP_TABLE_SQL.format(new=new_table)) cursor.execute(RENAME_SQL.format(old=old_table, new=new_table)) class Migration(migrations.Migration): dependencies = [('pinax_notifications', '0001_initial')] run_before = [('pinax_notifications', '0002_auto_20171003_2006')] operations = [migrations.RunPython(forward, migrations.RunPython.noop)]
We also altered some relations to these tables:
class User: notifications = models.ManyToManyField( - 'notifications.NoticeType', - through='notifications.NoticeSetting', + 'pinax_notifications.NoticeType', + through='pinax_notifications.NoticeSetting', blank=True, editable=False, ) ...
And the corresponding migrations:
migrations.AddField( model_name='user', name='notifications', - field=models.ManyToManyField(to='notifications.NoticeType', editable=False, through='notifications.NoticeSetting', blank=True), + field=models.ManyToManyField(to='pinax_notifications.NoticeType', editable=False, through='pinax_notifications.NoticeSetting', blank=True), ),
@meshy Thanks for this info. We will take a look at this.
We ran into some issues when upgrading from version 3. This updates the release notes to help clarify the process.
You may be interested in the migration we wrote (in another app) to get this going:
We also altered some relations to these tables:
And the corresponding migrations: