Files
Jacky 1f98f7152d
CI / test (push) Failing after 1m31s
v0.2 Preview: Construction Plan.
2026-08-08 21:25:27 +08:00

171 lines
8.7 KiB
Python

# Generated by Django 4.2.23 on 2026-08-08 11:15
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Character',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', models.SlugField(unique=True)),
('name', models.CharField(max_length=80)),
('profile', models.TextField(blank=True)),
('metadata', models.JSONField(blank=True, default=dict)),
],
),
migrations.CreateModel(
name='MathBTIAssessment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('version', models.CharField(max_length=30, unique=True)),
('title', models.CharField(max_length=120)),
('definition', models.JSONField()),
('is_published', models.BooleanField(default=False)),
('published_at', models.DateTimeField(blank=True, null=True)),
],
),
migrations.CreateModel(
name='MathIdentity',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=8, unique=True)),
('name', models.CharField(max_length=80)),
('clan', models.CharField(max_length=40)),
('mathematician', models.CharField(max_length=80)),
('description', models.TextField(blank=True)),
('initial_abilities', models.JSONField(blank=True, default=dict)),
('portrait', models.CharField(blank=True, max_length=200)),
],
),
migrations.CreateModel(
name='Story',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', models.SlugField(unique=True)),
('title', models.CharField(max_length=120)),
('summary', models.TextField(blank=True)),
('kind', models.CharField(choices=[('flagship', '旗舰人生'), ('skill', '人物 Skill'), ('special', '特别篇')], default='flagship', max_length=16)),
('estimated_minutes', models.PositiveIntegerField(default=20)),
('is_visible', models.BooleanField(default=True)),
],
),
migrations.CreateModel(
name='UserRelationship',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('trust', models.SmallIntegerField(default=0)),
('rivalry', models.SmallIntegerField(default=0)),
('debt', models.SmallIntegerField(default=0)),
('cooperation', models.SmallIntegerField(default=0)),
('metadata', models.JSONField(blank=True, default=dict)),
('character', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='math_life.character')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='StoryVersion',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('version', models.PositiveIntegerField()),
('content', models.JSONField()),
('is_published', models.BooleanField(default=False)),
('published_at', models.DateTimeField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('story', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='versions', to='math_life.story')),
],
options={
'ordering': ['story', '-version'],
},
),
migrations.CreateModel(
name='StoryRun',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('current_node', models.CharField(max_length=100)),
('state', models.JSONField(default=dict)),
('status', models.CharField(choices=[('active', '进行中'), ('completed', '已完成'), ('abandoned', '已放弃')], default='active', max_length=16)),
('ending_code', models.CharField(blank=True, max_length=80)),
('started_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('completed_at', models.DateTimeField(blank=True, null=True)),
('story_version', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='runs', to='math_life.storyversion')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='story_runs', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-updated_at'],
},
),
migrations.CreateModel(
name='StoryChoice',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sequence', models.PositiveIntegerField()),
('idempotency_key', models.CharField(blank=True, max_length=80, null=True)),
('node_id', models.CharField(max_length=100)),
('choice_index', models.PositiveIntegerField()),
('choice_text', models.CharField(max_length=300)),
('effects', models.JSONField(blank=True, default=dict)),
('created_at', models.DateTimeField(auto_now_add=True)),
('run', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='math_life.storyrun')),
],
options={
'ordering': ['sequence'],
},
),
migrations.CreateModel(
name='SkillPackage',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('real_person', models.CharField(max_length=120)),
('historical_context', models.TextField()),
('fact_sources', models.JSONField(default=list)),
('fictional_scope', models.TextField()),
('creator', models.CharField(max_length=120)),
('story', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='skill_package', to='math_life.story')),
],
),
migrations.CreateModel(
name='MathBTIResult',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('answers', models.JSONField(default=list)),
('axis_scores', models.JSONField(default=dict)),
('created_at', models.DateTimeField(auto_now_add=True)),
('assessment', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='math_life.mathbtiassessment')),
('identity', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='math_life.mathidentity')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mathbti_results', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created_at'],
},
),
migrations.AddConstraint(
model_name='userrelationship',
constraint=models.UniqueConstraint(fields=('user', 'character'), name='unique_user_character'),
),
migrations.AddConstraint(
model_name='storyversion',
constraint=models.UniqueConstraint(fields=('story', 'version'), name='unique_story_version'),
),
migrations.AddConstraint(
model_name='storychoice',
constraint=models.UniqueConstraint(fields=('run', 'sequence'), name='unique_run_choice_sequence'),
),
migrations.AddConstraint(
model_name='storychoice',
constraint=models.UniqueConstraint(fields=('run', 'idempotency_key'), name='unique_run_choice_idempotency'),
),
]