1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-23 07:14:21 +00:00

Create migration 0001_initial

This commit is contained in:
Steffo 2021-04-05 01:43:25 +02:00
parent 3de54bce92
commit 9567e4d5a3
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -0,0 +1,65 @@
# Generated by Django 3.1.7 on 2021-04-04 23:41
# Manually edited by @Steffo99
from django.db import migrations, models
def create_builtin_sources(apps, schema_editor):
"""
Create in the database the sources that are already built-in in :mod:`pandasdmx`.
This function is called when performing the migration: see
`this page <https://docs.djangoproject.com/en/3.1/topics/migrations/#data-migrations>`_ for details on how this
works!
"""
DataSource = apps.get_model("core", "DataSource")
DataSource.objects.bulk_create([
DataSource(pandasdmx_id="ABS", builtin=True),
DataSource(pandasdmx_id="ESTAT", builtin=True),
DataSource(pandasdmx_id="ECB", builtin=True),
DataSource(pandasdmx_id="ILO", builtin=True),
DataSource(pandasdmx_id="IMF", builtin=True),
DataSource(pandasdmx_id="INEGI", builtin=True),
DataSource(pandasdmx_id="INSEE", builtin=True),
DataSource(pandasdmx_id="ISTAT", builtin=True),
DataSource(pandasdmx_id="LSD", builtin=True),
DataSource(pandasdmx_id="NB", builtin=True),
DataSource(pandasdmx_id="NBB", builtin=True),
DataSource(pandasdmx_id="OECD", builtin=True),
DataSource(pandasdmx_id="SGR", builtin=True),
DataSource(pandasdmx_id="SPC", builtin=True),
DataSource(pandasdmx_id="STAT_EE", builtin=True),
DataSource(pandasdmx_id="UNSD", builtin=True),
DataSource(pandasdmx_id="UNICEF", builtin=True),
DataSource(pandasdmx_id="WB", builtin=True),
DataSource(pandasdmx_id="WB_WDI", builtin=True),
])
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='DataSource',
fields=[
('pandasdmx_id', models.CharField(max_length=16, primary_key=True, serialize=False, verbose_name='Internal pandasdmx source id')),
('builtin', models.BooleanField(verbose_name='If the source is builtin in pandasdmx')),
('settings', models.JSONField(null=True, verbose_name='Source info to pass to pandasdmx if the source is not builtin')),
],
),
migrations.CreateModel(
name='Project',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=512, verbose_name='Project name')),
('description', models.CharField(max_length=8192, verbose_name='Project description')),
('sources', models.ManyToManyField(related_name='used_in', to='core.DataSource')),
],
),
migrations.RunPython(create_builtin_sources)
]