<reponame>Fanduzi/YaSQL<gh_stars>100-1000
# Generated by Django 2.2.16 on 2020-12-15 07:18

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='DbQuerySchemas',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('schema', models.CharField(default='', max_length=64, verbose_name='库名')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('cid', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlorders.DbConfig', verbose_name='数据库')),
            ],
            options={
                'verbose_name': 'DB查询库',
                'verbose_name_plural': 'DB查询库',
                'db_table': 'yasql_sqlquery_schemas',
                'default_permissions': (),
                'unique_together': {('cid', 'schema')},
            },
        ),
        migrations.CreateModel(
            name='DbQueryTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('table', models.CharField(default='', max_length=128, verbose_name='表名')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('schema', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQuerySchemas', verbose_name='库名')),
            ],
            options={
                'verbose_name': 'DB查询表',
                'verbose_name_plural': 'DB查询表',
                'db_table': 'yasql_sqlquery_tables',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryUserPrivs',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('schemas', models.ManyToManyField(to='sqlquery.DbQuerySchemas', verbose_name='允许访问的库')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': 'DB查询用户权限',
                'verbose_name_plural': 'DB查询用户权限',
                'db_table': 'yasql_sqlquery_user_privileges',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryUserDenyTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('tables', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryTables', verbose_name='表')),
                ('user_privs', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryUserPrivs', verbose_name='权限')),
            ],
            options={
                'verbose_name': '禁止用户访问的表',
                'verbose_name_plural': '禁止用户访问的表',
                'db_table': 'yasql_sqlquery_user_deny_tables',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryUserAllowedTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('tables', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryTables', verbose_name='表')),
                ('user_privs', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryUserPrivs', verbose_name='权限')),
            ],
            options={
                'verbose_name': '允许用户访问的表',
                'verbose_name_plural': '允许用户访问的表',
                'db_table': 'yasql_sqlquery_user_allowed_tables',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryLog',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键id')),
                ('username', models.CharField(max_length=64, verbose_name='用户名')),
                ('host', models.CharField(max_length=256, verbose_name='目标数据库地址')),
                ('schema', models.CharField(default='', max_length=128, verbose_name='目标数据库')),
                ('tables', models.CharField(default='', max_length=200, verbose_name='目标表名')),
                ('query_sql', models.TextField(default='', verbose_name='查询SQL')),
                ('query_consume_time', models.FloatField(default=0.0, verbose_name='查询耗时，单位s')),
                ('query_status', models.CharField(default='', max_length=2048, verbose_name='查询是否成功或失败的原因')),
                ('affected_rows', models.IntegerField(default=0, verbose_name='影响影响行数')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='查询时间')),
            ],
            options={
                'verbose_name': 'DB查询日志',
                'verbose_name_plural': 'DB查询日志',
                'db_table': 'yasql_sqlquery_log',
                'default_permissions': (),
                'index_together': {('tables',), ('schema',), ('username',)},
            },
        ),
        migrations.CreateModel(
            name='DbQueryGroupPrivs',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('group', models.CharField(default='', max_length=128, verbose_name='组名')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('schemas', models.ManyToManyField(to='sqlquery.DbQuerySchemas', verbose_name='允许访问的库')),
                ('user', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': 'DB查询组权限',
                'verbose_name_plural': 'DB查询组权限',
                'db_table': 'yasql_sqlquery_group_privileges',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryGroupDenyTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('group_privs', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryGroupPrivs', verbose_name='权限')),
                ('tables', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryTables', verbose_name='表')),
            ],
            options={
                'verbose_name': '禁止组访问的表',
                'verbose_name_plural': '禁止组访问的表',
                'db_table': 'yasql_sqlquery_group_deny_tables',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryGroupAllowedTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('group_privs', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryGroupPrivs', verbose_name='权限')),
                ('tables', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryTables', verbose_name='表')),
            ],
            options={
                'verbose_name': '允许组访问的表',
                'verbose_name_plural': '允许组访问的表',
                'db_table': 'yasql_sqlquery_group_allowed_tables',
                'default_permissions': (),
            },
        ),
    ]

# Generated by Django 2.2.16 on 2020-12-15 07:18

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='DbQuerySchemas',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('schema', models.CharField(default='', max_length=64, verbose_name='库名')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('cid', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlorders.DbConfig', verbose_name='数据库')),
            ],
            options={
                'verbose_name': 'DB查询库',
                'verbose_name_plural': 'DB查询库',
                'db_table': 'yasql_sqlquery_schemas',
                'default_permissions': (),
                'unique_together': {('cid', 'schema')},
            },
        ),
        migrations.CreateModel(
            name='DbQueryTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('table', models.CharField(default='', max_length=128, verbose_name='表名')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('schema', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQuerySchemas', verbose_name='库名')),
            ],
            options={
                'verbose_name': 'DB查询表',
                'verbose_name_plural': 'DB查询表',
                'db_table': 'yasql_sqlquery_tables',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryUserPrivs',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('schemas', models.ManyToManyField(to='sqlquery.DbQuerySchemas', verbose_name='允许访问的库')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': 'DB查询用户权限',
                'verbose_name_plural': 'DB查询用户权限',
                'db_table': 'yasql_sqlquery_user_privileges',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryUserDenyTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('tables', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryTables', verbose_name='表')),
                ('user_privs', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryUserPrivs', verbose_name='权限')),
            ],
            options={
                'verbose_name': '禁止用户访问的表',
                'verbose_name_plural': '禁止用户访问的表',
                'db_table': 'yasql_sqlquery_user_deny_tables',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryUserAllowedTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('tables', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryTables', verbose_name='表')),
                ('user_privs', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryUserPrivs', verbose_name='权限')),
            ],
            options={
                'verbose_name': '允许用户访问的表',
                'verbose_name_plural': '允许用户访问的表',
                'db_table': 'yasql_sqlquery_user_allowed_tables',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryLog',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键id')),
                ('username', models.CharField(max_length=64, verbose_name='用户名')),
                ('host', models.CharField(max_length=256, verbose_name='目标数据库地址')),
                ('schema', models.CharField(default='', max_length=128, verbose_name='目标数据库')),
                ('tables', models.CharField(default='', max_length=200, verbose_name='目标表名')),
                ('query_sql', models.TextField(default='', verbose_name='查询SQL')),
                ('query_consume_time', models.FloatField(default=0.0, verbose_name='查询耗时，单位s')),
                ('query_status', models.CharField(default='', max_length=2048, verbose_name='查询是否成功或失败的原因')),
                ('affected_rows', models.IntegerField(default=0, verbose_name='影响影响行数')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='查询时间')),
            ],
            options={
                'verbose_name': 'DB查询日志',
                'verbose_name_plural': 'DB查询日志',
                'db_table': 'yasql_sqlquery_log',
                'default_permissions': (),
                'index_together': {('tables',), ('schema',), ('username',)},
            },
        ),
        migrations.CreateModel(
            name='DbQueryGroupPrivs',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('group', models.CharField(default='', max_length=128, verbose_name='组名')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('schemas', models.ManyToManyField(to='sqlquery.DbQuerySchemas', verbose_name='允许访问的库')),
                ('user', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': 'DB查询组权限',
                'verbose_name_plural': 'DB查询组权限',
                'db_table': 'yasql_sqlquery_group_privileges',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryGroupDenyTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('group_privs', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryGroupPrivs', verbose_name='权限')),
                ('tables', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryTables', verbose_name='表')),
            ],
            options={
                'verbose_name': '禁止组访问的表',
                'verbose_name_plural': '禁止组访问的表',
                'db_table': 'yasql_sqlquery_group_deny_tables',
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='DbQueryGroupAllowedTables',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='主键ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('group_privs', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryGroupPrivs', verbose_name='权限')),
                ('tables', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sqlquery.DbQueryTables', verbose_name='表')),
            ],
            options={
                'verbose_name': '允许组访问的表',
                'verbose_name_plural': '允许组访问的表',
                'db_table': 'yasql_sqlquery_group_allowed_tables',
                'default_permissions': (),
            },
        ),
    ]
# Generated by Django 2.2.16 on 2020-12-15 07:18