feat(migrations): add initial VPN and Device models

Introduce initial database migration to create VPN and Device models.
These models include fields for UUID primary keys, encrypted keys,
and subnet fields, with foreign key relations to user accounts and
VPN instances. This migration sets up essential entities for the VPN
module, providing the foundational structure for VPN and device
management.
This commit is contained in:
Kumi 2024-07-12 08:41:48 +02:00
parent 11e8fe8912
commit b92e8871a1
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -0,0 +1,87 @@
# Generated by Django 5.0.6 on 2024-07-12 06:39
import coldbrew.vpn.fields
import django.core.validators
import django.db.models.deletion
import encrypted_model_fields.fields
import uuid
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="VPN",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4, primary_key=True, serialize=False
),
),
("name", models.CharField(max_length=128)),
(
"port",
models.IntegerField(
blank=True,
null=True,
unique=True,
validators=[
django.core.validators.MinValueValidator(10000),
django.core.validators.MaxValueValidator(40000),
],
),
),
(
"private_key",
encrypted_model_fields.fields.EncryptedCharField(
blank=True, null=True
),
),
("public_key", models.CharField(blank=True, max_length=128, null=True)),
(
"ipv4_subnet",
coldbrew.vpn.fields.SubnetField(max_length=43, unique=True),
),
(
"ipv6_subnet",
coldbrew.vpn.fields.SubnetField(max_length=43, unique=True),
),
(
"owner",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
migrations.CreateModel(
name="Device",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4, primary_key=True, serialize=False
),
),
("name", models.CharField(max_length=128)),
("public_key", models.CharField(max_length=128)),
("preshared_key", encrypted_model_fields.fields.EncryptedCharField()),
(
"vpn",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="vpn.vpn"
),
),
],
),
]