<filename>jcourse_api/migrations/0001_initial.py
# Generated by Django 3.2.3 on 2021-09-07 08:59

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='ApiKey',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(max_length=255)),
                ('description', models.CharField(max_length=255, verbose_name='描述')),
                ('is_enabled', models.BooleanField(default=True, verbose_name='启用')),
                ('last_modified', models.DateTimeField(default=django.utils.timezone.now, verbose_name='修改时间')),
            ],
            options={
                'verbose_name': 'Api密钥',
                'verbose_name_plural': 'Api密钥',
            },
        ),
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64, unique=True, verbose_name='名称')),
            ],
            options={
                'verbose_name': '课程类别',
                'verbose_name_plural': '课程类别',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Course',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(db_index=True, max_length=32, verbose_name='课号')),
                ('name', models.CharField(db_index=True, max_length=255, verbose_name='名称')),
                ('credit', models.FloatField(default=0, verbose_name='学分')),
                ('moderator_remark', models.TextField(blank=True, max_length=817, null=True, verbose_name='管理员批注')),
                ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.category', verbose_name='类别')),
            ],
            options={
                'verbose_name': '课程',
                'verbose_name_plural': '课程',
                'ordering': ['code'],
            },
        ),
        migrations.CreateModel(
            name='Department',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64, unique=True, verbose_name='名称')),
            ],
            options={
                'verbose_name': '教学单位',
                'verbose_name_plural': '教学单位',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='FormerCode',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('old_code', models.CharField(max_length=32, verbose_name='旧课号')),
                ('new_code', models.CharField(max_length=32, verbose_name='新课号')),
            ],
            options={
                'verbose_name': '曾用课号',
                'verbose_name_plural': '曾用课号',
                'ordering': ['old_code'],
            },
        ),
        migrations.CreateModel(
            name='Language',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64, unique=True, verbose_name='名称')),
            ],
            options={
                'verbose_name': '授课语言',
                'verbose_name_plural': '授课语言',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Notice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=256, verbose_name='标题')),
                ('message', models.TextField(max_length=256, verbose_name='正文')),
                ('created', models.DateTimeField(default=django.utils.timezone.now, verbose_name='发布时间')),
                ('available', models.BooleanField(default=True, verbose_name='是否显示')),
            ],
            options={
                'verbose_name': '通知',
                'verbose_name_plural': '通知',
                'ordering': ['-created'],
            },
        ),
        migrations.CreateModel(
            name='Semester',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64, unique=True, verbose_name='名称')),
            ],
            options={
                'verbose_name': '学期',
                'verbose_name_plural': '学期',
                'ordering': ['-name'],
            },
        ),
        migrations.CreateModel(
            name='Teacher',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('tid', models.CharField(blank=True, max_length=32, null=True, unique=True, verbose_name='工号')),
                ('name', models.CharField(db_index=True, max_length=255, verbose_name='姓名')),
                ('title', models.CharField(blank=True, max_length=64, verbose_name='职称')),
                ('pinyin', models.CharField(blank=True, max_length=64, null=True, verbose_name='拼音')),
                ('abbr_pinyin', models.CharField(blank=True, max_length=64, null=True, verbose_name='拼音缩写')),
                ('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.department', verbose_name='单位')),
            ],
            options={
                'verbose_name': '教师',
                'verbose_name_plural': '教师',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Review',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('rating', models.IntegerField(validators=[django.core.validators.MaxValueValidator(5), django.core.validators.MinValueValidator(0)], verbose_name='推荐指数')),
                ('comment', models.TextField(default='', max_length=817, verbose_name='详细点评')),
                ('created', models.DateTimeField(default=django.utils.timezone.now, verbose_name='发布时间')),
                ('score', models.CharField(blank=True, max_length=10, null=True, verbose_name='成绩')),
                ('available', models.BooleanField(default=True, verbose_name='是否显示')),
                ('moderator_remark', models.TextField(blank=True, max_length=817, null=True, verbose_name='管理员批注')),
                ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='jcourse_api.course', verbose_name='课程')),
                ('semester', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.semester', verbose_name='上课学期')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': '点评',
                'verbose_name_plural': '点评',
                'ordering': ['-created'],
            },
        ),
        migrations.CreateModel(
            name='Report',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('solved', models.BooleanField(default=False, verbose_name='是否解决')),
                ('comment', models.TextField(max_length=817, verbose_name='反馈')),
                ('created', models.DateTimeField(default=django.utils.timezone.now, verbose_name='发布时间')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': '反馈',
                'verbose_name_plural': '反馈',
                'ordering': ['-created'],
            },
        ),
        migrations.CreateModel(
            name='EnrollCourse',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='jcourse_api.course')),
                ('semester', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.semester')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': '选课记录',
                'verbose_name_plural': '选课记录',
            },
        ),
        migrations.AddField(
            model_name='course',
            name='department',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.department', verbose_name='开课单位'),
        ),
        migrations.AddField(
            model_name='course',
            name='language',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.language', verbose_name='授课语言'),
        ),
        migrations.AddField(
            model_name='course',
            name='main_teacher',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='jcourse_api.teacher', verbose_name='主讲教师'),
        ),
        migrations.AddField(
            model_name='course',
            name='teacher_group',
            field=models.ManyToManyField(related_name='teacher_course', to='jcourse_api.Teacher', verbose_name='教师组成'),
        ),
        migrations.CreateModel(
            name='Action',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('action', models.IntegerField(choices=[(1, '赞同'), (-1, '反对'), (0, '重置')], default=0, verbose_name='操作')),
                ('review', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='jcourse_api.review', verbose_name='点评')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': '赞同',
                'verbose_name_plural': '赞同',
            },
        ),
        migrations.AddConstraint(
            model_name='teacher',
            constraint=models.UniqueConstraint(fields=('tid', 'name'), name='unique_teacher'),
        ),
        migrations.AddConstraint(
            model_name='review',
            constraint=models.UniqueConstraint(fields=('user', 'course'), name='unique_review'),
        ),
        migrations.AddConstraint(
            model_name='enrollcourse',
            constraint=models.UniqueConstraint(fields=('user', 'course', 'semester'), name='unique_enroll'),
        ),
        migrations.AddConstraint(
            model_name='course',
            constraint=models.UniqueConstraint(fields=('code', 'main_teacher'), name='unique_course'),
        ),
    ]

