Model cleanup
- sort models by reference order - change auto id fields
This commit is contained in:
parent
3a1796b1ed
commit
35ae769e76
4 changed files with 220 additions and 88 deletions
29
cats/migrations/0004_alter_unique_together_on_models.py
Normal file
29
cats/migrations/0004_alter_unique_together_on_models.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# Generated by Django 4.2.16 on 2024-09-18 16:48
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("cats", "0003_make_models_managed"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="incorrectanswer",
|
||||||
|
unique_together={("lp_id", "q_id")},
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="questiontypev2",
|
||||||
|
unique_together={("qt_id", "lang")},
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="user",
|
||||||
|
unique_together={("user_id", "root")},
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="useraddress",
|
||||||
|
unique_together={("user_id", "root")},
|
||||||
|
),
|
||||||
|
]
|
48
cats/migrations/0005_rename_auto_id_fields.py
Normal file
48
cats/migrations/0005_rename_auto_id_fields.py
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# Generated by Django 4.2.16 on 2024-09-18 16:50
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("cats", "0004_alter_unique_together_on_models"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="answer",
|
||||||
|
old_name="a_id",
|
||||||
|
new_name="id",
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="learnprogress",
|
||||||
|
old_name="lp_id",
|
||||||
|
new_name="id",
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="question",
|
||||||
|
old_name="q_id",
|
||||||
|
new_name="id",
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="questiontype",
|
||||||
|
old_name="qt_id",
|
||||||
|
new_name="id",
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="statistics",
|
||||||
|
old_name="stat_id",
|
||||||
|
new_name="id",
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="topic",
|
||||||
|
old_name="t_id",
|
||||||
|
new_name="id",
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="topictype",
|
||||||
|
old_name="type_id",
|
||||||
|
new_name="id",
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,62 @@
|
||||||
|
# Generated by Django 4.2.16 on 2024-09-18 16:51
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("cats", "0005_rename_auto_id_fields"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="answer",
|
||||||
|
name="id",
|
||||||
|
field=models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="learnprogress",
|
||||||
|
name="id",
|
||||||
|
field=models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="question",
|
||||||
|
name="id",
|
||||||
|
field=models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="questiontype",
|
||||||
|
name="id",
|
||||||
|
field=models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="statistics",
|
||||||
|
name="id",
|
||||||
|
field=models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="topic",
|
||||||
|
name="id",
|
||||||
|
field=models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="topictype",
|
||||||
|
name="id",
|
||||||
|
field=models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
169
cats/models.py
169
cats/models.py
|
@ -8,68 +8,27 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
class Answer(models.Model):
|
class TopicType(models.Model):
|
||||||
a_id = models.AutoField(primary_key=True)
|
text = models.CharField(max_length=255)
|
||||||
q_id = models.IntegerField()
|
|
||||||
answer = models.TextField()
|
|
||||||
correct = models.IntegerField()
|
|
||||||
ref_a_id = models.IntegerField(blank=True, null=True)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'answers'
|
db_table = 'topic_type'
|
||||||
|
|
||||||
|
|
||||||
class IncorrectAnswer(models.Model):
|
class Topic(models.Model):
|
||||||
lp_id = models.IntegerField(primary_key=True) # The composite primary key (lp_id, q_id) found, that is not supported. The first column is selected.
|
topic = models.CharField(unique=True, max_length=50, db_comment='Thema')
|
||||||
q_id = models.IntegerField()
|
active = models.IntegerField()
|
||||||
|
numofqu = models.IntegerField(db_column='numOfQu') # Field name made lowercase.
|
||||||
|
percentage = models.IntegerField()
|
||||||
|
lang = models.CharField(max_length=42, blank=True, null=True)
|
||||||
|
type_id = models.IntegerField(blank=True, null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'answers_incorrect'
|
db_table = 'topics'
|
||||||
unique_together = (('lp_id', 'q_id'),)
|
db_table_comment = 'Themen'
|
||||||
|
|
||||||
|
|
||||||
class LearnProgress(models.Model):
|
|
||||||
lp_id = models.AutoField(primary_key=True, db_comment='Schlüssel')
|
|
||||||
user_id = models.CharField(max_length=15)
|
|
||||||
root = models.CharField(max_length=45)
|
|
||||||
date = models.DateTimeField(db_comment='Uhrzeit und Datum')
|
|
||||||
t_id = models.IntegerField(db_comment='Themen ID')
|
|
||||||
number = models.IntegerField(db_comment='Anzahl der Fragen')
|
|
||||||
correct = models.IntegerField(db_comment='Richtige Fragen')
|
|
||||||
wrong = models.IntegerField(db_comment='Anzahl der falschen Antworten')
|
|
||||||
percentage = models.DecimalField(max_digits=5, decimal_places=0, blank=True, null=True)
|
|
||||||
uploaded = models.IntegerField(blank=True, null=True)
|
|
||||||
passed = models.IntegerField()
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
db_table = 'learnprogress'
|
|
||||||
|
|
||||||
|
|
||||||
class QuestionDescription(models.Model):
|
|
||||||
q_id = models.IntegerField(primary_key=True)
|
|
||||||
description = models.TextField()
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
db_table = 'question_description'
|
|
||||||
|
|
||||||
|
|
||||||
class Question(models.Model):
|
|
||||||
q_id = models.AutoField(primary_key=True, db_comment='Primärschlüssel')
|
|
||||||
qt_id = models.IntegerField(db_comment='Fragetyp')
|
|
||||||
t_id = models.IntegerField(db_comment='Topic_id')
|
|
||||||
question = models.TextField(db_comment='Frage')
|
|
||||||
active = models.CharField(max_length=1)
|
|
||||||
description = models.CharField(max_length=1)
|
|
||||||
ref_q_id = models.IntegerField(blank=True, null=True)
|
|
||||||
translationstatus = models.IntegerField(blank=True, null=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
db_table = 'questions'
|
|
||||||
db_table_comment = 'Fragen'
|
|
||||||
|
|
||||||
|
|
||||||
class QuestionType(models.Model):
|
class QuestionType(models.Model):
|
||||||
qt_id = models.AutoField(primary_key=True, db_comment='Fragetypenschlüssel')
|
|
||||||
de = models.CharField(db_column='DE', max_length=25, db_comment='Fragetyp') # Field name made lowercase.
|
de = models.CharField(db_column='DE', max_length=25, db_comment='Fragetyp') # Field name made lowercase.
|
||||||
en = models.CharField(db_column='EN', max_length=25) # Field name made lowercase.
|
en = models.CharField(db_column='EN', max_length=25) # Field name made lowercase.
|
||||||
fr = models.CharField(db_column='FR', max_length=25, blank=True, null=True) # Field name made lowercase.
|
fr = models.CharField(db_column='FR', max_length=25, blank=True, null=True) # Field name made lowercase.
|
||||||
|
@ -90,51 +49,36 @@ class QuestionTypeV2(models.Model):
|
||||||
db_table_comment = 'Fragetypen'
|
db_table_comment = 'Fragetypen'
|
||||||
|
|
||||||
|
|
||||||
class SchemaVersion(models.Model):
|
class Question(models.Model):
|
||||||
version = models.IntegerField(unique=True)
|
qt_id = models.IntegerField(db_comment='Fragetyp')
|
||||||
when = models.DateTimeField()
|
t_id = models.IntegerField(db_comment='Topic_id')
|
||||||
|
question = models.TextField(db_comment='Frage')
|
||||||
|
active = models.CharField(max_length=1)
|
||||||
|
description = models.CharField(max_length=1)
|
||||||
|
ref_q_id = models.IntegerField(blank=True, null=True)
|
||||||
|
translationstatus = models.IntegerField(blank=True, null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'schema_version'
|
db_table = 'questions'
|
||||||
|
db_table_comment = 'Fragen'
|
||||||
|
|
||||||
|
|
||||||
class Statistics(models.Model):
|
class QuestionDescription(models.Model):
|
||||||
stat_id = models.AutoField(primary_key=True, db_comment='Primärschlüssel')
|
q_id = models.IntegerField(primary_key=True)
|
||||||
q_id = models.IntegerField(db_comment='Frage Id')
|
description = models.TextField()
|
||||||
count = models.IntegerField(db_comment='Zählen von Antworten')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'statistics'
|
db_table = 'question_description'
|
||||||
|
|
||||||
|
|
||||||
class Temp(models.Model):
|
class Answer(models.Model):
|
||||||
uid = models.CharField(max_length=10, blank=True, null=True)
|
q_id = models.IntegerField()
|
||||||
number = models.IntegerField(blank=True, null=True)
|
answer = models.TextField()
|
||||||
|
correct = models.IntegerField()
|
||||||
|
ref_a_id = models.IntegerField(blank=True, null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'temp'
|
db_table = 'answers'
|
||||||
|
|
||||||
|
|
||||||
class TopicType(models.Model):
|
|
||||||
type_id = models.AutoField(primary_key=True)
|
|
||||||
text = models.CharField(max_length=255)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
db_table = 'topic_type'
|
|
||||||
|
|
||||||
|
|
||||||
class Topic(models.Model):
|
|
||||||
t_id = models.AutoField(primary_key=True, db_comment='Primärschlüssel')
|
|
||||||
topic = models.CharField(unique=True, max_length=50, db_comment='Thema')
|
|
||||||
active = models.IntegerField()
|
|
||||||
numofqu = models.IntegerField(db_column='numOfQu') # Field name made lowercase.
|
|
||||||
percentage = models.IntegerField()
|
|
||||||
lang = models.CharField(max_length=42, blank=True, null=True)
|
|
||||||
type_id = models.IntegerField(blank=True, null=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
db_table = 'topics'
|
|
||||||
db_table_comment = 'Themen'
|
|
||||||
|
|
||||||
|
|
||||||
class User(models.Model):
|
class User(models.Model):
|
||||||
|
@ -166,3 +110,52 @@ class UserAddress(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'user_address'
|
db_table = 'user_address'
|
||||||
unique_together = (('user_id', 'root'),)
|
unique_together = (('user_id', 'root'),)
|
||||||
|
|
||||||
|
|
||||||
|
class LearnProgress(models.Model):
|
||||||
|
user_id = models.CharField(max_length=15)
|
||||||
|
root = models.CharField(max_length=45)
|
||||||
|
date = models.DateTimeField(db_comment='Uhrzeit und Datum')
|
||||||
|
t_id = models.IntegerField(db_comment='Themen ID')
|
||||||
|
number = models.IntegerField(db_comment='Anzahl der Fragen')
|
||||||
|
correct = models.IntegerField(db_comment='Richtige Fragen')
|
||||||
|
wrong = models.IntegerField(db_comment='Anzahl der falschen Antworten')
|
||||||
|
percentage = models.DecimalField(max_digits=5, decimal_places=0, blank=True, null=True)
|
||||||
|
uploaded = models.IntegerField(blank=True, null=True)
|
||||||
|
passed = models.IntegerField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'learnprogress'
|
||||||
|
|
||||||
|
|
||||||
|
class IncorrectAnswer(models.Model):
|
||||||
|
lp_id = models.IntegerField(primary_key=True) # The composite primary key (lp_id, q_id) found, that is not supported. The first column is selected.
|
||||||
|
q_id = models.IntegerField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'answers_incorrect'
|
||||||
|
unique_together = (('lp_id', 'q_id'),)
|
||||||
|
|
||||||
|
|
||||||
|
class SchemaVersion(models.Model):
|
||||||
|
version = models.IntegerField(unique=True)
|
||||||
|
when = models.DateTimeField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'schema_version'
|
||||||
|
|
||||||
|
|
||||||
|
class Statistics(models.Model):
|
||||||
|
q_id = models.IntegerField(db_comment='Frage Id')
|
||||||
|
count = models.IntegerField(db_comment='Zählen von Antworten')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'statistics'
|
||||||
|
|
||||||
|
|
||||||
|
class Temp(models.Model):
|
||||||
|
uid = models.CharField(max_length=10, blank=True, null=True)
|
||||||
|
number = models.IntegerField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'temp'
|
||||||
|
|
Loading…
Reference in a new issue