Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COST-5015] Azure disk capacity table migration #5090

Merged
merged 12 commits into from
May 16, 2024
92 changes: 92 additions & 0 deletions koku/reporting_common/migrations/0041_diskcapacity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Generated by Django 4.2.11 on 2024-05-10 16:17
from django.db import migrations
from django.db import models


def populate_azure_storage_capacity(apps, schema_editor):
DiskCapacity = apps.get_model("reporting_common", "DiskCapacity")
initial_values = [
("P1", 4, "Azure"),
("P2", 8, "Azure"),
("P3", 16, "Azure"),
("P4", 32, "Azure"),
("P6", 64, "Azure"),
("P10", 128, "Azure"),
("P15", 256, "Azure"),
("P20", 512, "Azure"),
("P30", 1024, "Azure"),
("P40", 2048, "Azure"),
("P50", 4096, "Azure"),
("P60", 8192, "Azure"),
("P70", 16384, "Azure"),
("P80", 32767, "Azure"),
("S4", 32, "Azure"),
("S6", 64, "Azure"),
("S10", 128, "Azure"),
("S15", 256, "Azure"),
("S20", 512, "Azure"),
("S30", 1024, "Azure"),
("S40", 2048, "Azure"),
("S50", 4096, "Azure"),
("S60", 8192, "Azure"),
("S70", 16384, "Azure"),
("S80", 32767, "Azure"),
("E1", 4, "Azure"),
("E2", 8, "Azure"),
("E3", 16, "Azure"),
("E4", 32, "Azure"),
("E6", 64, "Azure"),
("E10", 128, "Azure"),
("E15", 256, "Azure"),
("E20", 512, "Azure"),
("E30", 1024, "Azure"),
("E40", 2048, "Azure"),
("E50", 4096, "Azure"),
("E60", 8192, "Azure"),
("E70", 16384, "Azure"),
("E80", 32767, "Azure"),
]
objects_to_create = [
DiskCapacity(product_substring=substring, capacity=capacity, provider_type=ptype)
for substring, capacity, ptype in initial_values
]
DiskCapacity.objects.bulk_create(objects_to_create)


class Migration(migrations.Migration):

dependencies = [
("reporting_common", "0040_delayedcelerytasks"),
]

operations = [
migrations.CreateModel(
name="DiskCapacity",
fields=[
("product_substring", models.CharField(max_length=20, primary_key=True, serialize=False)),
("capacity", models.IntegerField()),
(
"provider_type",
models.CharField(
choices=[
("AWS", "AWS"),
("Azure", "Azure"),
("GCP", "GCP"),
("IBM", "IBM"),
("OCI", "OCI"),
("AWS-local", "AWS-local"),
("Azure-local", "Azure-local"),
("GCP-local", "GCP-local"),
("IBM-local", "IBM-local"),
("OCI-local", "OCI-local"),
myersCody marked this conversation as resolved.
Show resolved Hide resolved
],
max_length=50,
),
),
],
options={
"unique_together": {("product_substring", "capacity", "provider_type")},
},
),
migrations.RunPython(populate_azure_storage_capacity),
]
Loading