diff --git a/sophon/core/migrations/0001_initial.py b/sophon/core/migrations/0001_initial.py new file mode 100644 index 0000000..1b2bc99 --- /dev/null +++ b/sophon/core/migrations/0001_initial.py @@ -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 `_ 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) + ]