<filename>jcourse_api/migrations/0001_initial.py
# Generated by Django 3.2.3 on 2021-09-07 08:59

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='ApiKey',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(max_length=255)),
                ('description', models.CharField(max_length=255, verbose_name='描述')),
                ('is_enabled', models.BooleanField(default=True, verbose_name='启用')),
                ('last_modified', models.DateTimeField(default=django.utils.timezone.now, verbose_name='修改时间')),
            ],
            options={
                'verbose_name': 'Api密钥',
                'verbose_name_plural': 'Api密钥',
            },
        ),
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64, unique=True, verbose_name='名称')),
            ],
            options={
                'verbose_name': '课程类别',
                'verbose_name_plural': '课程类别',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Course',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(db_index=True, max_length=32, verbose_name='课号')),
                ('name', models.CharField(db_index=True, max_length=255, verbose_name='名称')),
                ('credit', models.FloatField(default=0, verbose_name='学分')),
                ('moderator_remark', models.TextField(blank=True, max_length=817, null=True, verbose_name='管理员批注')),
                ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.category', verbose_name='类别')),
            ],
            options={
                'verbose_name': '课程',
                'verbose_name_plural': '课程',
                'ordering': ['code'],
            },
        ),
        migrations.CreateModel(
            name='Department',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64, unique=True, verbose_name='名称')),
            ],
            options={
                'verbose_name': '教学单位',
                'verbose_name_plural': '教学单位',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='FormerCode',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('old_code', models.CharField(max_length=32, verbose_name='旧课号')),
                ('new_code', models.CharField(max_length=32, verbose_name='新课号')),
            ],
            options={
                'verbose_name': '曾用课号',
                'verbose_name_plural': '曾用课号',
                'ordering': ['old_code'],
            },
        ),
        migrations.CreateModel(
            name='Language',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64, unique=True, verbose_name='名称')),
            ],
            options={
                'verbose_name': '授课语言',
                'verbose_name_plural': '授课语言',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Notice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=256, verbose_name='标题')),
                ('message', models.TextField(max_length=256, verbose_name='正文')),
                ('created', models.DateTimeField(default=django.utils.timezone.now, verbose_name='发布时间')),
                ('available', models.BooleanField(default=True, verbose_name='是否显示')),
            ],
            options={
                'verbose_name': '通知',
                'verbose_name_plural': '通知',
                'ordering': ['-created'],
            },
        ),
        migrations.CreateModel(
            name='Semester',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64, unique=True, verbose_name='名称')),
            ],
            options={
                'verbose_name': '学期',
                'verbose_name_plural': '学期',
                'ordering': ['-name'],
            },
        ),
        migrations.CreateModel(
            name='Teacher',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('tid', models.CharField(blank=True, max_length=32, null=True, unique=True, verbose_name='工号')),
                ('name', models.CharField(db_index=True, max_length=255, verbose_name='姓名')),
                ('title', models.CharField(blank=True, max_length=64, verbose_name='职称')),
                ('pinyin', models.CharField(blank=True, max_length=64, null=True, verbose_name='拼音')),
                ('abbr_pinyin', models.CharField(blank=True, max_length=64, null=True, verbose_name='拼音缩写')),
                ('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.department', verbose_name='单位')),
            ],
            options={
                'verbose_name': '教师',
                'verbose_name_plural': '教师',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Review',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('rating', models.IntegerField(validators=[django.core.validators.MaxValueValidator(5), django.core.validators.MinValueValidator(0)], verbose_name='推荐指数')),
                ('comment', models.TextField(default='', max_length=817, verbose_name='详细点评')),
                ('created', models.DateTimeField(default=django.utils.timezone.now, verbose_name='发布时间')),
                ('score', models.CharField(blank=True, max_length=10, null=True, verbose_name='成绩')),
                ('available', models.BooleanField(default=True, verbose_name='是否显示')),
                ('moderator_remark', models.TextField(blank=True, max_length=817, null=True, verbose_name='管理员批注')),
                ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='jcourse_api.course', verbose_name='课程')),
                ('semester', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.semester', verbose_name='上课学期')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': '点评',
                'verbose_name_plural': '点评',
                'ordering': ['-created'],
            },
        ),
        migrations.CreateModel(
            name='Report',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('solved', models.BooleanField(default=False, verbose_name='是否解决')),
                ('comment', models.TextField(max_length=817, verbose_name='反馈')),
                ('created', models.DateTimeField(default=django.utils.timezone.now, verbose_name='发布时间')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': '反馈',
                'verbose_name_plural': '反馈',
                'ordering': ['-created'],
            },
        ),
        migrations.CreateModel(
            name='EnrollCourse',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='jcourse_api.course')),
                ('semester', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.semester')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': '选课记录',
                'verbose_name_plural': '选课记录',
            },
        ),
        migrations.AddField(
            model_name='course',
            name='department',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.department', verbose_name='开课单位'),
        ),
        migrations.AddField(
            model_name='course',
            name='language',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='jcourse_api.language', verbose_name='授课语言'),
        ),
        migrations.AddField(
            model_name='course',
            name='main_teacher',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='jcourse_api.teacher', verbose_name='主讲教师'),
        ),
        migrations.AddField(
            model_name='course',
            name='teacher_group',
            field=models.ManyToManyField(related_name='teacher_course', to='jcourse_api.Teacher', verbose_name='教师组成'),
        ),
        migrations.CreateModel(
            name='Action',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('action', models.IntegerField(choices=[(1, '赞同'), (-1, '反对'), (0, '重置')], default=0, verbose_name='操作')),
                ('review', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='jcourse_api.review', verbose_name='点评')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': '赞同',
                'verbose_name_plural': '赞同',
            },
        ),
        migrations.AddConstraint(
            model_name='teacher',
            constraint=models.UniqueConstraint(fields=('tid', 'name'), name='unique_teacher'),
        ),
        migrations.AddConstraint(
            model_name='review',
            constraint=models.UniqueConstraint(fields=('user', 'course'), name='unique_review'),
        ),
        migrations.AddConstraint(
            model_name='enrollcourse',
            constraint=models.UniqueConstraint(fields=('user', 'course', 'semester'), name='unique_enroll'),
        ),
        migrations.AddConstraint(
            model_name='course',
            constraint=models.UniqueConstraint(fields=('code', 'main_teacher'), name='unique_course'),
        ),
    ]

# Generated by Django 3.2.3 on 2021-09-07 08:59