cmsmanage/reservations/migrations/0001_initial.py

114 lines
3.8 KiB
Python
Raw Normal View History

# Generated by Django 5.0.7 on 2024-08-05 20:43
import django.db.models.deletion
import django.db.models.expressions
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="Resource",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=256)),
("min_length", models.DurationField()),
("max_length", models.DurationField()),
("google_calendar", models.CharField(max_length=1024, unique=True)),
(
"parent",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="children",
to="reservations.resource",
),
),
],
),
migrations.CreateModel(
name="Reservation",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("start", models.DateTimeField()),
("end", models.DateTimeField()),
(
"google_calendar_event_id",
models.CharField(
blank=True, max_length=1024, null=True, unique=True
),
),
(
"duration",
models.GeneratedField(
db_persist=False,
expression=django.db.models.expressions.CombinedExpression(
models.F("end"), "-", models.F("start")
),
output_field=models.DurationField(),
),
),
(
"resources",
models.ManyToManyField(blank=True, to="reservations.resource"),
),
],
),
migrations.AddConstraint(
model_name="reservation",
constraint=models.CheckConstraint(
check=models.Q(("end__gt", models.F("start"))), name="end_after_start"
),
),
migrations.CreateModel(
name="UserReservation",
fields=[
(
"reservation_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="reservations.reservation",
),
),
(
"user",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
bases=("reservations.reservation",),
),
]