Skip to content

Extra 4.0 release notes - #89

Open
meshy wants to merge 2 commits into
pinax:masterfrom
Virtualstock:extra-4.0-release-notes
Open

Extra 4.0 release notes#89
meshy wants to merge 2 commits into
pinax:masterfrom
Virtualstock:extra-4.0-release-notes

Conversation

@meshy

@meshy meshy commented Jan 24, 2019

Copy link
Copy Markdown

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 and others added 2 commits January 24, 2019 11:46
Version 4 stopped disabling autoescape in `full.txt` and `short.txt`,
and developers must now do this explicitly.

The previous version of the release notes was not clear on this point.

Co-authored-by: Ian Foote <ian.foote@virtualstock.com>
This relates to the addition of `label = "pinax_notifications"` to
`notifications.apps.AppConfig`.

Ref: pinax@07076ff#diff-1eee6e9c62262b01383b6285ecf1b423R10

Co-authored-by: Ian Foote <ian.foote@virtualstock.com>
@KatherineMichel

Copy link
Copy Markdown
Member

@meshy Thanks for this info. We will take a look at this.

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

Successfully merging this pull request may close these issues.

2 participants