Repository: django-wiki/django-wiki

Issue:
Initial installation fails with 'django.db.utils.ProgrammingError: relation "notify_subscription" does not exist'
The error is that the migrations for 'wiki' do not depend on the 'django_notify' app.

In particular, you get this error on wiki:0007_auto__add_articlesubscription. It just needs to add:

```
depends_on = [("django_notify", "0004")]
```



Discussion:
Thanks! I think I see a general, more odd/wrong behaviour here. All of the plugins have `Meta.app_label` set because that creates a nicer db layout and also because the apps have very generic names. For instance as introduced in this commit:

https://github.com/benjaoming/django-wiki/commit/8a7a3e758cf7c09e5516f62ae75994fdbdd750ab

However, apparently setting app_label to "wiki" has caused South to put plugin migrations in `wiki/migrations` which is not really the intention. Because then the tables will be created even if the plugins are not installed + as you report, then it spawns a dependency on django_notify.

I guess I need a remedy to make South put the migrations with their respectiv apps.. but I'm wondering if this means getting rid of the app_label. And in that case, renaming tables would be terribly incompatible with running deployments :)

Seeing the response to this bug report makes me worry that using app_label is completely wrong:

http://south.aeracode.org/ticket/1128

It could well be that all the plugin models should start specifying `Meta.db_table` in order to have wiki_ prefixes.

https://docs.djangoproject.com/en/dev/ref/models/options/#db-table

I found out that if I set the INSTALLED_APPS in the right order, I don't have this problem. But the correct solution is still to use 'depends_on' in the migration.

I think as long as the wiki plugins are within the wiki codebase, there is no problem using 'app_label'. That ticket was about someone using an 'app_label' for models within a completely separate library.

I'm going to fix this by completely breaking stuff instead.

The old package django_notify supplied in `wiki` was supposed to be standalone, but a name clash ruined that. Instead, I've renamed everything and put it here:

https://github.com/benjaoming/django-nyt

Docs are there from day 1 :)

Now we just need to refactor some stuff in django-wiki and put django-nyt on pypi.

Hello -
I still seem to be having an issue with the `wiki:0007_auto__add_articlesubscription` migration regardless of the order...  The `django_notify` library installed from `pip` does not even have any models...  I'm sure I'm missing something obvious here, but any help is appreciated.

Perhaps I need to update that migration to look for `nyt_subscription` instead of `notify_subscription`?

---

UPDATE:
Sorry for posting just prior to resolving my issue.  But, my guess in question form above was indeed correct.  I updated the `wiki:0007_auto__add_articlesubscription` migration file to replace all `django_notify` instances with `django_nyt` and all `notify_` instances to `nyt`,

@dannybrowne86 thanks for pointing this out, we should indeed update the migrations for the 0.0.24 release.


Resolving patch:
diff --git a/wiki/plugins/notifications/south_migrations/0001_initial.py b/wiki/plugins/notifications/south_migrations/0001_initial.py
--- a/wiki/plugins/notifications/south_migrations/0001_initial.py
+++ b/wiki/plugins/notifications/south_migrations/0001_initial.py
@@ -13,7 +13,7 @@
     User = get_user_model()
 
 user_orm_label = '%s.%s' % (User._meta.app_label, User._meta.object_name)
-user_model_label = '%s.%s' % (User._meta.app_label, User._meta.module_name) 
+user_model_label = '%s.%s' % (User._meta.app_label, User._meta.module_name)
 
 
 class Migration(SchemaMigration):
