Commit 31cd94e7 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

quotaholder: Revert migration of log timestamps

Because migrating the timestamp fields of model ProvisionLog from string
to datetime takes too long, we keep them in string format.

Alter migrations 0005 through 0007 introduced in commit 164e64d.
parent b829f265
......@@ -47,6 +47,10 @@ from astakos.quotaholder_app.models import (
Holding, Commission, Provision, ProvisionLog)
def format_datetime(d):
return d.strftime('%Y-%m-%dT%H:%M:%S.%f')[:24]
def get_quota(holders=None, sources=None, resources=None):
holdings = Holding.objects.all()
......@@ -189,8 +193,8 @@ def _log_provision(commission, provision, holding, log_datetime, reason):
'usage_min': holding.usage_min,
'usage_max': holding.usage_max,
'delta_quantity': provision.quantity,
'issue_datetime': commission.issue_datetime,
'log_datetime': log_datetime,
'issue_time': format_datetime(commission.issue_datetime),
'log_time': format_datetime(log_datetime),
'reason': reason,
}
......
......@@ -11,24 +11,12 @@ class Migration(SchemaMigration):
# Adding field 'Commission.issue_datetime'
db.add_column('quotaholder_app_commission', 'issue_datetime', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2013, 1, 1, 0, 0, 0)), keep_default=False)
# Adding field 'ProvisionLog.issue_datetime'
db.add_column('quotaholder_app_provisionlog', 'issue_datetime', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2013, 1, 1, 0, 0, 0)), keep_default=False)
# Adding field 'ProvisionLog.log_datetime'
db.add_column('quotaholder_app_provisionlog', 'log_datetime', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2013, 1, 1, 0, 0, 0)), keep_default=False)
def backwards(self, orm):
# Deleting field 'Commission.issue_datetime'
db.delete_column('quotaholder_app_commission', 'issue_datetime')
# Deleting field 'ProvisionLog.issue_datetime'
db.delete_column('quotaholder_app_provisionlog', 'issue_datetime')
# Deleting field 'ProvisionLog.log_datetime'
db.delete_column('quotaholder_app_provisionlog', 'log_datetime')
models = {
'quotaholder_app.commission': {
......@@ -63,10 +51,8 @@ class Migration(SchemaMigration):
'delta_quantity': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
'holder': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'issue_datetime': ('django.db.models.fields.DateTimeField', [], {}),
'issue_time': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
'log_datetime': ('django.db.models.fields.DateTimeField', [], {}),
'log_time': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'reason': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
......
......@@ -4,7 +4,6 @@ from south.db import db
from south.v2 import DataMigration
from django.db import models
class Migration(DataMigration):
def forwards(self, orm):
......@@ -16,14 +15,6 @@ class Migration(DataMigration):
commission.issue_datetime = dt
commission.save()
plogs = orm.ProvisionLog.objects.all()
for plog in plogs:
issue_dt = parse(plog.issue_time)
plog.issue_datetime = issue_dt
log_dt = parse(plog.log_time)
plog.log_datetime = log_dt
plog.save()
def backwards(self, orm):
"Write your backwards methods here."
......@@ -61,10 +52,8 @@ class Migration(DataMigration):
'delta_quantity': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
'holder': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'issue_datetime': ('django.db.models.fields.DateTimeField', [], {}),
'issue_time': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
'log_datetime': ('django.db.models.fields.DateTimeField', [], {}),
'log_time': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'reason': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
......
......@@ -11,24 +11,12 @@ class Migration(SchemaMigration):
# Deleting field 'Commission.issue_time'
db.delete_column('quotaholder_app_commission', 'issue_time')
# Deleting field 'ProvisionLog.log_time'
db.delete_column('quotaholder_app_provisionlog', 'log_time')
# Deleting field 'ProvisionLog.issue_time'
db.delete_column('quotaholder_app_provisionlog', 'issue_time')
def backwards(self, orm):
# User chose to not deal with backwards NULL issues for 'Commission.issue_time'
raise RuntimeError("Cannot reverse this migration. 'Commission.issue_time' and its values cannot be restored.")
# User chose to not deal with backwards NULL issues for 'ProvisionLog.log_time'
raise RuntimeError("Cannot reverse this migration. 'ProvisionLog.log_time' and its values cannot be restored.")
# User chose to not deal with backwards NULL issues for 'ProvisionLog.issue_time'
raise RuntimeError("Cannot reverse this migration. 'ProvisionLog.issue_time' and its values cannot be restored.")
models = {
'quotaholder_app.commission': {
......@@ -62,9 +50,9 @@ class Migration(SchemaMigration):
'delta_quantity': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
'holder': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'issue_datetime': ('django.db.models.fields.DateTimeField', [], {}),
'issue_time': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
'log_datetime': ('django.db.models.fields.DateTimeField', [], {}),
'log_time': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'reason': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
'resource': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
......
......@@ -92,8 +92,8 @@ class ProvisionLog(Model):
serial = BigIntegerField()
name = CharField(max_length=4096)
issue_datetime = DateTimeField()
log_datetime = DateTimeField()
issue_time = CharField(max_length=4096)
log_time = CharField(max_length=4096)
holder = CharField(max_length=4096)
source = CharField(max_length=4096, null=True)
resource = CharField(max_length=4096)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment