infrasynth-backend-kit/infrasynth/scheduler/migrations/0001_initial.py
jcv-dev 551b42eab5 feat: production-hardening pass across the kit
Close the gaps between the documented contract (API-STANDARD, TENANCY,
ENTITLEMENTS) and the implementation, and remove committed build artifacts.

Security:
- verify + process inbound webhooks (HMAC/handler verify, size limit,
  timestamp tolerance, idempotency via InboundEvent.external_id)
- real 2FA login flow (pre-auth challenge; tokens only after verify/recovery)
- wire HybridPermission into security/audit views; add API-key rotate and
  users/<id>/permissions|roles endpoints
- tenant-scoped throttling on by default; webhook replay protection
- verify MercadoPago webhook signatures
- login brute-force guard, configurable password policy, real ALTCHA PoW

Correctness:
- apply verified billing webhooks idempotently (subscription/entitlement/
  invoice/PaymentTransaction); scheduled payment lifecycle jobs
- capture audit update diffs automatically; add audit retention purge
- working notification retries, per-channel rate limits, log retention
- pluggable virus scanner, upload-size limit, pipeline toggle
- feature rollout %/environment targeting; settings-driven registrations
- workflow guards (instance cap, route depth, self-assignment, clone on re-entry)
- wire every previously-dead INFRASYNTH_* setting; drop truly dead ones

Delivery:
- README + CHANGELOG; CI format check + coverage gate
- keep test media out of the tree; untrack .coverage, __pycache__,
  egg-info, docs/ and invoice artifacts
2026-09-24 10:41:21 -05:00

102 lines
3.9 KiB
Python

# Generated by Django 5.2.17 on 2026-09-24 14:10
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("tenancy", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="ScheduledTask",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("name", models.CharField(max_length=200)),
("task_path", models.CharField(max_length=500)),
(
"schedule_type",
models.CharField(
choices=[("cron", "Cron"), ("interval", "Interval"), ("date", "Date"), ("manual", "Manual")],
max_length=20,
),
),
("schedule_config", models.JSONField(default=dict)),
("args", models.JSONField(default=list)),
("kwargs", models.JSONField(default=dict)),
("is_active", models.BooleanField(default=True)),
("queue", models.CharField(blank=True, max_length=100)),
("priority", models.IntegerField(default=0)),
(
"tenant",
models.ForeignKey(
editable=False,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="tenancy.tenant",
),
),
],
options={
"db_table": "scheduler_task",
},
),
migrations.CreateModel(
name="TaskExecution",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("celery_task_id", models.CharField(blank=True, max_length=255)),
(
"status",
models.CharField(
choices=[
("pending", "Pending"),
("running", "Running"),
("success", "Success"),
("failure", "Failure"),
],
default="pending",
max_length=20,
),
),
("started_at", models.DateTimeField(blank=True, null=True)),
("completed_at", models.DateTimeField(blank=True, null=True)),
("result", models.TextField(blank=True)),
("error_traceback", models.TextField(blank=True)),
("worker_hostname", models.CharField(blank=True, max_length=255)),
(
"task",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="executions",
to="infrasynth_scheduler.scheduledtask",
),
),
(
"tenant",
models.ForeignKey(
editable=False,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="tenancy.tenant",
),
),
],
options={
"db_table": "scheduler_execution",
"ordering": ["-started_at"],
},
),
migrations.AddConstraint(
model_name="scheduledtask",
constraint=models.UniqueConstraint(fields=("tenant", "name"), name="uniq_scheduled_task_name_per_tenant"),
),
migrations.AddIndex(
model_name="taskexecution",
index=models.Index(fields=["tenant_id", "status"], name="scheduler_e_tenant__28f692_idx"),
),
]