WIP
This commit is contained in:
parent
e70a0584c9
commit
a7a5b5c8ea
43 changed files with 5531 additions and 9 deletions
289
control_plane/migrations/0001_initial.py
Normal file
289
control_plane/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
# Generated by Django 6.0.4 on 2026-04-27 12:21
|
||||
|
||||
import uuid
|
||||
|
||||
import auto_prefetch
|
||||
import django.core.validators
|
||||
import django.db.models.deletion
|
||||
import django.db.models.manager
|
||||
from django.db import migrations
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = []
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="HostedSite",
|
||||
fields=[
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
("slug", models.SlugField(max_length=64)),
|
||||
("display_name", models.CharField(max_length=255)),
|
||||
("working_directory", models.CharField(default=".", max_length=255)),
|
||||
("wsgi_module", models.CharField(max_length=255)),
|
||||
(
|
||||
"service_port",
|
||||
models.PositiveIntegerField(
|
||||
default=8000,
|
||||
validators=[
|
||||
django.core.validators.MinValueValidator(1024),
|
||||
django.core.validators.MaxValueValidator(65535),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ("tenant__slug", "slug"),
|
||||
"abstract": False,
|
||||
"base_manager_name": "prefetch_manager",
|
||||
},
|
||||
managers=[
|
||||
("objects", django.db.models.manager.Manager()),
|
||||
("prefetch_manager", django.db.models.manager.Manager()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Deployment",
|
||||
fields=[
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
("idempotency_key", models.CharField(max_length=64, unique=True)),
|
||||
("source_sha256", models.CharField(max_length=64)),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("queued", "Queued"),
|
||||
("provisioning", "Provisioning"),
|
||||
("booting", "Booting"),
|
||||
("running", "Running"),
|
||||
("failed", "Failed"),
|
||||
("stopped", "Stopped"),
|
||||
("destroying", "Destroying"),
|
||||
("destroyed", "Destroyed"),
|
||||
],
|
||||
default="queued",
|
||||
max_length=32,
|
||||
),
|
||||
),
|
||||
(
|
||||
"guest_ipv4",
|
||||
models.GenericIPAddressField(
|
||||
blank=True,
|
||||
null=True,
|
||||
protocol="IPv4",
|
||||
),
|
||||
),
|
||||
(
|
||||
"guest_port",
|
||||
models.PositiveIntegerField(
|
||||
default=8000,
|
||||
validators=[
|
||||
django.core.validators.MinValueValidator(1024),
|
||||
django.core.validators.MaxValueValidator(65535),
|
||||
],
|
||||
),
|
||||
),
|
||||
(
|
||||
"firecracker_vm_id",
|
||||
models.CharField(blank=True, max_length=64, null=True, unique=True),
|
||||
),
|
||||
("last_error", models.TextField(blank=True)),
|
||||
("started_at", models.DateTimeField(blank=True, null=True)),
|
||||
("finished_at", models.DateTimeField(blank=True, null=True)),
|
||||
(
|
||||
"hosted_site",
|
||||
auto_prefetch.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="deployments",
|
||||
to="control_plane.hostedsite",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ("-created_at",),
|
||||
"abstract": False,
|
||||
"base_manager_name": "prefetch_manager",
|
||||
},
|
||||
managers=[
|
||||
("objects", django.db.models.manager.Manager()),
|
||||
("prefetch_manager", django.db.models.manager.Manager()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="RuntimeService",
|
||||
fields=[
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"kind",
|
||||
models.CharField(
|
||||
choices=[("postgresql", "PostgreSQL"), ("redis", "Redis")],
|
||||
max_length=32,
|
||||
),
|
||||
),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("queued", "Queued"),
|
||||
("provisioning", "Provisioning"),
|
||||
("ready", "Ready"),
|
||||
("failed", "Failed"),
|
||||
("destroying", "Destroying"),
|
||||
("destroyed", "Destroyed"),
|
||||
],
|
||||
default="queued",
|
||||
max_length=32,
|
||||
),
|
||||
),
|
||||
("container_name", models.CharField(max_length=128, unique=True)),
|
||||
("network_name", models.CharField(max_length=128)),
|
||||
("hostname", models.CharField(max_length=128)),
|
||||
("image_reference", models.CharField(max_length=255)),
|
||||
(
|
||||
"internal_port",
|
||||
models.PositiveIntegerField(
|
||||
validators=[
|
||||
django.core.validators.MinValueValidator(1),
|
||||
django.core.validators.MaxValueValidator(65535),
|
||||
],
|
||||
),
|
||||
),
|
||||
("connection_username", models.CharField(blank=True, max_length=63)),
|
||||
("connection_database", models.CharField(blank=True, max_length=63)),
|
||||
("connection_secret_ref", models.CharField(max_length=255)),
|
||||
(
|
||||
"deployment",
|
||||
auto_prefetch.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="runtime_services",
|
||||
to="control_plane.deployment",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ("deployment__created_at", "kind"),
|
||||
"abstract": False,
|
||||
"base_manager_name": "prefetch_manager",
|
||||
},
|
||||
managers=[
|
||||
("objects", django.db.models.manager.Manager()),
|
||||
("prefetch_manager", django.db.models.manager.Manager()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Tenant",
|
||||
fields=[
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
("slug", models.SlugField(max_length=64, unique=True)),
|
||||
("display_name", models.CharField(max_length=255)),
|
||||
],
|
||||
options={
|
||||
"ordering": ("slug",),
|
||||
"abstract": False,
|
||||
"base_manager_name": "prefetch_manager",
|
||||
"indexes": [models.Index(fields=["slug"], name="tenant_slug_idx")],
|
||||
},
|
||||
managers=[
|
||||
("objects", django.db.models.manager.Manager()),
|
||||
("prefetch_manager", django.db.models.manager.Manager()),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="hostedsite",
|
||||
name="tenant",
|
||||
field=auto_prefetch.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="hosted_sites",
|
||||
to="control_plane.tenant",
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="deployment",
|
||||
index=models.Index(
|
||||
fields=["hosted_site", "status"],
|
||||
name="deploy_site_status_idx",
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="deployment",
|
||||
index=models.Index(
|
||||
fields=["status", "created_at"],
|
||||
name="deploy_status_created_idx",
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="runtimeservice",
|
||||
index=models.Index(
|
||||
fields=["deployment", "kind"],
|
||||
name="service_deploy_kind_idx",
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="runtimeservice",
|
||||
index=models.Index(
|
||||
fields=["kind", "status"],
|
||||
name="service_kind_status_idx",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="runtimeservice",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("deployment", "kind"),
|
||||
name="runtime_service_unique_deployment_kind",
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="hostedsite",
|
||||
index=models.Index(fields=["tenant", "slug"], name="site_tenant_slug_idx"),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="hostedsite",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("tenant", "slug"),
|
||||
name="hosted_site_unique_tenant_slug",
|
||||
),
|
||||
),
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue