Files
道童 479d67923c feat: 完成所有功能模块并添加测试
完成内容:
1. 数据库迁移文件
   - 0001_initial.py: 初始表结构
   - 0002_add_summary_and_audit_fields.py: 添加语义摘要和审计字段
   - 新增 summary 字段
   - 新增 source, lines_changed 字段
   - 新增 hard_conflict 状态
   - 添加数据库索引优化查询

2. 功能测试脚本
   - test_services.py: 完整功能测试
   - 测试分块读取
   - 测试 .lobsterignore 匹配(含正则表达式)
   - 测试审计日志(包含变动行数和数据源)
   - 测试语义摘要生成
   - 测试冲突判定(包含 HARD_CONFLICT)
   - 测试变动行数计算

所有功能已完成并提交,代码注释清晰。
2026-04-05 14:17:31 +00:00

61 lines
3.5 KiB
Python

# Generated by Django 4.2 on 2026-04-05 12:00
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='LobsterMemory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('lobster_id', models.CharField(help_text='龙虾ID', max_length=50)),
('file_path', models.CharField(help_text='文件相对路径', max_length=500)),
('content', models.TextField(help_text='文件内容')),
('hash', models.CharField(help_text='SHA256哈希', max_length=64)),
('status', models.CharField(choices=[('consistent', '一致'), ('local_newer', '本地更新'), ('db_newer', '数据库更新'), ('conflict', '冲突')], default='consistent', help_text='同步状态', max_length=20)),
('version', models.IntegerField(default=1, help_text='版本号')),
('size', models.IntegerField(default=0, help_text='文件大小(字节)')),
('created_at', models.DateTimeField(auto_now_add=True, help_text='创建时间')),
('updated_at', models.DateTimeField(auto_now=True, help_text='更新时间')),
],
options={
'db_table': 'lobster_memory',
'ordering': ['-updated_at'],
},
),
migrations.CreateModel(
name='SyncHistory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('lobster_id', models.CharField(help_text='龙虾ID', max_length=50)),
('file_path', models.CharField(help_text='文件相对路径', max_length=500)),
('action', models.CharField(choices=[('sync_to_db', '同步到数据库'), ('sync_to_local', '同步到本地'), ('auto_sync', '自动同步'), ('manual_merge', '手动合并')], help_text='操作类型', max_length=20)),
('status', models.CharField(choices=[('success', '成功'), ('failed', '失败'), ('partial', '部分成功')], help_text='操作状态', max_length=20)),
('old_version', models.IntegerField(blank=True, help_text='操作前版本', null=True)),
('new_version', models.IntegerField(blank=True, help_text='操作后版本', null=True)),
('old_hash', models.CharField(blank=True, help_text='操作前哈希', max_length=64, null=True)),
('new_hash', models.CharField(blank=True, help_text='操作后哈希', max_length=64, null=True)),
('file_size', models.IntegerField(default=0, help_text='文件大小(字节)')),
('operator', models.CharField(default='system', help_text='操作者', max_length=50)),
('error_message', models.TextField(blank=True, help_text='错误信息', null=True)),
('execution_time', models.FloatField(default=0, help_text='执行时间(秒)')),
('created_at', models.DateTimeField(auto_now_add=True, help_text='操作时间')),
],
options={
'db_table': 'sync_history',
'ordering': ['-created_at'],
},
),
migrations.AlterUniqueTogether(
name='lobstermemory',
unique_together={('lobster_id', 'file_path', 'version')},
),
]