@@ -21,7 +21,7 @@ class Migration(SchemaMigration):
     def forwards(self, orm):
         # Adding model 'ArticleSubscription'
         db.create_table('notifications_articlesubscription', (
-            ('subscription_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['django_notify.Subscription'], unique=True)),
+            ('subscription_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['django_nyt.Subscription'], unique=True)),
             ('articleplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['wiki.ArticlePlugin'], unique=True, primary_key=True)),
         ))
         db.send_create_signal('notifications', ['ArticleSubscription'])
@@ -69,30 +69,30 @@ def backwards(self, orm):
             'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
             'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
         },
-        'django_notify.notificationtype': {
-            'Meta': {'object_name': 'NotificationType', 'db_table': "'notify_notificationtype'"},
+        'django_nyt.notificationtype': {
+            'Meta': {'object_name': 'NotificationType', 'db_table': "'nyt_notificationtype'"},
             'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']", 'null': 'True', 'blank': 'True'}),
             'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'primary_key': 'True'}),
             'label': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'})
         },
-        'django_notify.settings': {
-            'Meta': {'object_name': 'Settings', 'db_table': "'notify_settings'"},
+        'django_nyt.settings': {
+            'Meta': {'object_name': 'Settings', 'db_table': "'nyt_settings'"},
             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
             'interval': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
             'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']" % user_orm_label})
         },
-        'django_notify.subscription': {
-            'Meta': {'object_name': 'Subscription', 'db_table': "'notify_subscription'"},
+        'django_nyt.subscription': {
+            'Meta': {'object_name': 'Subscription', 'db_table': "'nyt_subscription'"},
             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'notification_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_notify.NotificationType']"}),
+            'notification_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_nyt.NotificationType']"}),
             'object_id': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
             'send_emails': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
-            'settings': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_notify.Settings']"})
+            'settings': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_nyt.Settings']"})
         },
         'notifications.articlesubscription': {
-            'Meta': {'object_name': 'ArticleSubscription', '_ormbases': ['wiki.ArticlePlugin', 'django_notify.Subscription']},
+            'Meta': {'object_name': 'ArticleSubscription', '_ormbases': ['wiki.ArticlePlugin', 'django_nyt.Subscription']},
             'articleplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['wiki.ArticlePlugin']", 'unique': 'True', 'primary_key': 'True'}),
-            'subscription_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['django_notify.Subscription']", 'unique': 'True'})
+            'subscription_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['django_nyt.Subscription']", 'unique': 'True'})
         },
         'wiki.article': {
             'Meta': {'object_name': 'Article'},
diff --git a/wiki/south_migrations/0007_auto__add_articlesubscription.py b/wiki/south_migrations/0007_auto__add_articlesubscription.py
--- a/wiki/south_migrations/0007_auto__add_articlesubscription.py
+++ b/wiki/south_migrations/0007_auto__add_articlesubscription.py
@@ -13,7 +13,7 @@
     User = get_user_model()
 
 user_orm_label = '%s.%s' % (User._meta.app_label, User._meta.object_name)
-user_model_label = '%s.%s' % (User._meta.app_label, User._meta.module_name) 
+user_model_label = '%s.%s' % (User._meta.app_label, User._meta.module_name)
 
 
 class Migration(SchemaMigration):
@@ -21,7 +21,7 @@ class Migration(SchemaMigration):
     def forwards(self, orm):
         # Adding model 'ArticleSubscription'
         db.create_table('wiki_articlesubscription', (
-            ('subscription_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['django_notify.Subscription'], unique=True)),
+            ('subscription_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['django_nyt.Subscription'], unique=True)),
             ('articleplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['wiki.ArticlePlugin'], unique=True, primary_key=True)),
         ))
         db.send_create_signal('wiki', ['ArticleSubscription'])
@@ -69,25 +69,25 @@ def backwards(self, orm):
             'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
             'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
         },
-        'django_notify.notificationtype': {
-            'Meta': {'object_name': 'NotificationType', 'db_table': "'notify_notificationtype'"},
+        'django_nyt.notificationtype': {
+            'Meta': {'object_name': 'NotificationType', 'db_table': "'nyt_notificationtype'"},
             'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']", 'null': 'True', 'blank': 'True'}),
             'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'primary_key': 'True'}),
             'label': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'})
         },
-        'django_notify.settings': {
-            'Meta': {'object_name': 'Settings', 'db_table': "'notify_settings'"},
+        'django_nyt.settings': {
+            'Meta': {'object_name': 'Settings', 'db_table': "'nyt_settings'"},
             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
             'interval': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
             'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']" % user_orm_label})
         },
-        'django_notify.subscription': {
-            'Meta': {'object_name': 'Subscription', 'db_table': "'notify_subscription'"},
+        'django_nyt.subscription': {
+            'Meta': {'object_name': 'Subscription', 'db_table': "'nyt_subscription'"},
             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'notification_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_notify.NotificationType']"}),
+            'notification_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_nyt.NotificationType']"}),
             'object_id': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
             'send_emails': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
-            'settings': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_notify.Settings']"})
+            'settings': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_nyt.Settings']"})
         },
         'sites.site': {
             'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"},
@@ -142,9 +142,9 @@ def backwards(self, orm):
             'user_message': ('django.db.models.fields.TextField', [], {'blank': 'True'})
         },
         'wiki.articlesubscription': {
-            'Meta': {'object_name': 'ArticleSubscription', '_ormbases': ['wiki.ArticlePlugin', 'django_notify.Subscription']},
+            'Meta': {'object_name': 'ArticleSubscription', '_ormbases': ['wiki.ArticlePlugin', 'django_nyt.Subscription']},
             'articleplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['wiki.ArticlePlugin']", 'unique': 'True', 'primary_key': 'True'}),
-            'subscription_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['django_notify.Subscription']", 'unique': 'True'})
+            'subscription_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['django_nyt.Subscription']", 'unique': 'True'})
         },
         'wiki.attachment': {
             'Meta': {'object_name': 'Attachment', '_ormbases': ['wiki.ReusablePlugin']},


Test patch: