# Generated by Django 2.1.8 on 2019-04-09 17:08

from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("api_v2", "0023_issuer_endpoint"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="CredentialHook",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True)),
                ("updated", models.DateTimeField(auto_now=True)),
                (
                    "event",
                    models.CharField(
                        db_index=True, max_length=64, verbose_name="Event"
                    ),
                ),
                ("target", models.URLField(max_length=255, verbose_name="Target URL")),
                ("is_active", models.BooleanField(default=True)),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="credentialhooks",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={"abstract": False},
        ),
        migrations.CreateModel(
            name="HookableCredential",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "create_timestamp",
                    models.DateTimeField(auto_now_add=True, null=True),
                ),
                ("update_timestamp", models.DateTimeField(auto_now=True, null=True)),
                ("topic_status", models.TextField()),
                ("corp_num", models.TextField(null=True)),
                ("credential_type", models.TextField(null=True)),
                (
                    "credential_json",
                    django.contrib.postgres.fields.jsonb.JSONField(
                        blank=True, null=True
                    ),
                ),
            ],
            options={
                "db_table": "hookable_cred",
                "ordering": ("corp_num", "credential_type"),
            },
        ),
        migrations.CreateModel(
            name="HookUser",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "create_timestamp",
                    models.DateTimeField(auto_now_add=True, null=True),
                ),
                ("update_timestamp", models.DateTimeField(auto_now=True, null=True)),
                ("DID", models.TextField(blank=True, max_length=60, unique=True)),
                ("verkey", models.BinaryField(blank=True)),
                ("display_name", models.TextField(blank=True)),
                ("registration_expiry", models.DateField(blank=True, null=True)),
                ("org_name", models.TextField(blank=True, max_length=240, null=True)),
                ("target_url", models.TextField(blank=True, max_length=240, null=True)),
                ("hook_token", models.TextField(blank=True, max_length=240, null=True)),
            ],
            options={"abstract": False},
        ),
        migrations.CreateModel(
            name="Subscription",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "create_timestamp",
                    models.DateTimeField(auto_now_add=True, null=True),
                ),
                ("update_timestamp", models.DateTimeField(auto_now=True, null=True)),
                ("subscription_type", models.TextField(max_length=20)),
                ("topic_source_id", models.TextField(blank=True, null=True)),
                ("target_url", models.TextField(blank=True, max_length=240, null=True)),
                ("hook_token", models.TextField(blank=True, max_length=240, null=True)),
                (
                    "credential_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="credential_subscription",
                        to="api_v2.CredentialType",
                    ),
                ),
                (
                    "hook",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="credential_subscription",
                        to="subscriptions.CredentialHook",
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="subscriptions",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={"abstract": False},
        ),
    ]
