Create partitioned models for the following materialized views:
- reporting_aws_compute_summary
- reporting_aws_compute_summary_by_account
- reporting_aws_compute_summary_by_region
- reporting_aws_compute_summary_by_service
- reporting_aws_cost_summary
- reporting_aws_cost_summary_by_account
- reporting_aws_cost_summary_by_region
- reporting_aws_cost_summary_by_service
- reporting_aws_database_summary
- reporting_aws_network_summary
- reporting_aws_storage_summary
- reporting_aws_storage_summary_by_account
- reporting_aws_storage_summary_by_region
- reporting_aws_storage_summary_by_service
This will require making new models. For each of these models, name the model class the same as the original materialized view model class but suffix the new class name with a "P".
For each Meta.db_table attribute, use the materialized view name, but suffix the view name with a "_p".
Each PartitionInfo class should be defined as:
class MyModel(models.Model): class PartitionInfo: partition_type = 'range' partition_col = ['usage_start'] ...
Place the new models in the same file as the materialized view models.
Add these model names to the PARTITIONED_MODEL_NAMES list in koku/database.py
Once you make migrations, don't forget to import the schema editor manipulation functions.
from koku.database import set_partition_mode from koku.database import unset_partition_mode
And don't forget to set them as the first and last migration operation steps:
class Migration(migrations.Migration):
dependencies = [...]
operations = [
migrations.RunPython(set_partition_mode, reverse_code=unset_partition_mode),
...,
migrations.RunPython(unset_partition_mode, reverse_code=set_partition_mode),
]
See this article for an in-depth explanation.