# Generated by Django 2.2.5 on 2019-09-23 23:28

from django.db import migrations, models


def insert_objects(apps, schema_editor):
    db_alias = schema_editor.connection.alias
    TestTable = apps.get_model('old_notnull_check_constraint_migration_app', 'TestTable')
    TestTable.objects.using(db_alias).create(field=1)


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='TestTable',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('field', models.IntegerField()),
            ],
        ),
        migrations.RunPython(insert_objects, migrations.RunPython.noop),
        migrations.RunSQL(
            'ALTER TABLE old_notnull_check_constraint_migration_app_testtable '
            'ADD CONSTRAINT old_constraint_notnull CHECK (field IS NOT NULL)',
            migrations.RunSQL.noop,
        ),
        migrations.RunSQL(
            'ALTER TABLE old_notnull_check_constraint_migration_app_testtable '
            'ALTER COLUMN field DROP NOT NULL',
            migrations.RunSQL.noop,
        ),
    ]
