4 changed files with 90 additions and 34 deletions
-
19abonapp/migrations/0005_current_tariff.py
-
2abonapp/models.py
-
102statistics/migrations/0003_auto_20180814_1921.py
-
1statistics/models.py
@ -0,0 +1,19 @@ |
|||
# Generated by Django 2.1 on 2018-09-22 14:24 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
dependencies = [ |
|||
('abonapp', '0004_auto_20180918_1734'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterField( |
|||
model_name='abon', |
|||
name='current_tariff', |
|||
field=models.OneToOneField(blank=True, default=None, null=True, |
|||
on_delete=django.db.models.deletion.SET_NULL, to='abonapp.AbonTariff'), |
|||
), |
|||
] |
|||
@ -1,43 +1,79 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.11 on 2018-08-14 19:21 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
# Generated by Django 2.1 on 2018-09-22 14:30 |
|||
from django.core.exceptions import ImproperlyConfigured |
|||
from django.db import migrations, connection, models |
|||
from statistics.fields import UnixDateTimeField |
|||
|
|||
|
|||
# def psql_migr(apps, _): |
|||
# pass |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('abonapp', '0002_auto_20180808_1448'), |
|||
('abonapp', '0005_current_tariff'), |
|||
('statistics', '0002_auto_20180808_1236'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RunSQL( |
|||
( |
|||
"DROP TABLE `flowcache`;", |
|||
"CREATE TABLE `flowcache` ( " |
|||
" `last_time` INT(10) UNSIGNED NOT NULL, " |
|||
" `abon_id` INT(11) DEFAULT NULL UNIQUE, " |
|||
" `octets` INT(10) UNSIGNED NOT NULL, " |
|||
" `packets` INT(10) UNSIGNED NOT NULL, " |
|||
" KEY `flowcache_abon_id_91e1085d` (`abon_id`) " |
|||
") ENGINE = MEMORY DEFAULT CHARSET = utf8;" |
|||
), |
|||
state_operations=[ |
|||
migrations.DeleteModel(name='statcache'), |
|||
migrations.CreateModel( |
|||
name='statcache', |
|||
fields=[ |
|||
('last_time', UnixDateTimeField()), |
|||
('abon', models.OneToOneField('abonapp.Abon', on_delete=models.CASCADE, primary_key=True)), |
|||
('octets', models.PositiveIntegerField(default=0)), |
|||
('packets', models.PositiveIntegerField(default=0)) |
|||
], |
|||
options={ |
|||
'db_table': 'flowcache', |
|||
}, |
|||
) |
|||
] |
|||
) |
|||
migrations.AlterModelOptions( |
|||
name='statcache', |
|||
options={'ordering': ('-last_time',)}, |
|||
), |
|||
] |
|||
|
|||
|
|||
db_e = connection.settings_dict.get('ENGINE') |
|||
if db_e is None: |
|||
raise ImproperlyConfigured('Database ENGINE is not set') |
|||
# if 'postgresql' in db_e: |
|||
# # Postgres |
|||
Migration.operations.insert(0, migrations.RunPython(psql_migr)) |
|||
if 'mysql' in db_e: |
|||
Migration.operations.insert(0, migrations.RunSQL( |
|||
( |
|||
"DROP TABLE `flowcache`;", |
|||
"CREATE TABLE `flowcache` ( " |
|||
" `last_time` INT(10) UNSIGNED NOT NULL, " |
|||
" `abon_id` INT(11) DEFAULT NULL UNIQUE, " |
|||
" `octets` INT(10) UNSIGNED NOT NULL, " |
|||
" `packets` INT(10) UNSIGNED NOT NULL, " |
|||
" KEY `flowcache_abon_id_91e1085d` (`abon_id`) " |
|||
") ENGINE = MEMORY DEFAULT CHARSET = utf8;" |
|||
), |
|||
state_operations=[ |
|||
migrations.DeleteModel(name='statcache'), |
|||
migrations.CreateModel( |
|||
name='statcache', |
|||
fields=[ |
|||
('last_time', UnixDateTimeField()), |
|||
('abon', models.OneToOneField('abonapp.Abon', on_delete=models.CASCADE, primary_key=True)), |
|||
('octets', models.PositiveIntegerField(default=0)), |
|||
('packets', models.PositiveIntegerField(default=0)) |
|||
], |
|||
options={ |
|||
'db_table': 'flowcache', |
|||
}, |
|||
) |
|||
] |
|||
)) |
|||
else: |
|||
Migration.operations.extend( |
|||
( |
|||
migrations.DeleteModel(name='statcache'), |
|||
migrations.CreateModel( |
|||
name='statcache', |
|||
fields=[ |
|||
('last_time', UnixDateTimeField()), |
|||
('abon', models.OneToOneField('abonapp.Abon', on_delete=models.CASCADE, primary_key=True)), |
|||
('octets', models.PositiveIntegerField(default=0)), |
|||
('packets', models.PositiveIntegerField(default=0)) |
|||
], |
|||
options={ |
|||
'db_table': 'flowcache', |
|||
'ordering': ('-last_time',), |
|||
#'db_tablespace': 'ram' |
|||
}, |
|||
) |
|||
) |
|||
) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue