2024-08-05 22:04:15 -04:00
|
|
|
# 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(
|
2024-08-26 23:45:39 -04:00
|
|
|
db_persist=True,
|
2024-08-05 22:04:15 -04:00
|
|
|
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",),
|
|
|
|
),
|
|
|
|
]
|