# Generated by Django 3.2.11 on 2022-02-05 11:33

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('products', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='CodeBatch',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qr_angle', models.FloatField(default=0.0)),
                ('datetime', models.DateTimeField(auto_now=True)),
                ('code_prefix', models.CharField(max_length=64)),
            ],
        ),
        migrations.CreateModel(
            name='ConsumerInfo',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(auto_now=True)),
                ('username', models.CharField(max_length=128)),
                ('gender', models.CharField(blank=True, max_length=128, null=True)),
                ('country', models.CharField(blank=True, max_length=128, null=True)),
                ('province', models.CharField(blank=True, max_length=128, null=True)),
                ('city', models.CharField(blank=True, max_length=128, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Event',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('datetime', models.DateTimeField(auto_now=True)),
                ('kind', models.CharField(max_length=128)),
                ('params', models.TextField()),
            ],
        ),
        migrations.CreateModel(
            name='PageTemplate',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('template', models.TextField()),
                ('params', models.TextField()),
            ],
        ),
        migrations.CreateModel(
            name='Stat',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('kind', models.CharField(max_length=128)),
                ('params', models.TextField()),
                ('count', models.IntegerField(default=1)),
            ],
        ),
        migrations.CreateModel(
            name='Tenant',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('username', models.CharField(db_index=True, max_length=128, unique=True, verbose_name='用户名')),
                ('mobile', models.CharField(blank=True, max_length=128, null=True, unique=True, verbose_name='手机号')),
                ('password', models.CharField(max_length=256, verbose_name='密码')),
                ('token', models.CharField(db_index=True, max_length=128, unique=True, verbose_name='API Token')),
            ],
        ),
        migrations.CreateModel(
            name='SerialCode',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(db_index=True, max_length=128, unique=True)),
                ('batch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='codes', to='products.codebatch')),
            ],
        ),
        migrations.CreateModel(
            name='ScanData',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('datetime', models.DateTimeField(auto_now=True)),
                ('ip', models.CharField(max_length=64)),
                ('kind', models.CharField(max_length=128)),
                ('params', models.TextField()),
                ('image', models.TextField()),
                ('consumer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scans', to='products.consumerinfo')),
            ],
        ),
        migrations.CreateModel(
            name='ProductPage',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('html', models.TextField(default='<html><body>no content</body></html>')),
                ('arguments', models.TextField(blank=True, null=True)),
                ('template', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='pages', to='products.pagetemplate')),
            ],
        ),
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128, verbose_name='名称')),
                ('description', models.TextField(verbose_name='产品描述')),
                ('counterfeit_result_page', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='counterfeit_page', to='products.productpage', verbose_name='假货页面')),
                ('genuine_result_page', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='genuine_page', to='products.productpage', verbose_name='产品信息页面')),
                ('tenant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='products', to='products.tenant')),
            ],
            options={
                'unique_together': {('tenant', 'name')},
            },
        ),
        migrations.AddField(
            model_name='pagetemplate',
            name='tenant',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='templates', to='products.tenant'),
        ),
        migrations.CreateModel(
            name='Media',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('mime_type', models.CharField(max_length=128)),
                ('uri', models.TextField()),
                ('tenant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='media', to='products.tenant')),
            ],
        ),
        migrations.AddField(
            model_name='codebatch',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='batches', to='products.product'),
        ),
        migrations.CreateModel(
            name='AdminInfo',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('token', models.CharField(db_index=True, max_length=128, null=True, unique=True, verbose_name='API Token')),
                ('mobile', models.CharField(blank=True, max_length=128, null=True, unique=True, verbose_name='手机号')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='token', to=settings.AUTH_USER_MODEL)),
            ],
        ),
    ]
