# Generated by Django 2.1.7 on 2019-03-14 18:19

from django.db import migrations, models

from oldp.apps.sources.models import Source


def create_default_source(apps, schema_editor):
    Source.objects.create(pk=Source.DEFAULT_ID, name="Default")


def delete_default_source(apps, schema_editor):
    pass


class Migration(migrations.Migration):
    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Source",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        db_index=True,
                        help_text="Name of source (crawler class)",
                        max_length=100,
                        unique=True,
                    ),
                ),
                ("homepage", models.URLField(help_text="Link to source homepage")),
                (
                    "private",
                    models.BooleanField(
                        default=True,
                        help_text="Private sources are not displayed in front-end",
                    ),
                ),
            ],
        ),
        migrations.RunPython(
            code=create_default_source, reverse_code=delete_default_source
        ),
    ]
