Statistics
| Branch: | Tag: | Revision:

root / snf-astakos-app / astakos / quotaholder_app / migrations / 0008_reduce_bigint.py @ 41e92ef2

History | View | Annotate | Download (4.5 kB)

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

    
7
MAX = 2**63 - 1
8

    
9
class Migration(DataMigration):
10

    
11
    def forwards(self, orm):
12
        orm.Provision.objects.filter(quantity__gt=MAX).update(quantity=MAX)
13
        orm.Holding.objects.filter(usage_min__gt=MAX).update(usage_min=MAX)
14
        orm.Holding.objects.filter(usage_max__gt=MAX).update(usage_max=MAX)
15
        orm.Holding.objects.filter(limit__gt=MAX).update(limit=MAX)
16
        orm.ProvisionLog.objects.filter(delta_quantity__gt=MAX).\
17
            update(delta_quantity=MAX)
18
        orm.ProvisionLog.objects.filter(usage_min__gt=MAX).\
19
            update(usage_min=MAX)
20
        orm.ProvisionLog.objects.filter(usage_max__gt=MAX).\
21
            update(usage_max=MAX)
22
        orm.ProvisionLog.objects.filter(limit__gt=MAX).update(limit=MAX)
23

    
24
    def backwards(self, orm):
25
        "Write your backwards methods here."
26

    
27
    models = {
28
        'quotaholder_app.commission': {
29
            'Meta': {'object_name': 'Commission'},
30
            'clientkey': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
31
            'issue_datetime': ('django.db.models.fields.DateTimeField', [], {}),
32
            'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '4096'}),
33
            'serial': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
34
        },
35
        'quotaholder_app.holding': {
36
            'Meta': {'unique_together': "(('holder', 'source', 'resource'),)", 'object_name': 'Holding'},
37
            'holder': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'db_index': 'True'}),
38
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
39
            'limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
40
            'resource': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
41
            'source': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'null': 'True'}),
42
            'usage_max': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '0', 'max_digits': '38', 'decimal_places': '0'}),
43
            'usage_min': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '0', 'max_digits': '38', 'decimal_places': '0'})
44
        },
45
        'quotaholder_app.provision': {
46
            'Meta': {'object_name': 'Provision'},
47
            'holder': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'db_index': 'True'}),
48
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
49
            'quantity': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
50
            'resource': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
51
            'serial': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'provisions'", 'to': "orm['quotaholder_app.Commission']"}),
52
            'source': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'null': 'True'})
53
        },
54
        'quotaholder_app.provisionlog': {
55
            'Meta': {'object_name': 'ProvisionLog'},
56
            'delta_quantity': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
57
            'holder': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
58
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
59
            'issue_time': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
60
            'limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
61
            'log_time': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
62
            'name': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
63
            'reason': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
64
            'resource': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
65
            'serial': ('django.db.models.fields.BigIntegerField', [], {}),
66
            'source': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'null': 'True'}),
67
            'usage_max': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
68
            'usage_min': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'})
69
        }
70
    }
71

    
72
    complete_apps = ['quotaholder_app']
73
    symmetrical = True