Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / userdata / migrations / 0003_auto__chg_field_publickeypair_fingerprint__chg_field_publickeypair_use.py @ a9d34f3b

History | View | Annotate | Download (2.3 kB)

1
# encoding: utf-8
2
import datetime
3
from south.db import db
4
from south.v2 import SchemaMigration
5
from django.db import models
6

    
7
class Migration(SchemaMigration):
8

    
9
    needed_by = (
10
        ("db", "0027_auto__del_legacy_fields"),
11
    )
12

    
13
    def forwards(self, orm):
14

    
15
        # Changing field 'PublicKeyPair.fingerprint'
16
        db.alter_column('userdata_publickeypair', 'fingerprint', self.gf('django.db.models.fields.CharField')(max_length=100, blank=True))
17

    
18
        try:
19
            db.drop_foreign_key('userdata_publickeypair', 'user_id')
20
        except:
21
            pass
22
        # Renaming column for 'PublicKeyPair.user' to match new field type.
23
        db.rename_column('userdata_publickeypair', 'user_id', 'user')
24
        # Changing field 'PublicKeyPair.user'
25
        db.alter_column('userdata_publickeypair', 'user', self.gf('django.db.models.fields.CharField')(max_length=100))
26

    
27
        try:
28
            # Removing index on 'PublicKeyPair', fields ['user']
29
            db.delete_index('userdata_publickeypair', ['user_id'])
30
        except:
31
            pass
32

    
33

    
34
    def backwards(self, orm):
35

    
36
        # Changing field 'PublicKeyPair.fingerprint'
37
        db.alter_column('userdata_publickeypair', 'fingerprint', self.gf('django.db.models.fields.CharField')(max_length=100))
38

    
39
        # Renaming column for 'PublicKeyPair.user' to match new field type.
40
        db.rename_column('userdata_publickeypair', 'user', 'user_id')
41
        # Changing field 'PublicKeyPair.user'
42
        db.alter_column('userdata_publickeypair', 'user_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['db.SynnefoUser']))
43

    
44
        # Adding index on 'PublicKeyPair', fields ['user']
45
        db.create_index('userdata_publickeypair', ['user_id'])
46

    
47

    
48
    models = {
49
        'userdata.publickeypair': {
50
            'Meta': {'object_name': 'PublicKeyPair'},
51
            'content': ('django.db.models.fields.TextField', [], {}),
52
            'fingerprint': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
53
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
54
            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
55
            'user': ('django.db.models.fields.CharField', [], {'max_length': '100'})
56
        }
57
    }
58

    
59
    complete_apps = ['userdata']