Commit 93748cd2 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Fix migrations

parent b4ce56b2
......@@ -4,62 +4,45 @@ from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'GroupKind'
db.create_table('im_groupkind', (
('id', self.gf(
'django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')
(unique=True, max_length=255, db_index=True)),
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255, db_index=True)),
))
db.send_create_signal('im', ['GroupKind'])
# Adding model 'AstakosGroup'
db.create_table('im_astakosgroup', (
('group_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['auth.Group'], unique=True, primary_key=True)),
('kind', self.gf('django.db.models.fields.related.ForeignKey')
(to=orm['im.GroupKind'])),
('kind', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.GroupKind'])),
('desc', self.gf('django.db.models.fields.TextField')(null=True)),
('creation_date', self.gf('django.db.models.fields.DateTimeField')
(default=datetime.datetime(2012, 8, 3, 11, 26, 47, 642626))),
('issue_date', self.gf(
'django.db.models.fields.DateTimeField')(null=True)),
('expiration_date', self.gf(
'django.db.models.fields.DateTimeField')(null=True)),
('moderation_enabled', self.gf(
'django.db.models.fields.BooleanField')(default=False)),
('approval_date', self.gf('django.db.models.fields.DateTimeField')
(null=True, blank=True)),
('estimated_participants', self.gf(
'django.db.models.fields.PositiveIntegerField')(null=True)),
('creation_date', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2012, 12, 4, 9, 50, 9, 334623))),
('issue_date', self.gf('django.db.models.fields.DateTimeField')(null=True)),
('expiration_date', self.gf('django.db.models.fields.DateTimeField')(null=True)),
('moderation_enabled', self.gf('django.db.models.fields.BooleanField')(default=False)),
('approval_date', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
('estimated_participants', self.gf('django.db.models.fields.PositiveIntegerField')(null=True)),
))
db.send_create_signal('im', ['AstakosGroup'])
# Adding model 'ResourceMetadata'
db.create_table('im_resourcemetadata', (
('id', self.gf(
'django.db.models.fields.AutoField')(primary_key=True)),
('key', self.gf('django.db.models.fields.CharField')
(unique=True, max_length=255, db_index=True)),
('value', self.gf(
'django.db.models.fields.CharField')(max_length=255)),
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('key', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255, db_index=True)),
('value', self.gf('django.db.models.fields.CharField')(max_length=255)),
))
db.send_create_signal('im', ['ResourceMetadata'])
# Adding model 'AstakosGroupQuota'
db.create_table('im_astakosgroupquota', (
('id', self.gf(
'django.db.models.fields.AutoField')(primary_key=True)),
('limit', self.gf(
'django.db.models.fields.PositiveIntegerField')()),
('resource', self.gf('django.db.models.fields.related.ForeignKey')
(to=orm['im.Resource'])),
('group', self.gf('django.db.models.fields.related.ForeignKey')
(to=orm['im.AstakosGroup'], blank=True)),
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('limit', self.gf('django.db.models.fields.PositiveIntegerField')()),
('resource', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.Resource'])),
('group', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.AstakosGroup'], blank=True)),
))
db.send_create_signal('im', ['AstakosGroupQuota'])
......@@ -68,38 +51,27 @@ class Migration(SchemaMigration):
# Adding model 'Resource'
db.create_table('im_resource', (
('id', self.gf(
'django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')
(unique=True, max_length=255, db_index=True)),
('service', self.gf('django.db.models.fields.related.ForeignKey')
(to=orm['im.Service'])),
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255, db_index=True)),
('service', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.Service'])),
))
db.send_create_signal('im', ['Resource'])
# Adding M2M table for field meta on 'Resource'
db.create_table('im_resource_meta', (
('id', models.AutoField(
verbose_name='ID', primary_key=True, auto_created=True)),
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('resource', models.ForeignKey(orm['im.resource'], null=False)),
('resourcemetadata', models.ForeignKey(orm[
'im.resourcemetadata'], null=False))
('resourcemetadata', models.ForeignKey(orm['im.resourcemetadata'], null=False))
))
db.create_unique(
'im_resource_meta', ['resource_id', 'resourcemetadata_id'])
db.create_unique('im_resource_meta', ['resource_id', 'resourcemetadata_id'])
# Adding model 'Membership'
db.create_table('im_membership', (
('id', self.gf(
'django.db.models.fields.AutoField')(primary_key=True)),
('person', self.gf('django.db.models.fields.related.ForeignKey')
(to=orm['im.AstakosUser'])),
('group', self.gf('django.db.models.fields.related.ForeignKey')
(to=orm['im.AstakosGroup'])),
('date_requested', self.gf('django.db.models.fields.DateField')
(default=datetime.datetime(2012, 8, 3, 11, 26, 47, 646518))),
('date_joined', self.gf('django.db.models.fields.DateField')
(null=True, db_index=True)),
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('person', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.AstakosUser'])),
('group', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.AstakosGroup'])),
('date_requested', self.gf('django.db.models.fields.DateField')(default=datetime.datetime(2012, 12, 4, 9, 50, 9, 338510))),
('date_joined', self.gf('django.db.models.fields.DateField')(null=True, db_index=True)),
))
db.send_create_signal('im', ['Membership'])
......@@ -108,14 +80,10 @@ class Migration(SchemaMigration):
# Adding model 'AstakosUserQuota'
db.create_table('im_astakosuserquota', (
('id', self.gf(
'django.db.models.fields.AutoField')(primary_key=True)),
('limit', self.gf(
'django.db.models.fields.PositiveIntegerField')()),
('resource', self.gf('django.db.models.fields.related.ForeignKey')
(to=orm['im.Resource'])),
('user', self.gf('django.db.models.fields.related.ForeignKey')
(to=orm['im.AstakosUser'])),
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('limit', self.gf('django.db.models.fields.PositiveIntegerField')()),
('resource', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.Resource'])),
('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.AstakosUser'])),
))
db.send_create_signal('im', ['AstakosUserQuota'])
......@@ -127,18 +95,15 @@ class Migration(SchemaMigration):
# Adding M2M table for field owner on 'AstakosUser'
db.create_table('im_astakosuser_owner', (
('id', models.AutoField(
verbose_name='ID', primary_key=True, auto_created=True)),
('astakosuser', models.ForeignKey(orm[
'im.astakosuser'], null=False)),
('astakosgroup', models.ForeignKey(orm[
'im.astakosgroup'], null=False))
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('astakosuser', models.ForeignKey(orm['im.astakosuser'], null=False)),
('astakosgroup', models.ForeignKey(orm['im.astakosgroup'], null=False))
))
db.create_unique(
'im_astakosuser_owner', ['astakosuser_id', 'astakosgroup_id'])
db.create_unique('im_astakosuser_owner', ['astakosuser_id', 'astakosgroup_id'])
def backwards(self, orm):
def backwards(self, orm):
# Removing index on 'Service', fields ['name']
db.delete_index('im_service', ['name'])
......@@ -178,6 +143,7 @@ class Migration(SchemaMigration):
# Removing M2M table for field owner on 'AstakosUser'
db.delete_table('im_astakosuser_owner')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
......
......@@ -2,16 +2,76 @@
from south.v2 import DataMigration
from astakos.im.settings import SERVICES
import logging
logger = logging.getLogger(__name__)
class Migration(DataMigration):
def forwards(self, orm):
"Obsolete migration."
return
"Write your forwards methods here."
try:
default = orm.AstakosGroup.objects.get(name='default')
except orm.AstakosGroup.DoesNotExist:
return
def create_policies(args):
sn, dict = args
url = dict.get('url')
resources = dict.get('resources') or ()
s, created = orm.Service.objects.get_or_create(
name=sn,
defaults={'url': url}
)
for r in resources:
try:
rn = r.pop('name', '')
uplimit = r.pop('uplimit', None)
r, created = orm.Resource.objects.get_or_create(
service=s,
name=rn,
defaults=r)
except Exception, e:
print "Cannot create resource ", rn
continue
else:
q, created = orm.AstakosGroupQuota.objects.get_or_create(
group=default,
resource=r,
defaults={
'uplimit':uplimit,
}
)
map(create_policies, SERVICES.iteritems())
def backwards(self, orm):
"Obsolete migration."
return
try:
default = orm.AstakosGroup.objects.get(name='default')
except orm.AstakosGroup.DoesNotExist:
return
def destroy_policies(args):
sn, dict = args
url = dict.get('url')
resources = dict.get('resources') or ()
for r in resources:
rn = r.get('name', '')
try:
q = orm.AstakosGroupQuota.objects.get(
group=default,
resource__name=rn)
q.delete()
q = orm.Resource.objects.get(service__name=sn, name=rn)
q.delete()
except Exception, e:
print "Cannot create resource ", rn
continue
map(destroy_policies, SERVICES.iteritems())
models = {
'auth.group': {
......
......@@ -4,19 +4,20 @@ from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'AstakosGroup.homepage'
db.add_column('im_astakosgroup', 'homepage', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True), keep_default=False)
def backwards(self, orm):
def backwards(self, orm):
# Deleting field 'AstakosGroup.homepage'
db.delete_column('im_astakosgroup', 'homepage')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
......
......@@ -4,20 +4,19 @@ from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Changing field 'AstakosGroup.homepage'
db.alter_column('im_astakosgroup', 'homepage', self.gf(
'django.db.models.fields.URLField')(max_length=255, null=True))
db.alter_column('im_astakosgroup', 'homepage', self.gf('django.db.models.fields.URLField')(max_length=255, null=True))
def backwards(self, orm):
def backwards(self, orm):
# Changing field 'AstakosGroup.homepage'
db.alter_column('im_astakosgroup', 'homepage', self.gf(
'django.db.models.fields.CharField')(max_length=255, null=True))
db.alter_column('im_astakosgroup', 'homepage', self.gf('django.db.models.fields.CharField')(max_length=255, null=True))
models = {
'auth.group': {
......
......@@ -4,25 +4,26 @@ from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'AstakosGroupQuota.uplimit'
db.add_column('im_astakosgroupquota', 'uplimit', self.gf('django.db.models.fields.BigIntegerField')(null=True), keep_default=False)
# Adding field 'AstakosUserQuota.uplimit'
db.add_column('im_astakosuserquota', 'uplimit', self.gf('django.db.models.fields.BigIntegerField')(null=True), keep_default=False)
def backwards(self, orm):
def backwards(self, orm):
# Deleting field 'AstakosGroupQuota.uplimit'
db.delete_column('im_astakosgroupquota', 'uplimit')
# Deleting field 'AstakosUserQuota.uplimit'
db.delete_column('im_astakosuserquota', 'uplimit')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
......
......@@ -4,28 +4,25 @@ from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Changing field 'AstakosGroupQuota.limit'
db.alter_column('im_astakosgroupquota', 'limit', self.gf(
'django.db.models.fields.PositiveIntegerField')(null=True))
db.alter_column('im_astakosgroupquota', 'limit', self.gf('django.db.models.fields.PositiveIntegerField')(null=True))
# Changing field 'AstakosUserQuota.limit'
db.alter_column('im_astakosuserquota', 'limit', self.gf(
'django.db.models.fields.PositiveIntegerField')(null=True))
db.alter_column('im_astakosuserquota', 'limit', self.gf('django.db.models.fields.PositiveIntegerField')(null=True))
def backwards(self, orm):
pass
# # Changing field 'AstakosGroupQuota.limit'
# db.alter_column('im_astakosgroupquota', 'limit', self.gf(
# 'django.db.models.fields.PositiveIntegerField')(default=None))
#
# # Changing field 'AstakosUserQuota.limit'
# db.alter_column('im_astakosuserquota', 'limit', self.gf(
# 'django.db.models.fields.PositiveIntegerField')(default=None))
# Changing field 'AstakosGroupQuota.limit'
db.alter_column('im_astakosgroupquota', 'limit', self.gf('django.db.models.fields.PositiveIntegerField')(default=None))
# Changing field 'AstakosUserQuota.limit'
db.alter_column('im_astakosuserquota', 'limit', self.gf('django.db.models.fields.PositiveIntegerField')(default=None))
models = {
'auth.group': {
......
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import DataMigration
from south.v2 import SchemaMigration
from django.db import models
class Migration(DataMigration):
class Migration(SchemaMigration):
def forwards(self, orm):
"Write your forwards methods here."
......@@ -13,8 +12,10 @@ class Migration(DataMigration):
u.email = u.email.lower()
u.save()
def backwards(self, orm):
"Write your backwards methods here."
pass
models = {
'auth.group': {
......
......@@ -4,25 +4,26 @@ from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Resource.desc'
db.add_column('im_resource', 'desc', self.gf('django.db.models.fields.TextField')(null=True), keep_default=False)
# Adding field 'Resource.unit'
db.add_column('im_resource', 'unit', self.gf('django.db.models.fields.CharField')(max_length=255, null=True), keep_default=False)
def backwards(self, orm):
def backwards(self, orm):
# Deleting field 'Resource.desc'
db.delete_column('im_resource', 'desc')
# Deleting field 'Resource.unit'
db.delete_column('im_resource', 'unit')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
......
......@@ -8,14 +8,6 @@ class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'SessionCatalog'
db.create_table('im_sessioncatalog', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('session_key', self.gf('django.db.models.fields.CharField')(max_length=40)),
('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='sessions', null=True, to=orm['im.AstakosUser'])),
))
db.send_create_signal('im', ['SessionCatalog'])
# Adding model 'PendingThirdPartyUser'
db.create_table('im_pendingthirdpartyuser', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
......@@ -32,18 +24,26 @@ class Migration(SchemaMigration):
# Adding unique constraint on 'PendingThirdPartyUser', fields ['provider', 'third_party_identifier']
db.create_unique('im_pendingthirdpartyuser', ['provider', 'third_party_identifier'])
# Adding model 'SessionCatalog'
db.create_table('im_sessioncatalog', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('session_key', self.gf('django.db.models.fields.CharField')(max_length=40)),
('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='sessions', null=True, to=orm['im.AstakosUser'])),
))
db.send_create_signal('im', ['SessionCatalog'])
def backwards(self, orm):
# Removing unique constraint on 'PendingThirdPartyUser', fields ['provider', 'third_party_identifier']
db.delete_unique('im_pendingthirdpartyuser', ['provider', 'third_party_identifier'])
# Deleting model 'SessionCatalog'
db.delete_table('im_sessioncatalog')
# Deleting model 'PendingThirdPartyUser'
db.delete_table('im_pendingthirdpartyuser')
# Deleting model 'SessionCatalog'
db.delete_table('im_sessioncatalog')
models = {
'auth.group': {
......
......@@ -45,7 +45,7 @@ class Migration(SchemaMigration):
db.delete_table('im_astakosuserauthprovider')
# Changing field 'AstakosUser.affiliation'
db.alter_column('im_astakosuser', 'affiliation', self.gf('django.db.models.fields.CharField')(default='', max_length=255))
db.alter_column('im_astakosuser', 'affiliation', self.gf('django.db.models.fields.CharField')(default='', max_length=255, null=True))
# Changing field 'AstakosUser.provider'
db.alter_column('im_astakosuser', 'provider', self.gf('django.db.models.fields.CharField')(default='', max_length=255))
......
......@@ -27,6 +27,7 @@ class Migration(DataMigration):
user.save()
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
......@@ -35,7 +36,7 @@ class Migration(DataMigration):
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': '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'}),
......@@ -48,9 +49,9 @@ class Migration(DataMigration):
'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', 'blank': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': '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'}),
......@@ -58,7 +59,7 @@ class Migration(DataMigration):
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'contenttypes.contenttype': {
'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'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'}),
......@@ -72,24 +73,51 @@ class Migration(DataMigration):
},
'im.approvalterms': {
'Meta': {'object_name': 'ApprovalTerms'},
'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 11, 29, 13, 58, 8, 395739)', 'db_index': 'True'}),
'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 4, 11, 35, 14, 103893)', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'location': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
'im.astakosgroup': {
'Meta': {'object_name': 'AstakosGroup', '_ormbases': ['auth.Group']},
'approval_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 4, 11, 35, 14, 96747)'}),
'desc': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'estimated_participants': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
'expiration_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'group_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.Group']", 'unique': 'True', 'primary_key': 'True'}),