You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.6 KiB
79 lines
2.6 KiB
# 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', '0005_current_tariff'),
|
|
('statistics', '0002_auto_20180808_1236'),
|
|
]
|
|
|
|
operations = [
|
|
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'
|
|
},
|
|
)
|
|
)
|
|
)
|