2026-04-09 22:48:54 +03:30
|
|
|
from django.db import migrations, models
|
2026-04-03 23:51:00 +03:30
|
|
|
import django.db.models.deletion
|
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
initial = True
|
|
|
|
|
|
|
|
|
|
dependencies = [
|
|
|
|
|
("farm_hub", "0006_seed_expanded_product_catalog"),
|
2026-04-09 22:48:54 +03:30
|
|
|
("sensor_catalog", "0003_sensorcatalog_code"),
|
2026-04-03 23:51:00 +03:30
|
|
|
]
|
|
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
|
migrations.CreateModel(
|
|
|
|
|
name="AccessFeature",
|
|
|
|
|
fields=[
|
|
|
|
|
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
|
|
|
|
("uuid", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, unique=True)),
|
2026-04-09 22:48:54 +03:30
|
|
|
("code", models.CharField(db_index=True, max_length=150, unique=True)),
|
2026-04-03 23:51:00 +03:30
|
|
|
("name", models.CharField(max_length=255)),
|
|
|
|
|
("description", models.TextField(blank=True, default="")),
|
2026-04-09 22:48:54 +03:30
|
|
|
("feature_type", models.CharField(choices=[("page", "Page"), ("widget", "Widget"), ("action", "Action")], default="page", max_length=32)),
|
2026-04-03 23:51:00 +03:30
|
|
|
("default_enabled", models.BooleanField(default=False)),
|
|
|
|
|
("metadata", models.JSONField(blank=True, default=dict)),
|
2026-04-09 22:48:54 +03:30
|
|
|
("is_active", models.BooleanField(default=True)),
|
2026-04-03 23:51:00 +03:30
|
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
|
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
|
|
|
],
|
2026-04-09 22:48:54 +03:30
|
|
|
options={"db_table": "access_features", "ordering": ["name"]},
|
2026-04-03 23:51:00 +03:30
|
|
|
),
|
|
|
|
|
migrations.CreateModel(
|
|
|
|
|
name="SubscriptionPlan",
|
|
|
|
|
fields=[
|
|
|
|
|
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
|
|
|
|
("uuid", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, unique=True)),
|
2026-04-09 22:48:54 +03:30
|
|
|
("code", models.CharField(db_index=True, max_length=100, unique=True)),
|
|
|
|
|
("name", models.CharField(max_length=255)),
|
2026-04-03 23:51:00 +03:30
|
|
|
("description", models.TextField(blank=True, default="")),
|
|
|
|
|
("metadata", models.JSONField(blank=True, default=dict)),
|
|
|
|
|
("is_active", models.BooleanField(default=True)),
|
|
|
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
|
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
|
|
|
],
|
2026-04-09 22:48:54 +03:30
|
|
|
options={"db_table": "access_subscription_plans", "ordering": ["name"]},
|
2026-04-03 23:51:00 +03:30
|
|
|
),
|
|
|
|
|
migrations.CreateModel(
|
|
|
|
|
name="AccessRule",
|
|
|
|
|
fields=[
|
|
|
|
|
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
|
|
|
|
("uuid", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, unique=True)),
|
2026-04-09 22:48:54 +03:30
|
|
|
("code", models.CharField(db_index=True, max_length=150, unique=True)),
|
2026-04-03 23:51:00 +03:30
|
|
|
("name", models.CharField(max_length=255)),
|
|
|
|
|
("description", models.TextField(blank=True, default="")),
|
|
|
|
|
("priority", models.PositiveIntegerField(default=100)),
|
2026-04-09 22:48:54 +03:30
|
|
|
("effect", models.CharField(choices=[("allow", "Allow"), ("deny", "Deny")], default="allow", max_length=16)),
|
2026-04-03 23:51:00 +03:30
|
|
|
("metadata", models.JSONField(blank=True, default=dict)),
|
2026-04-09 22:48:54 +03:30
|
|
|
("is_active", models.BooleanField(default=True)),
|
2026-04-03 23:51:00 +03:30
|
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
|
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
|
|
|
("farm_types", models.ManyToManyField(blank=True, related_name="access_rules", to="farm_hub.farmtype")),
|
|
|
|
|
("features", models.ManyToManyField(blank=True, related_name="rules", to="access_control.accessfeature")),
|
|
|
|
|
("products", models.ManyToManyField(blank=True, related_name="access_rules", to="farm_hub.product")),
|
2026-04-09 22:48:54 +03:30
|
|
|
("sensor_catalogs", models.ManyToManyField(blank=True, related_name="access_rules", to="sensor_catalog.sensorcatalog")),
|
|
|
|
|
("subscription_plans", models.ManyToManyField(blank=True, related_name="access_rules", to="access_control.subscriptionplan")),
|
2026-04-03 23:51:00 +03:30
|
|
|
],
|
2026-04-09 22:48:54 +03:30
|
|
|
options={"db_table": "access_rules", "ordering": ["priority", "name"]},
|
2026-04-03 23:51:00 +03:30
|
|
|
),
|
|
|
|
|
]
|