Jan Dittberner
f085dab017
- refer to osuser instead of own home, uid and gid entries in mailboxes - add data and schema migrations
128 lines
8.1 KiB
Python
128 lines
8.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# pymode:lint_ignore=E501
|
|
from south.db import db
|
|
from south.v2 import SchemaMigration
|
|
|
|
|
|
class Migration(SchemaMigration):
|
|
|
|
def forwards(self, orm):
|
|
Mailbox = orm['managemails.Mailbox']
|
|
User = orm['osusers.User']
|
|
|
|
db.start_transaction()
|
|
|
|
db.add_column(
|
|
u'managemails_mailbox', 'osuser_id',
|
|
self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=0))
|
|
|
|
for mailbox in Mailbox.objects.all():
|
|
user = User.objects.get(uid=mailbox.uid)
|
|
mailbox.osuser = user
|
|
mailbox.save()
|
|
|
|
db.alter_column(
|
|
u'managemails_mailbox', 'osuser_id',
|
|
self.gf('django.db.models.fields.related.ForeignKey')(to=orm['osusers.User']))
|
|
|
|
# Deleting field 'Mailbox.home'
|
|
db.delete_column(u'managemails_mailbox', 'home')
|
|
|
|
# Deleting field 'Mailbox.gid'
|
|
db.delete_column(u'managemails_mailbox', 'gid')
|
|
|
|
# Deleting field 'Mailbox.uid'
|
|
db.delete_column(u'managemails_mailbox', 'uid')
|
|
|
|
db.commit_transaction()
|
|
|
|
def backwards(self, orm):
|
|
raise RuntimeError("Cannot reverse this migration.")
|
|
|
|
models = {
|
|
u'managemails.mailaddress': {
|
|
'Meta': {'unique_together': "(('localpart', 'domain'),)", 'object_name': 'MailAddress'},
|
|
'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
|
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
|
|
'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['managemails.MailDomain']"}),
|
|
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
|
'localpart': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
|
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'})
|
|
},
|
|
u'managemails.mailaddressforward': {
|
|
'Meta': {'unique_together': "(('mailaddress', 'target'),)", 'object_name': 'MailAddressForward'},
|
|
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
|
|
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
|
'mailaddress': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['managemails.MailAddress']"}),
|
|
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
|
|
'target': ('django.db.models.fields.EmailField', [], {'max_length': '254'})
|
|
},
|
|
u'managemails.mailaddressmailbox': {
|
|
'Meta': {'unique_together': "(('mailaddress', 'mailbox'),)", 'object_name': 'MailAddressMailbox'},
|
|
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
|
|
'mailaddress': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['managemails.MailAddress']", 'unique': 'True', 'primary_key': 'True'}),
|
|
'mailbox': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['managemails.Mailbox']"}),
|
|
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'})
|
|
},
|
|
u'managemails.mailbox': {
|
|
'Meta': {'object_name': 'Mailbox'},
|
|
'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
|
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
|
|
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
|
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
|
|
'osuser': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['osusers.User']"}),
|
|
'password': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
|
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}),
|
|
'uid': ('django.db.models.fields.PositiveSmallIntegerField', [], {}),
|
|
},
|
|
u'managemails.maildomain': {
|
|
'Meta': {'object_name': 'MailDomain'},
|
|
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
|
|
'domain': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}),
|
|
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
|
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'})
|
|
},
|
|
u'osusers.additionalgroup': {
|
|
'Meta': {'unique_together': "(('user', 'group'),)", 'object_name': 'AdditionalGroup'},
|
|
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
|
|
'group': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['osusers.Group']"}),
|
|
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
|
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
|
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['osusers.User']"})
|
|
},
|
|
u'osusers.group': {
|
|
'Meta': {'object_name': 'Group'},
|
|
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
|
|
'descr': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
|
'gid': ('django.db.models.fields.PositiveSmallIntegerField', [], {'unique': 'True', 'primary_key': 'True'}),
|
|
'groupname': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '16'}),
|
|
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
|
|
'passwd': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'})
|
|
},
|
|
u'osusers.shadow': {
|
|
'Meta': {'object_name': 'Shadow'},
|
|
'changedays': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
|
|
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
|
|
'expiredays': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
|
|
'gracedays': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
|
|
'inactdays': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
|
|
'maxage': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
|
|
'minage': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
|
|
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
|
|
'passwd': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
|
'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['osusers.User']", 'unique': 'True', 'primary_key': 'True'})
|
|
},
|
|
u'osusers.user': {
|
|
'Meta': {'object_name': 'User'},
|
|
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
|
|
'gecos': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
|
|
'group': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['osusers.Group']"}),
|
|
'homedir': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
|
|
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
|
|
'shell': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
|
|
'uid': ('django.db.models.fields.PositiveSmallIntegerField', [], {'unique': 'True', 'primary_key': 'True'}),
|
|
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'})
|
|
}
|
|
}
|
|
|
|
complete_apps = ['osusers', 'managemails']
|