dynamicweb/datacenterlight/migrations/0020_auto_20180409_1928.py
2018-04-09 21:40:03 +02:00

48 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2018-04-09 19:28
from __future__ import unicode_literals
from django.db import migrations
DEFAULT_VMPRICING_NAME='default'
def create_default_pricing(apps, schema_editor):
"""
Create default pricing
:param apps:
:param schema_editor:
:return:
"""
VMPricing = apps.get_model('datacenterlight', 'VMPricing')
if not VMPricing.objects.count():
vm_pricing = VMPricing(
name=DEFAULT_VMPRICING_NAME,
vat_inclusive=True,
cores_unit_price=5,
ram_unit_price=2,
ssd_unit_price=0.6,
hdd_unit_price=0.01,
)
vm_pricing.save()
def undo_vm_pricing(apps, schema_editor):
"""Deleting all entries for this model"""
VMPricing = apps.get_model("datacenterlight", "VMPricing")
VMPricing.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
('datacenterlight', '0019_auto_20180409_1923'),
]
operations = [
migrations.RunPython(
create_default_pricing,
reverse_code=undo_vm_pricing
),
]