From b92e8871a11247f383bdc30f2fb26663a24dca84 Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 12 Jul 2024 08:41:48 +0200 Subject: [PATCH] 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. --- coldbrew/vpn/migrations/0001_initial.py | 87 +++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 coldbrew/vpn/migrations/0001_initial.py diff --git a/coldbrew/vpn/migrations/0001_initial.py b/coldbrew/vpn/migrations/0001_initial.py new file mode 100644 index 0000000..737a118 --- /dev/null +++ b/coldbrew/vpn/migrations/0001_initial.py @@ -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" + ), + ), + ], + ), + ]