ajuste de la estructura
This commit is contained in:
36
resumen/migrations/0001_initial.py
Normal file
36
resumen/migrations/0001_initial.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
forward = """
|
||||
CREATE OR REPLACE VIEW resumen AS
|
||||
SELECT g.name->>'es' AS modelo, COALESCE(COUNT(ri.resourceinstanceid),0) AS Cuenta
|
||||
FROM graphs AS g LEFT JOIN resource_instances AS ri ON g.graphid = ri.graphid
|
||||
WHERE g.isresource AND g.name ? 'es'
|
||||
GROUP BY g.name;
|
||||
"""
|
||||
|
||||
reverse = """
|
||||
DROP VIEW IF EXISTS resumen;
|
||||
DELETE FROM system_record;
|
||||
"""
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SystemRecord',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('state_details', models.JSONField(blank=True, null=True)),
|
||||
('state_time', models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'system_record',
|
||||
'managed': True,
|
||||
},
|
||||
),
|
||||
migrations.RunSQL(forward, reverse),
|
||||
]
|
||||
0
resumen/migrations/__init__.py
Normal file
0
resumen/migrations/__init__.py
Normal file
Reference in New Issue
Block a user