Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

The existing migrations for allauth.openid were not compatible with

MySQL due to the use of an URLField with max_length above 255. The
issue has now been addressed but unfortunately at the cost of the
existing migrations for this app. Existing installations will have to
be dealt with manually (altering the "identity" column of
OpenIDAccount, deleting ghost migrations).
  • Loading branch information...
commit e8e3400af04a2da504192640da38767515e0f277 1 parent d9647cb
@pennersr pennersr authored
View
8 allauth/openid/admin.py
@@ -1,5 +1,4 @@
from django.contrib import admin
-from django.contrib.admin.widgets import AdminURLFieldWidget
from django.db import models
from django import forms
@@ -7,8 +6,11 @@
class OpenIDAccountAdmin(admin.ModelAdmin):
raw_id_fields = ('user',)
- formfield_overrides = {
- models.TextField: dict(widget=AdminURLFieldWidget)}
+
+ # If we ever switch back to TextField for storing OpenID identity
+ # URLs...
+ # formfield_overrides = {
+ # models.TextField: dict(widget=AdminURLFieldWidget)}
admin.site.register(OpenIDAccount, OpenIDAccountAdmin)
View
4 allauth/openid/migrations/0001_initial.py
@@ -11,7 +11,7 @@ def forwards(self, orm):
# Adding model 'OpenIDAccount'
db.create_table('openid_openidaccount', (
('socialaccount_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['socialaccount.SocialAccount'], unique=True, primary_key=True)),
- ('identity', self.gf('django.db.models.fields.URLField')(unique=True, max_length=1024)),
+ ('identity', self.gf('django.db.models.fields.URLField')(unique=True, max_length=255)),
))
db.send_create_signal('openid', ['OpenIDAccount'])
@@ -89,7 +89,7 @@ def backwards(self, orm):
},
'openid.openidaccount': {
'Meta': {'object_name': 'OpenIDAccount', '_ormbases': ['socialaccount.SocialAccount']},
- 'identity': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '1024'}),
+ 'identity': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '255'}),
'socialaccount_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['socialaccount.SocialAccount']", 'unique': 'True', 'primary_key': 'True'})
},
'openid.openidnonce': {
View
90 allauth/openid/migrations/0002_auto__chg_field_openidaccount_identity.py
@@ -1,90 +0,0 @@
-# encoding: utf-8
-import datetime
-from south.db import db
-from south.v2 import SchemaMigration
-from django.db import models
-
-class Migration(SchemaMigration):
-
- def forwards(self, orm):
-
- # Changing field 'OpenIDAccount.identity'
- db.alter_column('openid_openidaccount', 'identity', self.gf('django.db.models.fields.TextField')(unique=True))
-
-
- def backwards(self, orm):
-
- # Changing field 'OpenIDAccount.identity'
- db.alter_column('openid_openidaccount', 'identity', self.gf('django.db.models.fields.URLField')(max_length=1024, unique=True))
-
-
- models = {
- 'auth.group': {
- 'Meta': {'object_name': 'Group'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
- 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
- },
- 'auth.permission': {
- 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
- 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- },
- 'auth.user': {
- 'Meta': {'object_name': 'User'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
- 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
- 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
- },
- 'contenttypes.contenttype': {
- 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
- 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
- },
- 'openid.openidaccount': {
- 'Meta': {'object_name': 'OpenIDAccount', '_ormbases': ['socialaccount.SocialAccount']},
- 'identity': ('django.db.models.fields.TextField', [], {'unique': 'True'}),
- 'socialaccount_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['socialaccount.SocialAccount']", 'unique': 'True', 'primary_key': 'True'})
- },
- 'openid.openidnonce': {
- 'Meta': {'object_name': 'OpenIDNonce'},
- 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'salt': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'server_url': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'timestamp': ('django.db.models.fields.IntegerField', [], {})
- },
- 'openid.openidstore': {
- 'Meta': {'object_name': 'OpenIDStore'},
- 'assoc_type': ('django.db.models.fields.TextField', [], {}),
- 'handle': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'issued': ('django.db.models.fields.IntegerField', [], {}),
- 'lifetime': ('django.db.models.fields.IntegerField', [], {}),
- 'secret': ('django.db.models.fields.TextField', [], {}),
- 'server_url': ('django.db.models.fields.CharField', [], {'max_length': '255'})
- },
- 'socialaccount.socialaccount': {
- 'Meta': {'object_name': 'SocialAccount'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
- }
- }
-
- complete_apps = ['openid']
View
13 allauth/openid/models.py
@@ -6,9 +6,16 @@
class OpenIDAccount(SocialAccount):
# Ideally, URLField(max_length=1024, unique=True) would be used
# for identity. However, MySQL has a max_length limitation of 255
- # for URLField. So let's be pragmetic and switch to TextField...
- # TODO: Model field validation to ensure valid URLs
- identity = models.TextField(unique=True)
+ # for URLField. How about models.TextField(unique=True) then?
+ # Well, that won't work either for MySQL due to another bug[1]. So
+ # the only way out would be to drop the unique constraint, or
+ # switch to shorter identity URLs. Opted for the latter, as [2]
+ # suggests that identity URLs are supposed to be short anyway, at
+ # least for the old spec.
+ #
+ # [1] http://code.djangoproject.com/ticket/2495.
+ # [2] http://openid.net/specs/openid-authentication-1_1.html#limits
+ identity = models.URLField(max_length=255, unique=True)
def __unicode__(self):
return self.identity
Please sign in to comment.
Something went wrong with that request. Please try again.