chore: import existing codebase as baseline
Verify / verify (push) Failing after 1m20s

This commit is contained in:
Jayway Liu
2026-09-26 01:12:10 +08:00
commit 0ac0c4eb56
77 changed files with 14155 additions and 0 deletions
+224
View File
@@ -0,0 +1,224 @@
# Generated by Django 5.2.17 on 2026-09-22 16:35
import uuid
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="Organization",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("name", models.CharField(max_length=160)),
],
),
migrations.CreateModel(
name="Throttle",
fields=[
("key", models.CharField(max_length=64, primary_key=True, serialize=False)),
("count", models.PositiveIntegerField(default=0)),
("expires_at", models.DateTimeField()),
],
),
migrations.CreateModel(
name="Dataset",
fields=[
(
"id",
models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
),
("name", models.CharField(max_length=200)),
("file", models.FileField(upload_to="sources/%Y/%m")),
("sha256", models.CharField(max_length=64)),
("status", models.CharField(default="mapping", max_length=16)),
("profile", models.JSONField(default=dict)),
("mapping", models.JSONField(default=dict)),
("quality", models.JSONField(default=dict)),
("row_count", models.PositiveIntegerField(default=0)),
("periods", models.JSONField(default=list)),
("error", models.TextField(blank=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
("started_at", models.DateTimeField(null=True)),
("finished_at", models.DateTimeField(null=True)),
(
"created_by",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL
),
),
(
"organization",
models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to="finance.organization"),
),
],
),
migrations.CreateModel(
name="Membership",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"role",
models.CharField(
choices=[("admin", "管理员"), ("analyst", "分析师"), ("viewer", "查看者")],
max_length=16,
),
),
("departments", models.JSONField(default=list)),
(
"user",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"organization",
models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to="finance.organization"),
),
],
),
migrations.CreateModel(
name="Audit",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("action", models.CharField(max_length=64)),
("resource", models.CharField(blank=True, max_length=100)),
("details", models.JSONField(default=dict)),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL
),
),
(
"organization",
models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to="finance.organization"),
),
],
),
migrations.CreateModel(
name="Preference",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("value", models.JSONField(default=dict)),
("revision", models.PositiveIntegerField(default=1)),
(
"dataset",
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="finance.dataset"),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
),
migrations.CreateModel(
name="Fact",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("period", models.CharField(max_length=7)),
("dimensions", models.JSONField(default=dict)),
("customer", models.CharField(max_length=256, null=True)),
("revenue", models.DecimalField(decimal_places=4, max_digits=22)),
("cost", models.DecimalField(decimal_places=4, max_digits=22, null=True)),
("gross", models.DecimalField(decimal_places=4, max_digits=22, null=True)),
("quantity", models.DecimalField(decimal_places=4, max_digits=22, null=True)),
("list_amount", models.DecimalField(decimal_places=4, max_digits=22, null=True)),
("discount", models.DecimalField(decimal_places=4, max_digits=22, null=True)),
("source_row", models.PositiveIntegerField()),
("raw", models.JSONField(default=list)),
(
"dataset",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="facts",
to="finance.dataset",
),
),
],
options={
"indexes": [
models.Index(fields=["dataset", "period"], name="finance_fac_dataset_69c9ce_idx")
],
"constraints": [
models.UniqueConstraint(fields=("dataset", "source_row"), name="unique_source_row")
],
},
),
migrations.CreateModel(
name="Investigation",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("key", models.CharField(max_length=64)),
("context", models.JSONField(default=dict)),
("status", models.CharField(default="open", max_length=16)),
("note", models.TextField(blank=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"dataset",
models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to="finance.dataset"),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL
),
),
],
options={
"constraints": [
models.UniqueConstraint(fields=("dataset", "user", "key"), name="unique_investigation")
],
},
),
migrations.AddConstraint(
model_name="dataset",
constraint=models.UniqueConstraint(fields=("organization", "sha256"), name="unique_org_source"),
),
migrations.AddConstraint(
model_name="preference",
constraint=models.UniqueConstraint(fields=("dataset", "user"), name="unique_preference"),
),
]
@@ -0,0 +1,42 @@
# Generated by Django 5.2.17 on 2026-09-22 16:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("finance", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="fact",
name="cost",
field=models.DecimalField(decimal_places=24, max_digits=44, null=True),
),
migrations.AlterField(
model_name="fact",
name="discount",
field=models.DecimalField(decimal_places=24, max_digits=44, null=True),
),
migrations.AlterField(
model_name="fact",
name="gross",
field=models.DecimalField(decimal_places=24, max_digits=44, null=True),
),
migrations.AlterField(
model_name="fact",
name="list_amount",
field=models.DecimalField(decimal_places=24, max_digits=44, null=True),
),
migrations.AlterField(
model_name="fact",
name="quantity",
field=models.DecimalField(decimal_places=24, max_digits=44, null=True),
),
migrations.AlterField(
model_name="fact",
name="revenue",
field=models.DecimalField(decimal_places=24, max_digits=44),
),
]
+50
View File
@@ -0,0 +1,50 @@
import uuid
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("finance", "0002_alter_fact_cost_alter_fact_discount_alter_fact_gross_and_more"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="FormulaExport",
fields=[
(
"id",
models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
),
("context", models.JSONField(default=dict)),
("departments", models.JSONField(default=list)),
("status", models.CharField(default="queued", max_length=16)),
("path", models.CharField(blank=True, max_length=512)),
("error", models.CharField(blank=True, max_length=500)),
("created_at", models.DateTimeField(auto_now_add=True)),
("finished_at", models.DateTimeField(null=True)),
("expires_at", models.DateTimeField(null=True)),
(
"dataset",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="formula_exports",
to="finance.dataset",
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
),
migrations.AddIndex(
model_name="formulaexport",
index=models.Index(fields=["status", "created_at"], name="finance_for_status_fa1c07_idx"),
),
]
@@ -0,0 +1,50 @@
import uuid
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("finance", "0003_formulaexport"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="FormulaDefinition",
fields=[
(
"id",
models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
),
("normalized_name", models.CharField(max_length=320)),
("definition", models.JSONField()),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"dataset",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="formula_definitions",
to="finance.dataset",
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
migrations.AddConstraint(
model_name="formuladefinition",
constraint=models.UniqueConstraint(
fields=("dataset", "user", "normalized_name"),
name="unique_formula_definition_name",
),
),
]
View File