diff --git a/src/client/src/app/+state/events/actions/add-event-timeslot.action.ts b/src/client/src/app/+state/events/actions/add-event-timeslot.action.ts index c661813..acb3d1e 100644 --- a/src/client/src/app/+state/events/actions/add-event-timeslot.action.ts +++ b/src/client/src/app/+state/events/actions/add-event-timeslot.action.ts @@ -18,7 +18,7 @@ export const addEventTimeslotAction = createHttpAction< { eventId: string; time: Time; - mapId: string; + mapId: string | null; isFallbackAllowed: boolean; }, EventTimeslot diff --git a/src/client/src/app/+state/events/actions/update-event-timeslot.action.ts b/src/client/src/app/+state/events/actions/update-event-timeslot.action.ts index 294fca6..d774dbf 100644 --- a/src/client/src/app/+state/events/actions/update-event-timeslot.action.ts +++ b/src/client/src/app/+state/events/actions/update-event-timeslot.action.ts @@ -15,7 +15,7 @@ export const updateEventTimeslotAction = createHttpAction<{ eventId: string; timeslotId: string; changes: { - mapId?: string; + mapId?: string | null; isFallbackAllowed?: boolean; }; }>()(EVENTS_ACTION_SCOPE, 'Update Event Timeslot'); diff --git a/src/client/src/app/components/events/event-details/event-details.component.html b/src/client/src/app/components/events/event-details/event-details.component.html index 7543702..7499d2f 100644 --- a/src/client/src/app/components/events/event-details/event-details.component.html +++ b/src/client/src/app/components/events/event-details/event-details.component.html @@ -45,6 +45,7 @@ [label]="translations.events_start()" (onClick)="startEvent()" [loading]="isStartBusy()" + [disabled]="!allowToStart()" /> } @@ -76,9 +77,11 @@

{{ translations.events_timeslots() }}

timeslot.time.minute | number: '2.0-0' }} - @if (maps()[timeslot.mapId]; as map) { - - {{ map.name }} + @if (timeslot.mapId) { + @if (maps()[timeslot.mapId]; as map) { + + {{ map.name }} + } } {{ timeslot.playerIds.length }} @@ -118,9 +121,11 @@

timeslot.time.minute | number: '2.0-0' }} - @if (maps()[timeslot.mapId]; as map) { - - {{ map.name }} + @if (timeslot.mapId) { + @if (maps()[timeslot.mapId]; as map) { + + {{ map.name }} + } }

@for (instance of timeslot.instances; track ii; let ii = $index) { diff --git a/src/client/src/app/components/events/event-details/event-details.component.ts b/src/client/src/app/components/events/event-details/event-details.component.ts index 5151364..7870c61 100644 --- a/src/client/src/app/components/events/event-details/event-details.component.ts +++ b/src/client/src/app/components/events/event-details/event-details.component.ts @@ -92,6 +92,13 @@ export class EventDetailsComponent { this.canBuildInstances() && this.event() && !this.event()?.startedAt && this.hasInstances() ); + protected readonly allowToStart = computed( + () => + !this.event() + ?.timeslots.filter(x => x.instances.length > 0) + .some(x => x.mapId === null || x.mapId === undefined) + ); + constructor() { this._store.dispatch(loadMapsAction({ reload: false })); this._store.dispatch(loadUsersAction({ reload: false })); diff --git a/src/client/src/app/components/events/event-timeslot-dialog/event-timeslot-dialog.component.html b/src/client/src/app/components/events/event-timeslot-dialog/event-timeslot-dialog.component.html index 5cad197..15b73a2 100644 --- a/src/client/src/app/components/events/event-timeslot-dialog/event-timeslot-dialog.component.html +++ b/src/client/src/app/components/events/event-timeslot-dialog/event-timeslot-dialog.component.html @@ -37,7 +37,7 @@ - + diff --git a/src/client/src/app/components/events/event-timeslot-dialog/event-timeslot-dialog.component.ts b/src/client/src/app/components/events/event-timeslot-dialog/event-timeslot-dialog.component.ts index d95c76f..5b47943 100644 --- a/src/client/src/app/components/events/event-timeslot-dialog/event-timeslot-dialog.component.ts +++ b/src/client/src/app/components/events/event-timeslot-dialog/event-timeslot-dialog.component.ts @@ -76,7 +76,7 @@ export class EventTimeslotDialogComponent { Validators.required, this.getTimeValidator(), ]), - mapId: this._formBuilder.control(null, [Validators.required]), + mapId: this._formBuilder.control(null), isFallbackAllowed: this._formBuilder.control(false, { nonNullable: true }), }); @@ -104,7 +104,7 @@ export class EventTimeslotDialogComponent { untracked(() => this.form.setValue({ time: dateWithTime(new Date(), timeslot.time), - mapId: timeslot.mapId, + mapId: timeslot.mapId ?? null, isFallbackAllowed: timeslot.isFallbackAllowed, }) ); @@ -144,24 +144,23 @@ export class EventTimeslotDialogComponent { const timeslot = this.timeslot(); if (timeslot) { - if (!mapId) return; this._store.dispatch( updateEventTimeslotAction({ eventId: event.id, timeslotId: timeslot.id, changes: { - mapId, + mapId: mapId ?? null, isFallbackAllowed: !!isFallbackAllowed, }, }) ); } else { - if (!time || !mapId) return; + if (!time) return; this._store.dispatch( addEventTimeslotAction({ eventId: event.id, time: getTimeFromDate(time), - mapId, + mapId: mapId ?? null, isFallbackAllowed: !!isFallbackAllowed, }) ); diff --git a/src/client/src/app/components/events/event-timeslot/event-timeslot.component.html b/src/client/src/app/components/events/event-timeslot/event-timeslot.component.html index 07a418a..16b4b1c 100644 --- a/src/client/src/app/components/events/event-timeslot/event-timeslot.component.html +++ b/src/client/src/app/components/events/event-timeslot/event-timeslot.component.html @@ -66,14 +66,16 @@ > {{ event.registrationDeadline | date: 'medium' : undefined : locale() }} - @if (maps()[timeslot.mapId]; as map) { - - - {{ - translations.events_timeslot_map() - }} - - {{ map.name }} + @if (timeslot.mapId) { + @if (maps()[timeslot.mapId]; as map) { + + + {{ + translations.events_timeslot_map() + }} + + {{ map.name }} + } } diff --git a/src/server/data/Entities/EventTimeslotEntity.cs b/src/server/data/Entities/EventTimeslotEntity.cs index 351b972..f0bd147 100644 --- a/src/server/data/Entities/EventTimeslotEntity.cs +++ b/src/server/data/Entities/EventTimeslotEntity.cs @@ -9,10 +9,10 @@ public class EventTimeslotEntity public required TimeOnly Time { get; set; } public bool IsFallbackAllowed { get; set; } public long EventId { get; set; } - public long MapId { get; set; } + public long? MapId { get; set; } public EventEntity Event { get; set; } = null!; - public MinigolfMapEntity Map { get; set; } = null!; + public MinigolfMapEntity? Map { get; set; } = null; public List Preconfigurations { get; set; } = []; public List Instances { get; set; } = []; @@ -25,7 +25,7 @@ public static void Configure(EntityTypeBuilder builder) builder.Property(x => x.Id).HasColumnName("id").IsRequired().ValueGeneratedOnAdd(); builder.Property(x => x.Time).HasColumnName("time").IsRequired(); builder.Property(x => x.EventId).HasColumnName("event_id").IsRequired(); - builder.Property(x => x.MapId).HasColumnName("map_id").IsRequired(); + builder.Property(x => x.MapId).HasColumnName("map_id"); builder .Property(x => x.IsFallbackAllowed) .HasColumnName("is_fallback_allowed") diff --git a/src/server/domain/Models/Event.cs b/src/server/domain/Models/Event.cs index 7e3c6d8..4e75b1a 100644 --- a/src/server/domain/Models/Event.cs +++ b/src/server/domain/Models/Event.cs @@ -31,7 +31,7 @@ public record Event( public record EventTimeslot( [property: Required] string Id, [property: Required] TimeOnly Time, - [property: Required] string MapId, + string? MapId, [property: Required] bool IsFallbackAllowed, [property: Required] EventInstancePreconfiguration[] Preconfigurations, [property: Required] string[] PlayerIds, diff --git a/src/server/host/Endpoints/Administration/Events/StartEventEndpoint.cs b/src/server/host/Endpoints/Administration/Events/StartEventEndpoint.cs index 00e8d85..e18b464 100644 --- a/src/server/host/Endpoints/Administration/Events/StartEventEndpoint.cs +++ b/src/server/host/Endpoints/Administration/Events/StartEventEndpoint.cs @@ -37,7 +37,8 @@ public override void Configure() EndpointErrors.EventNotFound, EndpointErrors.EventRegistrationNotElapsed, EndpointErrors.EventHasNoInstances, - EndpointErrors.EventAlreadyStarted + EndpointErrors.EventAlreadyStarted, + EndpointErrors.EventMissingMapOnStart ); } @@ -50,7 +51,10 @@ public override async Task HandleAsync(StartEventRequest req, CancellationToken { x.RegistrationDeadline, HasInstances = x.Timeslots.Any(t => t.Instances.Any()), - IsStarted = x.StartedAt != null + IsStarted = x.StartedAt != null, + HasMissingMap = x + .Timeslots.Where(t => t.Instances.Count > 0) + .Any(x => x.MapId == null) }) .FirstOrDefaultAsync(ct); @@ -91,6 +95,13 @@ await this.SendErrorAsync( return; } + if (info.HasMissingMap) + { + Logger.LogWarning(EndpointErrors.EventMissingMapOnStart, eventId); + await this.SendErrorAsync(EndpointErrors.EventMissingMapOnStart, req.EventId, ct); + return; + } + var now = DateTimeOffset.Now; await databaseContext .Events.Where(x => x.Id == eventId) diff --git a/src/server/host/Endpoints/Administration/Events/Timeslots/CreateEventTimeslotEndpoint.cs b/src/server/host/Endpoints/Administration/Events/Timeslots/CreateEventTimeslotEndpoint.cs index eeb7bdc..a0c3aa1 100644 --- a/src/server/host/Endpoints/Administration/Events/Timeslots/CreateEventTimeslotEndpoint.cs +++ b/src/server/host/Endpoints/Administration/Events/Timeslots/CreateEventTimeslotEndpoint.cs @@ -19,7 +19,7 @@ namespace MinigolfFriday.Host.Endpoints.Administration.Events.Timeslots; public record CreateEventTimeslotRequest( [property: Required] string EventId, [property: Required] TimeOnly Time, - [property: Required] string MapId, + string? MapId, [property: Required] bool IsFallbackAllowed ); @@ -32,7 +32,7 @@ public CreateEventTimeslotRequestValidator(IIdService idService) { RuleFor(x => x.EventId).NotEmpty().ValidSqid(idService.Event); RuleFor(x => x.Time).NotEmpty(); - RuleFor(x => x.MapId).NotEmpty().ValidSqid(idService.Map); + When(x => x.MapId != null, () => RuleFor(x => x.MapId!).ValidSqid(idService.Map)); } } @@ -72,14 +72,19 @@ public override async Task HandleAsync(CreateEventTimeslotRequest req, Cancellat await this.SendErrorAsync(EndpointErrors.EventAlreadyStarted, req.EventId, ct); return; } - - var mapId = idService.Map.DecodeSingle(req.MapId); - var mapExists = await databaseContext.Maps.AnyAsync(x => x.Id == mapId, ct); - - if (!mapExists) + long? mapId = null; + if (req.MapId != null) { - Logger.LogWarning(EndpointErrors.MapNotFound, mapId); - ValidationFailures.Add(new ValidationFailure(nameof(req.MapId), "Map does not exist.")); + mapId = idService.Map.DecodeSingle(req.MapId); + var mapExists = await databaseContext.Maps.AnyAsync(x => x.Id == mapId, ct); + + if (!mapExists) + { + Logger.LogWarning(EndpointErrors.MapNotFound, mapId); + ValidationFailures.Add( + new ValidationFailure(nameof(req.MapId), "Map does not exist.") + ); + } } ThrowIfAnyErrors(); @@ -87,7 +92,7 @@ public override async Task HandleAsync(CreateEventTimeslotRequest req, Cancellat var timeslot = new EventTimeslotEntity { Time = req.Time, - Map = databaseContext.MapById(mapId), + Map = mapId != null ? databaseContext.MapById(mapId.Value) : null, Event = databaseContext.EventById(eventId), IsFallbackAllowed = req.IsFallbackAllowed, }; diff --git a/src/server/host/Endpoints/Administration/Events/Timeslots/UpdateEventTimeslotEndpoint.cs b/src/server/host/Endpoints/Administration/Events/Timeslots/UpdateEventTimeslotEndpoint.cs index b83ba08..f0681a1 100644 --- a/src/server/host/Endpoints/Administration/Events/Timeslots/UpdateEventTimeslotEndpoint.cs +++ b/src/server/host/Endpoints/Administration/Events/Timeslots/UpdateEventTimeslotEndpoint.cs @@ -85,6 +85,10 @@ await this.SendErrorAsync( ); } } + else + { + updateBuilder.With(x => x.SetProperty(x => x.MapId, (long?)null)); + } if (req.IsFallbackAllowed != null) updateBuilder.With(x => x.SetProperty(x => x.IsFallbackAllowed, req.IsFallbackAllowed)); diff --git a/src/server/host/Endpoints/EndpointErrors.cs b/src/server/host/Endpoints/EndpointErrors.cs index fca8887..25db2b3 100644 --- a/src/server/host/Endpoints/EndpointErrors.cs +++ b/src/server/host/Endpoints/EndpointErrors.cs @@ -17,6 +17,8 @@ public class EndpointErrors new(404, "An event with the id {0} does not exist.", "EventId"); public static readonly EndpointError.Params1 EventAlreadyStarted = new(409, "The event with id {0} has already been started.", "EventId"); + public static readonly EndpointError.Params1 EventMissingMapOnStart = + new(409, "The event with id {0} has timeslots with players and no map.", "EventId"); public static readonly EndpointError.Params2 EventRegistrationNotElapsed = new( 409, diff --git a/src/server/host/Mappers/EventMapper.cs b/src/server/host/Mappers/EventMapper.cs index 2d4ae36..b54a5df 100644 --- a/src/server/host/Mappers/EventMapper.cs +++ b/src/server/host/Mappers/EventMapper.cs @@ -24,7 +24,7 @@ public EventTimeslot Map(EventTimeslotEntity entity) return new EventTimeslot( idService.EventTimeslot.Encode(entity.Id), entity.Time, - idService.Map.Encode(entity.MapId), + entity.MapId != null ? idService.Map.Encode(entity.MapId.Value) : null, entity.IsFallbackAllowed, entity.Preconfigurations.Select(Map).ToArray(), entity diff --git a/src/server/host/Mappers/PlayerEventMapper.cs b/src/server/host/Mappers/PlayerEventMapper.cs index 5f72f99..1d65368 100644 --- a/src/server/host/Mappers/PlayerEventMapper.cs +++ b/src/server/host/Mappers/PlayerEventMapper.cs @@ -51,7 +51,7 @@ public PlayerEventInstance Map(EventInstanceEntity entity) return new( idService.EventInstance.Encode(entity.Id), entity.GroupCode, - Map(entity.EventTimeslot.Map), + Map(entity.EventTimeslot.Map!), entity.Players.Count ); } diff --git a/src/server/migrations/mssql/Migrations/20240615205257_MapNotRequired.Designer.cs b/src/server/migrations/mssql/Migrations/20240615205257_MapNotRequired.Designer.cs new file mode 100644 index 0000000..81af0b8 --- /dev/null +++ b/src/server/migrations/mssql/Migrations/20240615205257_MapNotRequired.Designer.cs @@ -0,0 +1,545 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MinigolfFriday.Data; + +#nullable disable + +namespace MinigolfFriday.Migrations.MsSql.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20240615205257_MapNotRequired")] + partial class MapNotRequired + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("date") + .HasColumnName("date"); + + b.Property("RegistrationDeadline") + .HasColumnType("datetimeoffset") + .HasColumnName("registration_deadline"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset") + .HasColumnName("started_at"); + + b.HasKey("Id"); + + b.ToTable("events", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GroupCode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)") + .HasColumnName("group_code"); + + b.Property("timeslot_id") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("timeslot_id"); + + b.ToTable("event_instances", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("event_timeslot_id") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("event_timeslot_id"); + + b.ToTable("event_instance_preconfigurations", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EventId") + .HasColumnType("bigint") + .HasColumnName("event_id"); + + b.Property("IsFallbackAllowed") + .HasColumnType("bit") + .HasColumnName("is_fallback_allowed"); + + b.Property("MapId") + .HasColumnType("bigint") + .HasColumnName("map_id"); + + b.Property("Time") + .HasColumnType("time") + .HasColumnName("time"); + + b.HasKey("Id"); + + b.HasIndex("MapId"); + + b.HasIndex("EventId", "Time") + .IsUnique(); + + b.ToTable("event_timeslots", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EventTimeslotId") + .HasColumnType("bigint") + .HasColumnName("event_timeslot_id"); + + b.Property("FallbackEventTimeslotId") + .HasColumnType("bigint") + .HasColumnName("fallback_event_timeslot_id"); + + b.Property("PlayerId") + .HasColumnType("bigint") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("EventTimeslotId"); + + b.HasIndex("FallbackEventTimeslotId"); + + b.HasIndex("PlayerId"); + + b.ToTable("event_timeslot_registration", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true) + .HasColumnName("active"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("maps", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.RoleEntity", b => + { + b.Property("Id") + .HasColumnType("int") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("roles", (string)null); + + b.HasData( + new + { + Id = 0, + Name = "Player" + }, + new + { + Id = 1, + Name = "Admin" + }); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Alias") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("alias"); + + b.Property("LoginToken") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)") + .HasColumnName("login_token"); + + b.HasKey("Id"); + + b.HasIndex("LoginToken") + .IsUnique() + .HasFilter("[login_token] IS NOT NULL"); + + b.ToTable("users", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Auth") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("auth"); + + b.Property("Endpoint") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasColumnName("endpoint"); + + b.Property("Lang") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)") + .HasColumnName("lang"); + + b.Property("P256DH") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("p256dh"); + + b.Property("UserId") + .HasColumnType("bigint") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("Endpoint") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("user_push_subscriptions", (string)null); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.Property("event_instance_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("event_instance_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("event_instances_to_users"); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.Property("avoided_user_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("avoided_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_avoided_users"); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.Property("event_instance_preconfiguration_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("event_instance_preconfiguration_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_event_instance_preconfigurations"); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.Property("preferred_user_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("preferred_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_preferred_users"); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.Property("role_id") + .HasColumnType("int"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("role_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_roles"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Instances") + .HasForeignKey("timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeSlot") + .WithMany("Preconfigurations") + .HasForeignKey("event_timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeSlot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventEntity", "Event") + .WithMany("Timeslots") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.MinigolfMapEntity", "Map") + .WithMany("EventTimeslots") + .HasForeignKey("MapId"); + + b.Navigation("Event"); + + b.Navigation("Map"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Registrations") + .HasForeignKey("EventTimeslotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "FallbackEventTimeslot") + .WithMany() + .HasForeignKey("FallbackEventTimeslotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + + b.Navigation("FallbackEventTimeslot"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "User") + .WithMany("PushSubscriptions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstanceEntity", null) + .WithMany() + .HasForeignKey("event_instance_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("avoided_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", null) + .WithMany() + .HasForeignKey("event_instance_preconfiguration_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("preferred_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.HasOne("MinigolfFriday.Data.Entities.RoleEntity", null) + .WithMany() + .HasForeignKey("role_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Navigation("Timeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Navigation("Instances"); + + b.Navigation("Preconfigurations"); + + b.Navigation("Registrations"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Navigation("EventTimeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Navigation("PushSubscriptions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/server/migrations/mssql/Migrations/20240615205257_MapNotRequired.cs b/src/server/migrations/mssql/Migrations/20240615205257_MapNotRequired.cs new file mode 100644 index 0000000..fdddd47 --- /dev/null +++ b/src/server/migrations/mssql/Migrations/20240615205257_MapNotRequired.cs @@ -0,0 +1,59 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MinigolfFriday.Migrations.MsSql.Migrations +{ + /// + public partial class MapNotRequired : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots"); + + migrationBuilder.AlterColumn( + name: "map_id", + table: "event_timeslots", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AddForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots", + column: "map_id", + principalTable: "maps", + principalColumn: "id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots"); + + migrationBuilder.AlterColumn( + name: "map_id", + table: "event_timeslots", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots", + column: "map_id", + principalTable: "maps", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/src/server/migrations/mssql/Migrations/DatabaseContextModelSnapshot.cs b/src/server/migrations/mssql/Migrations/DatabaseContextModelSnapshot.cs index 89d77f3..3e9a694 100644 --- a/src/server/migrations/mssql/Migrations/DatabaseContextModelSnapshot.cs +++ b/src/server/migrations/mssql/Migrations/DatabaseContextModelSnapshot.cs @@ -1,544 +1,542 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MinigolfFriday.Data; - -#nullable disable - -namespace MinigolfFriday.Migrations.MsSql.Migrations -{ - [DbContext(typeof(DatabaseContext))] - partial class DatabaseContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Date") - .HasColumnType("date") - .HasColumnName("date"); - - b.Property("RegistrationDeadline") - .HasColumnType("datetimeoffset") - .HasColumnName("registration_deadline"); - - b.Property("StartedAt") - .HasColumnType("datetimeoffset") - .HasColumnName("started_at"); - - b.HasKey("Id"); - - b.ToTable("events", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("GroupCode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)") - .HasColumnName("group_code"); - - b.Property("timeslot_id") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("timeslot_id"); - - b.ToTable("event_instances", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("event_timeslot_id") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("event_timeslot_id"); - - b.ToTable("event_instance_preconfigurations", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EventId") - .HasColumnType("bigint") - .HasColumnName("event_id"); - - b.Property("IsFallbackAllowed") - .HasColumnType("bit") - .HasColumnName("is_fallback_allowed"); - - b.Property("MapId") - .HasColumnType("bigint") - .HasColumnName("map_id"); - - b.Property("Time") - .HasColumnType("time") - .HasColumnName("time"); - - b.HasKey("Id"); - - b.HasIndex("MapId"); - - b.HasIndex("EventId", "Time") - .IsUnique(); - - b.ToTable("event_timeslots", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EventTimeslotId") - .HasColumnType("bigint") - .HasColumnName("event_timeslot_id"); - - b.Property("FallbackEventTimeslotId") - .HasColumnType("bigint") - .HasColumnName("fallback_event_timeslot_id"); - - b.Property("PlayerId") - .HasColumnType("bigint") - .HasColumnName("user_id"); - - b.HasKey("Id"); - - b.HasIndex("EventTimeslotId"); - - b.HasIndex("FallbackEventTimeslotId"); - - b.HasIndex("PlayerId"); - - b.ToTable("event_timeslot_registration", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true) - .HasColumnName("active"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)") - .HasColumnName("name"); - - b.HasKey("Id"); - - b.ToTable("maps", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.RoleEntity", b => - { - b.Property("Id") - .HasColumnType("int") - .HasColumnName("id"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("name"); - - b.HasKey("Id"); - - b.ToTable("roles", (string)null); - - b.HasData( - new - { - Id = 0, - Name = "Player" - }, - new - { - Id = 1, - Name = "Admin" - }); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Alias") - .HasMaxLength(150) - .HasColumnType("nvarchar(150)") - .HasColumnName("alias"); - - b.Property("LoginToken") - .HasMaxLength(32) - .HasColumnType("nvarchar(32)") - .HasColumnName("login_token"); - - b.HasKey("Id"); - - b.HasIndex("LoginToken") - .IsUnique() - .HasFilter("[login_token] IS NOT NULL"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Auth") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)") - .HasColumnName("auth"); - - b.Property("Endpoint") - .IsRequired() - .HasMaxLength(2048) - .HasColumnType("nvarchar(2048)") - .HasColumnName("endpoint"); - - b.Property("Lang") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)") - .HasColumnName("lang"); - - b.Property("P256DH") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)") - .HasColumnName("p256dh"); - - b.Property("UserId") - .HasColumnType("bigint") - .HasColumnName("user_id"); - - b.HasKey("Id"); - - b.HasIndex("Endpoint") - .IsUnique(); - - b.HasIndex("UserId"); - - b.ToTable("user_push_subscriptions", (string)null); - }); - - modelBuilder.Entity("event_instances_to_users", b => - { - b.Property("event_instance_id") - .HasColumnType("bigint"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("event_instance_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("event_instances_to_users"); - }); - - modelBuilder.Entity("users_to_avoided_users", b => - { - b.Property("avoided_user_id") - .HasColumnType("bigint"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("avoided_user_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_avoided_users"); - }); - - modelBuilder.Entity("users_to_event_instance_preconfigurations", b => - { - b.Property("event_instance_preconfiguration_id") - .HasColumnType("bigint"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("event_instance_preconfiguration_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_event_instance_preconfigurations"); - }); - - modelBuilder.Entity("users_to_preferred_users", b => - { - b.Property("preferred_user_id") - .HasColumnType("bigint"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("preferred_user_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_preferred_users"); - }); - - modelBuilder.Entity("users_to_roles", b => - { - b.Property("role_id") - .HasColumnType("int"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("role_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_roles"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") - .WithMany("Instances") - .HasForeignKey("timeslot_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("EventTimeslot"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeSlot") - .WithMany("Preconfigurations") - .HasForeignKey("event_timeslot_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("EventTimeSlot"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventEntity", "Event") - .WithMany("Timeslots") - .HasForeignKey("EventId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.MinigolfMapEntity", "Map") - .WithMany("EventTimeslots") - .HasForeignKey("MapId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Event"); - - b.Navigation("Map"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") - .WithMany("Registrations") - .HasForeignKey("EventTimeslotId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "FallbackEventTimeslot") - .WithMany() - .HasForeignKey("FallbackEventTimeslotId") - .OnDelete(DeleteBehavior.SetNull); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "Player") - .WithMany() - .HasForeignKey("PlayerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("EventTimeslot"); - - b.Navigation("FallbackEventTimeslot"); - - b.Navigation("Player"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "User") - .WithMany("PushSubscriptions") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("event_instances_to_users", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventInstanceEntity", null) - .WithMany() - .HasForeignKey("event_instance_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_avoided_users", b => - { - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("avoided_user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_event_instance_preconfigurations", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", null) - .WithMany() - .HasForeignKey("event_instance_preconfiguration_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_preferred_users", b => - { - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("preferred_user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_roles", b => - { - b.HasOne("MinigolfFriday.Data.Entities.RoleEntity", null) - .WithMany() - .HasForeignKey("role_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => - { - b.Navigation("Timeslots"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => - { - b.Navigation("Instances"); - - b.Navigation("Preconfigurations"); - - b.Navigation("Registrations"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => - { - b.Navigation("EventTimeslots"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => - { - b.Navigation("PushSubscriptions"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MinigolfFriday.Data; + +#nullable disable + +namespace MinigolfFriday.Migrations.MsSql.Migrations +{ + [DbContext(typeof(DatabaseContext))] + partial class DatabaseContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("date") + .HasColumnName("date"); + + b.Property("RegistrationDeadline") + .HasColumnType("datetimeoffset") + .HasColumnName("registration_deadline"); + + b.Property("StartedAt") + .HasColumnType("datetimeoffset") + .HasColumnName("started_at"); + + b.HasKey("Id"); + + b.ToTable("events", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GroupCode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)") + .HasColumnName("group_code"); + + b.Property("timeslot_id") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("timeslot_id"); + + b.ToTable("event_instances", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("event_timeslot_id") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("event_timeslot_id"); + + b.ToTable("event_instance_preconfigurations", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EventId") + .HasColumnType("bigint") + .HasColumnName("event_id"); + + b.Property("IsFallbackAllowed") + .HasColumnType("bit") + .HasColumnName("is_fallback_allowed"); + + b.Property("MapId") + .HasColumnType("bigint") + .HasColumnName("map_id"); + + b.Property("Time") + .HasColumnType("time") + .HasColumnName("time"); + + b.HasKey("Id"); + + b.HasIndex("MapId"); + + b.HasIndex("EventId", "Time") + .IsUnique(); + + b.ToTable("event_timeslots", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EventTimeslotId") + .HasColumnType("bigint") + .HasColumnName("event_timeslot_id"); + + b.Property("FallbackEventTimeslotId") + .HasColumnType("bigint") + .HasColumnName("fallback_event_timeslot_id"); + + b.Property("PlayerId") + .HasColumnType("bigint") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("EventTimeslotId"); + + b.HasIndex("FallbackEventTimeslotId"); + + b.HasIndex("PlayerId"); + + b.ToTable("event_timeslot_registration", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true) + .HasColumnName("active"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("maps", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.RoleEntity", b => + { + b.Property("Id") + .HasColumnType("int") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("roles", (string)null); + + b.HasData( + new + { + Id = 0, + Name = "Player" + }, + new + { + Id = 1, + Name = "Admin" + }); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Alias") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("alias"); + + b.Property("LoginToken") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)") + .HasColumnName("login_token"); + + b.HasKey("Id"); + + b.HasIndex("LoginToken") + .IsUnique() + .HasFilter("[login_token] IS NOT NULL"); + + b.ToTable("users", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Auth") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("auth"); + + b.Property("Endpoint") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasColumnName("endpoint"); + + b.Property("Lang") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)") + .HasColumnName("lang"); + + b.Property("P256DH") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("p256dh"); + + b.Property("UserId") + .HasColumnType("bigint") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("Endpoint") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("user_push_subscriptions", (string)null); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.Property("event_instance_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("event_instance_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("event_instances_to_users"); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.Property("avoided_user_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("avoided_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_avoided_users"); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.Property("event_instance_preconfiguration_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("event_instance_preconfiguration_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_event_instance_preconfigurations"); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.Property("preferred_user_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("preferred_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_preferred_users"); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.Property("role_id") + .HasColumnType("int"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("role_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_roles"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Instances") + .HasForeignKey("timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeSlot") + .WithMany("Preconfigurations") + .HasForeignKey("event_timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeSlot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventEntity", "Event") + .WithMany("Timeslots") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.MinigolfMapEntity", "Map") + .WithMany("EventTimeslots") + .HasForeignKey("MapId"); + + b.Navigation("Event"); + + b.Navigation("Map"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Registrations") + .HasForeignKey("EventTimeslotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "FallbackEventTimeslot") + .WithMany() + .HasForeignKey("FallbackEventTimeslotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + + b.Navigation("FallbackEventTimeslot"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "User") + .WithMany("PushSubscriptions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstanceEntity", null) + .WithMany() + .HasForeignKey("event_instance_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("avoided_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", null) + .WithMany() + .HasForeignKey("event_instance_preconfiguration_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("preferred_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.HasOne("MinigolfFriday.Data.Entities.RoleEntity", null) + .WithMany() + .HasForeignKey("role_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Navigation("Timeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Navigation("Instances"); + + b.Navigation("Preconfigurations"); + + b.Navigation("Registrations"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Navigation("EventTimeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Navigation("PushSubscriptions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/server/migrations/postgresql/Migrations/20240615205300_MapNotRequired.Designer.cs b/src/server/migrations/postgresql/Migrations/20240615205300_MapNotRequired.Designer.cs new file mode 100644 index 0000000..bfc442f --- /dev/null +++ b/src/server/migrations/postgresql/Migrations/20240615205300_MapNotRequired.Designer.cs @@ -0,0 +1,544 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MinigolfFriday.Data; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MinigolfFriday.Migrations.PostgreSql.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20240615205300_MapNotRequired")] + partial class MapNotRequired + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("date") + .HasColumnName("date"); + + b.Property("RegistrationDeadline") + .HasColumnType("timestamp with time zone") + .HasColumnName("registration_deadline"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone") + .HasColumnName("started_at"); + + b.HasKey("Id"); + + b.ToTable("events", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("GroupCode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasColumnName("group_code"); + + b.Property("timeslot_id") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("timeslot_id"); + + b.ToTable("event_instances", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("event_timeslot_id") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("event_timeslot_id"); + + b.ToTable("event_instance_preconfigurations", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EventId") + .HasColumnType("bigint") + .HasColumnName("event_id"); + + b.Property("IsFallbackAllowed") + .HasColumnType("boolean") + .HasColumnName("is_fallback_allowed"); + + b.Property("MapId") + .HasColumnType("bigint") + .HasColumnName("map_id"); + + b.Property("Time") + .HasColumnType("time without time zone") + .HasColumnName("time"); + + b.HasKey("Id"); + + b.HasIndex("MapId"); + + b.HasIndex("EventId", "Time") + .IsUnique(); + + b.ToTable("event_timeslots", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EventTimeslotId") + .HasColumnType("bigint") + .HasColumnName("event_timeslot_id"); + + b.Property("FallbackEventTimeslotId") + .HasColumnType("bigint") + .HasColumnName("fallback_event_timeslot_id"); + + b.Property("PlayerId") + .HasColumnType("bigint") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("EventTimeslotId"); + + b.HasIndex("FallbackEventTimeslotId"); + + b.HasIndex("PlayerId"); + + b.ToTable("event_timeslot_registration", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true) + .HasColumnName("active"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("maps", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.RoleEntity", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("roles", (string)null); + + b.HasData( + new + { + Id = 0, + Name = "Player" + }, + new + { + Id = 1, + Name = "Admin" + }); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Alias") + .HasMaxLength(150) + .HasColumnType("character varying(150)") + .HasColumnName("alias"); + + b.Property("LoginToken") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasColumnName("login_token"); + + b.HasKey("Id"); + + b.HasIndex("LoginToken") + .IsUnique(); + + b.ToTable("users", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Auth") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("auth"); + + b.Property("Endpoint") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("character varying(2048)") + .HasColumnName("endpoint"); + + b.Property("Lang") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("lang"); + + b.Property("P256DH") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("p256dh"); + + b.Property("UserId") + .HasColumnType("bigint") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("Endpoint") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("user_push_subscriptions", (string)null); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.Property("event_instance_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("event_instance_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("event_instances_to_users"); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.Property("avoided_user_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("avoided_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_avoided_users"); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.Property("event_instance_preconfiguration_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("event_instance_preconfiguration_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_event_instance_preconfigurations"); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.Property("preferred_user_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("preferred_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_preferred_users"); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.Property("role_id") + .HasColumnType("integer"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("role_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_roles"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Instances") + .HasForeignKey("timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeSlot") + .WithMany("Preconfigurations") + .HasForeignKey("event_timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeSlot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventEntity", "Event") + .WithMany("Timeslots") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.MinigolfMapEntity", "Map") + .WithMany("EventTimeslots") + .HasForeignKey("MapId"); + + b.Navigation("Event"); + + b.Navigation("Map"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Registrations") + .HasForeignKey("EventTimeslotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "FallbackEventTimeslot") + .WithMany() + .HasForeignKey("FallbackEventTimeslotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + + b.Navigation("FallbackEventTimeslot"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "User") + .WithMany("PushSubscriptions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstanceEntity", null) + .WithMany() + .HasForeignKey("event_instance_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("avoided_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", null) + .WithMany() + .HasForeignKey("event_instance_preconfiguration_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("preferred_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.HasOne("MinigolfFriday.Data.Entities.RoleEntity", null) + .WithMany() + .HasForeignKey("role_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Navigation("Timeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Navigation("Instances"); + + b.Navigation("Preconfigurations"); + + b.Navigation("Registrations"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Navigation("EventTimeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Navigation("PushSubscriptions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/server/migrations/postgresql/Migrations/20240615205300_MapNotRequired.cs b/src/server/migrations/postgresql/Migrations/20240615205300_MapNotRequired.cs new file mode 100644 index 0000000..15ad992 --- /dev/null +++ b/src/server/migrations/postgresql/Migrations/20240615205300_MapNotRequired.cs @@ -0,0 +1,59 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MinigolfFriday.Migrations.PostgreSql.Migrations +{ + /// + public partial class MapNotRequired : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots"); + + migrationBuilder.AlterColumn( + name: "map_id", + table: "event_timeslots", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AddForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots", + column: "map_id", + principalTable: "maps", + principalColumn: "id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots"); + + migrationBuilder.AlterColumn( + name: "map_id", + table: "event_timeslots", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots", + column: "map_id", + principalTable: "maps", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/src/server/migrations/postgresql/Migrations/DatabaseContextModelSnapshot.cs b/src/server/migrations/postgresql/Migrations/DatabaseContextModelSnapshot.cs index 9b45646..fc388d5 100644 --- a/src/server/migrations/postgresql/Migrations/DatabaseContextModelSnapshot.cs +++ b/src/server/migrations/postgresql/Migrations/DatabaseContextModelSnapshot.cs @@ -1,543 +1,541 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MinigolfFriday.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MinigolfFriday.Migrations.PostgreSql.Migrations -{ - [DbContext(typeof(DatabaseContext))] - partial class DatabaseContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Date") - .HasColumnType("date") - .HasColumnName("date"); - - b.Property("RegistrationDeadline") - .HasColumnType("timestamp with time zone") - .HasColumnName("registration_deadline"); - - b.Property("StartedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("started_at"); - - b.HasKey("Id"); - - b.ToTable("events", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("GroupCode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasColumnName("group_code"); - - b.Property("timeslot_id") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("timeslot_id"); - - b.ToTable("event_instances", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("event_timeslot_id") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("event_timeslot_id"); - - b.ToTable("event_instance_preconfigurations", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EventId") - .HasColumnType("bigint") - .HasColumnName("event_id"); - - b.Property("IsFallbackAllowed") - .HasColumnType("boolean") - .HasColumnName("is_fallback_allowed"); - - b.Property("MapId") - .HasColumnType("bigint") - .HasColumnName("map_id"); - - b.Property("Time") - .HasColumnType("time without time zone") - .HasColumnName("time"); - - b.HasKey("Id"); - - b.HasIndex("MapId"); - - b.HasIndex("EventId", "Time") - .IsUnique(); - - b.ToTable("event_timeslots", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EventTimeslotId") - .HasColumnType("bigint") - .HasColumnName("event_timeslot_id"); - - b.Property("FallbackEventTimeslotId") - .HasColumnType("bigint") - .HasColumnName("fallback_event_timeslot_id"); - - b.Property("PlayerId") - .HasColumnType("bigint") - .HasColumnName("user_id"); - - b.HasKey("Id"); - - b.HasIndex("EventTimeslotId"); - - b.HasIndex("FallbackEventTimeslotId"); - - b.HasIndex("PlayerId"); - - b.ToTable("event_timeslot_registration", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true) - .HasColumnName("active"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("character varying(150)") - .HasColumnName("name"); - - b.HasKey("Id"); - - b.ToTable("maps", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.RoleEntity", b => - { - b.Property("Id") - .HasColumnType("integer") - .HasColumnName("id"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b.HasKey("Id"); - - b.ToTable("roles", (string)null); - - b.HasData( - new - { - Id = 0, - Name = "Player" - }, - new - { - Id = 1, - Name = "Admin" - }); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Alias") - .HasMaxLength(150) - .HasColumnType("character varying(150)") - .HasColumnName("alias"); - - b.Property("LoginToken") - .HasMaxLength(32) - .HasColumnType("character varying(32)") - .HasColumnName("login_token"); - - b.HasKey("Id"); - - b.HasIndex("LoginToken") - .IsUnique(); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Auth") - .HasMaxLength(255) - .HasColumnType("character varying(255)") - .HasColumnName("auth"); - - b.Property("Endpoint") - .IsRequired() - .HasMaxLength(2048) - .HasColumnType("character varying(2048)") - .HasColumnName("endpoint"); - - b.Property("Lang") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("lang"); - - b.Property("P256DH") - .HasMaxLength(255) - .HasColumnType("character varying(255)") - .HasColumnName("p256dh"); - - b.Property("UserId") - .HasColumnType("bigint") - .HasColumnName("user_id"); - - b.HasKey("Id"); - - b.HasIndex("Endpoint") - .IsUnique(); - - b.HasIndex("UserId"); - - b.ToTable("user_push_subscriptions", (string)null); - }); - - modelBuilder.Entity("event_instances_to_users", b => - { - b.Property("event_instance_id") - .HasColumnType("bigint"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("event_instance_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("event_instances_to_users"); - }); - - modelBuilder.Entity("users_to_avoided_users", b => - { - b.Property("avoided_user_id") - .HasColumnType("bigint"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("avoided_user_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_avoided_users"); - }); - - modelBuilder.Entity("users_to_event_instance_preconfigurations", b => - { - b.Property("event_instance_preconfiguration_id") - .HasColumnType("bigint"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("event_instance_preconfiguration_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_event_instance_preconfigurations"); - }); - - modelBuilder.Entity("users_to_preferred_users", b => - { - b.Property("preferred_user_id") - .HasColumnType("bigint"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("preferred_user_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_preferred_users"); - }); - - modelBuilder.Entity("users_to_roles", b => - { - b.Property("role_id") - .HasColumnType("integer"); - - b.Property("user_id") - .HasColumnType("bigint"); - - b.HasKey("role_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_roles"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") - .WithMany("Instances") - .HasForeignKey("timeslot_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("EventTimeslot"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeSlot") - .WithMany("Preconfigurations") - .HasForeignKey("event_timeslot_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("EventTimeSlot"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventEntity", "Event") - .WithMany("Timeslots") - .HasForeignKey("EventId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.MinigolfMapEntity", "Map") - .WithMany("EventTimeslots") - .HasForeignKey("MapId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Event"); - - b.Navigation("Map"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") - .WithMany("Registrations") - .HasForeignKey("EventTimeslotId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "FallbackEventTimeslot") - .WithMany() - .HasForeignKey("FallbackEventTimeslotId") - .OnDelete(DeleteBehavior.SetNull); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "Player") - .WithMany() - .HasForeignKey("PlayerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("EventTimeslot"); - - b.Navigation("FallbackEventTimeslot"); - - b.Navigation("Player"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "User") - .WithMany("PushSubscriptions") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("event_instances_to_users", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventInstanceEntity", null) - .WithMany() - .HasForeignKey("event_instance_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_avoided_users", b => - { - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("avoided_user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_event_instance_preconfigurations", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", null) - .WithMany() - .HasForeignKey("event_instance_preconfiguration_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_preferred_users", b => - { - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("preferred_user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_roles", b => - { - b.HasOne("MinigolfFriday.Data.Entities.RoleEntity", null) - .WithMany() - .HasForeignKey("role_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => - { - b.Navigation("Timeslots"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => - { - b.Navigation("Instances"); - - b.Navigation("Preconfigurations"); - - b.Navigation("Registrations"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => - { - b.Navigation("EventTimeslots"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => - { - b.Navigation("PushSubscriptions"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MinigolfFriday.Data; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MinigolfFriday.Migrations.PostgreSql.Migrations +{ + [DbContext(typeof(DatabaseContext))] + partial class DatabaseContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("date") + .HasColumnName("date"); + + b.Property("RegistrationDeadline") + .HasColumnType("timestamp with time zone") + .HasColumnName("registration_deadline"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone") + .HasColumnName("started_at"); + + b.HasKey("Id"); + + b.ToTable("events", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("GroupCode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasColumnName("group_code"); + + b.Property("timeslot_id") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("timeslot_id"); + + b.ToTable("event_instances", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("event_timeslot_id") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("event_timeslot_id"); + + b.ToTable("event_instance_preconfigurations", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EventId") + .HasColumnType("bigint") + .HasColumnName("event_id"); + + b.Property("IsFallbackAllowed") + .HasColumnType("boolean") + .HasColumnName("is_fallback_allowed"); + + b.Property("MapId") + .HasColumnType("bigint") + .HasColumnName("map_id"); + + b.Property("Time") + .HasColumnType("time without time zone") + .HasColumnName("time"); + + b.HasKey("Id"); + + b.HasIndex("MapId"); + + b.HasIndex("EventId", "Time") + .IsUnique(); + + b.ToTable("event_timeslots", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EventTimeslotId") + .HasColumnType("bigint") + .HasColumnName("event_timeslot_id"); + + b.Property("FallbackEventTimeslotId") + .HasColumnType("bigint") + .HasColumnName("fallback_event_timeslot_id"); + + b.Property("PlayerId") + .HasColumnType("bigint") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("EventTimeslotId"); + + b.HasIndex("FallbackEventTimeslotId"); + + b.HasIndex("PlayerId"); + + b.ToTable("event_timeslot_registration", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true) + .HasColumnName("active"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("maps", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.RoleEntity", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("roles", (string)null); + + b.HasData( + new + { + Id = 0, + Name = "Player" + }, + new + { + Id = 1, + Name = "Admin" + }); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Alias") + .HasMaxLength(150) + .HasColumnType("character varying(150)") + .HasColumnName("alias"); + + b.Property("LoginToken") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasColumnName("login_token"); + + b.HasKey("Id"); + + b.HasIndex("LoginToken") + .IsUnique(); + + b.ToTable("users", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Auth") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("auth"); + + b.Property("Endpoint") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("character varying(2048)") + .HasColumnName("endpoint"); + + b.Property("Lang") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("lang"); + + b.Property("P256DH") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("p256dh"); + + b.Property("UserId") + .HasColumnType("bigint") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("Endpoint") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("user_push_subscriptions", (string)null); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.Property("event_instance_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("event_instance_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("event_instances_to_users"); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.Property("avoided_user_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("avoided_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_avoided_users"); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.Property("event_instance_preconfiguration_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("event_instance_preconfiguration_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_event_instance_preconfigurations"); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.Property("preferred_user_id") + .HasColumnType("bigint"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("preferred_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_preferred_users"); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.Property("role_id") + .HasColumnType("integer"); + + b.Property("user_id") + .HasColumnType("bigint"); + + b.HasKey("role_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_roles"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Instances") + .HasForeignKey("timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeSlot") + .WithMany("Preconfigurations") + .HasForeignKey("event_timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeSlot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventEntity", "Event") + .WithMany("Timeslots") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.MinigolfMapEntity", "Map") + .WithMany("EventTimeslots") + .HasForeignKey("MapId"); + + b.Navigation("Event"); + + b.Navigation("Map"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Registrations") + .HasForeignKey("EventTimeslotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "FallbackEventTimeslot") + .WithMany() + .HasForeignKey("FallbackEventTimeslotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + + b.Navigation("FallbackEventTimeslot"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "User") + .WithMany("PushSubscriptions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstanceEntity", null) + .WithMany() + .HasForeignKey("event_instance_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("avoided_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", null) + .WithMany() + .HasForeignKey("event_instance_preconfiguration_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("preferred_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.HasOne("MinigolfFriday.Data.Entities.RoleEntity", null) + .WithMany() + .HasForeignKey("role_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Navigation("Timeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Navigation("Instances"); + + b.Navigation("Preconfigurations"); + + b.Navigation("Registrations"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Navigation("EventTimeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Navigation("PushSubscriptions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/server/migrations/sqlite/Migrations/20240615205254_MapNotRequired.Designer.cs b/src/server/migrations/sqlite/Migrations/20240615205254_MapNotRequired.Designer.cs new file mode 100644 index 0000000..d68037c --- /dev/null +++ b/src/server/migrations/sqlite/Migrations/20240615205254_MapNotRequired.Designer.cs @@ -0,0 +1,523 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MinigolfFriday.Data; + +#nullable disable + +namespace MinigolfFriday.Migrations.Sqlite.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20240615205254_MapNotRequired")] + partial class MapNotRequired + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Date") + .HasColumnType("TEXT") + .HasColumnName("date"); + + b.Property("RegistrationDeadline") + .HasColumnType("TEXT") + .HasColumnName("registration_deadline"); + + b.Property("StartedAt") + .HasColumnType("TEXT") + .HasColumnName("started_at"); + + b.HasKey("Id"); + + b.ToTable("events", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("GroupCode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnName("group_code"); + + b.Property("timeslot_id") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("timeslot_id"); + + b.ToTable("event_instances", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("event_timeslot_id") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("event_timeslot_id"); + + b.ToTable("event_instance_preconfigurations", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("EventId") + .HasColumnType("INTEGER") + .HasColumnName("event_id"); + + b.Property("IsFallbackAllowed") + .HasColumnType("INTEGER") + .HasColumnName("is_fallback_allowed"); + + b.Property("MapId") + .HasColumnType("INTEGER") + .HasColumnName("map_id"); + + b.Property("Time") + .HasColumnType("TEXT") + .HasColumnName("time"); + + b.HasKey("Id"); + + b.HasIndex("MapId"); + + b.HasIndex("EventId", "Time") + .IsUnique(); + + b.ToTable("event_timeslots", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("EventTimeslotId") + .HasColumnType("INTEGER") + .HasColumnName("event_timeslot_id"); + + b.Property("FallbackEventTimeslotId") + .HasColumnType("INTEGER") + .HasColumnName("fallback_event_timeslot_id"); + + b.Property("PlayerId") + .HasColumnType("INTEGER") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("EventTimeslotId"); + + b.HasIndex("FallbackEventTimeslotId"); + + b.HasIndex("PlayerId"); + + b.ToTable("event_timeslot_registration", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnName("active"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("TEXT") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("maps", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.RoleEntity", b => + { + b.Property("Id") + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("roles", (string)null); + + b.HasData( + new + { + Id = 0, + Name = "Player" + }, + new + { + Id = 1, + Name = "Admin" + }); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Alias") + .HasMaxLength(150) + .HasColumnType("TEXT") + .HasColumnName("alias"); + + b.Property("LoginToken") + .HasMaxLength(32) + .HasColumnType("TEXT") + .HasColumnName("login_token"); + + b.HasKey("Id"); + + b.HasIndex("LoginToken") + .IsUnique(); + + b.ToTable("users", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Auth") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnName("auth"); + + b.Property("Endpoint") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnName("endpoint"); + + b.Property("Lang") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnName("lang"); + + b.Property("P256DH") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnName("p256dh"); + + b.Property("UserId") + .HasColumnType("INTEGER") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("Endpoint") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("user_push_subscriptions", (string)null); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.Property("event_instance_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("event_instance_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("event_instances_to_users"); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.Property("avoided_user_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("avoided_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_avoided_users"); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.Property("event_instance_preconfiguration_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("event_instance_preconfiguration_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_event_instance_preconfigurations"); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.Property("preferred_user_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("preferred_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_preferred_users"); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.Property("role_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("role_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_roles"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Instances") + .HasForeignKey("timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeSlot") + .WithMany("Preconfigurations") + .HasForeignKey("event_timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeSlot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventEntity", "Event") + .WithMany("Timeslots") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.MinigolfMapEntity", "Map") + .WithMany("EventTimeslots") + .HasForeignKey("MapId"); + + b.Navigation("Event"); + + b.Navigation("Map"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Registrations") + .HasForeignKey("EventTimeslotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "FallbackEventTimeslot") + .WithMany() + .HasForeignKey("FallbackEventTimeslotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + + b.Navigation("FallbackEventTimeslot"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "User") + .WithMany("PushSubscriptions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstanceEntity", null) + .WithMany() + .HasForeignKey("event_instance_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("avoided_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", null) + .WithMany() + .HasForeignKey("event_instance_preconfiguration_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("preferred_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.HasOne("MinigolfFriday.Data.Entities.RoleEntity", null) + .WithMany() + .HasForeignKey("role_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Navigation("Timeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Navigation("Instances"); + + b.Navigation("Preconfigurations"); + + b.Navigation("Registrations"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Navigation("EventTimeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Navigation("PushSubscriptions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/server/migrations/sqlite/Migrations/20240615205254_MapNotRequired.cs b/src/server/migrations/sqlite/Migrations/20240615205254_MapNotRequired.cs new file mode 100644 index 0000000..5ec6e25 --- /dev/null +++ b/src/server/migrations/sqlite/Migrations/20240615205254_MapNotRequired.cs @@ -0,0 +1,59 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MinigolfFriday.Migrations.Sqlite.Migrations +{ + /// + public partial class MapNotRequired : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots"); + + migrationBuilder.AlterColumn( + name: "map_id", + table: "event_timeslots", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AddForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots", + column: "map_id", + principalTable: "maps", + principalColumn: "id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots"); + + migrationBuilder.AlterColumn( + name: "map_id", + table: "event_timeslots", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_event_timeslots_maps_map_id", + table: "event_timeslots", + column: "map_id", + principalTable: "maps", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/src/server/migrations/sqlite/Migrations/DatabaseContextModelSnapshot.cs b/src/server/migrations/sqlite/Migrations/DatabaseContextModelSnapshot.cs index 1c7ec98..687c5d5 100644 --- a/src/server/migrations/sqlite/Migrations/DatabaseContextModelSnapshot.cs +++ b/src/server/migrations/sqlite/Migrations/DatabaseContextModelSnapshot.cs @@ -1,522 +1,520 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MinigolfFriday.Data; - -#nullable disable - -namespace MinigolfFriday.Migrations.Sqlite.Migrations -{ - [DbContext(typeof(DatabaseContext))] - partial class DatabaseContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasColumnName("id"); - - b.Property("Date") - .HasColumnType("TEXT") - .HasColumnName("date"); - - b.Property("RegistrationDeadline") - .HasColumnType("TEXT") - .HasColumnName("registration_deadline"); - - b.Property("StartedAt") - .HasColumnType("TEXT") - .HasColumnName("started_at"); - - b.HasKey("Id"); - - b.ToTable("events", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasColumnName("id"); - - b.Property("GroupCode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("TEXT") - .HasColumnName("group_code"); - - b.Property("timeslot_id") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("timeslot_id"); - - b.ToTable("event_instances", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasColumnName("id"); - - b.Property("event_timeslot_id") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("event_timeslot_id"); - - b.ToTable("event_instance_preconfigurations", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasColumnName("id"); - - b.Property("EventId") - .HasColumnType("INTEGER") - .HasColumnName("event_id"); - - b.Property("IsFallbackAllowed") - .HasColumnType("INTEGER") - .HasColumnName("is_fallback_allowed"); - - b.Property("MapId") - .HasColumnType("INTEGER") - .HasColumnName("map_id"); - - b.Property("Time") - .HasColumnType("TEXT") - .HasColumnName("time"); - - b.HasKey("Id"); - - b.HasIndex("MapId"); - - b.HasIndex("EventId", "Time") - .IsUnique(); - - b.ToTable("event_timeslots", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasColumnName("id"); - - b.Property("EventTimeslotId") - .HasColumnType("INTEGER") - .HasColumnName("event_timeslot_id"); - - b.Property("FallbackEventTimeslotId") - .HasColumnType("INTEGER") - .HasColumnName("fallback_event_timeslot_id"); - - b.Property("PlayerId") - .HasColumnType("INTEGER") - .HasColumnName("user_id"); - - b.HasKey("Id"); - - b.HasIndex("EventTimeslotId"); - - b.HasIndex("FallbackEventTimeslotId"); - - b.HasIndex("PlayerId"); - - b.ToTable("event_timeslot_registration", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasColumnName("id"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(true) - .HasColumnName("active"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("TEXT") - .HasColumnName("name"); - - b.HasKey("Id"); - - b.ToTable("maps", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.RoleEntity", b => - { - b.Property("Id") - .HasColumnType("INTEGER") - .HasColumnName("id"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("TEXT") - .HasColumnName("name"); - - b.HasKey("Id"); - - b.ToTable("roles", (string)null); - - b.HasData( - new - { - Id = 0, - Name = "Player" - }, - new - { - Id = 1, - Name = "Admin" - }); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasColumnName("id"); - - b.Property("Alias") - .HasMaxLength(150) - .HasColumnType("TEXT") - .HasColumnName("alias"); - - b.Property("LoginToken") - .HasMaxLength(32) - .HasColumnType("TEXT") - .HasColumnName("login_token"); - - b.HasKey("Id"); - - b.HasIndex("LoginToken") - .IsUnique(); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasColumnName("id"); - - b.Property("Auth") - .HasMaxLength(255) - .HasColumnType("TEXT") - .HasColumnName("auth"); - - b.Property("Endpoint") - .IsRequired() - .HasMaxLength(2048) - .HasColumnType("TEXT") - .HasColumnName("endpoint"); - - b.Property("Lang") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("TEXT") - .HasColumnName("lang"); - - b.Property("P256DH") - .HasMaxLength(255) - .HasColumnType("TEXT") - .HasColumnName("p256dh"); - - b.Property("UserId") - .HasColumnType("INTEGER") - .HasColumnName("user_id"); - - b.HasKey("Id"); - - b.HasIndex("Endpoint") - .IsUnique(); - - b.HasIndex("UserId"); - - b.ToTable("user_push_subscriptions", (string)null); - }); - - modelBuilder.Entity("event_instances_to_users", b => - { - b.Property("event_instance_id") - .HasColumnType("INTEGER"); - - b.Property("user_id") - .HasColumnType("INTEGER"); - - b.HasKey("event_instance_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("event_instances_to_users"); - }); - - modelBuilder.Entity("users_to_avoided_users", b => - { - b.Property("avoided_user_id") - .HasColumnType("INTEGER"); - - b.Property("user_id") - .HasColumnType("INTEGER"); - - b.HasKey("avoided_user_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_avoided_users"); - }); - - modelBuilder.Entity("users_to_event_instance_preconfigurations", b => - { - b.Property("event_instance_preconfiguration_id") - .HasColumnType("INTEGER"); - - b.Property("user_id") - .HasColumnType("INTEGER"); - - b.HasKey("event_instance_preconfiguration_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_event_instance_preconfigurations"); - }); - - modelBuilder.Entity("users_to_preferred_users", b => - { - b.Property("preferred_user_id") - .HasColumnType("INTEGER"); - - b.Property("user_id") - .HasColumnType("INTEGER"); - - b.HasKey("preferred_user_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_preferred_users"); - }); - - modelBuilder.Entity("users_to_roles", b => - { - b.Property("role_id") - .HasColumnType("INTEGER"); - - b.Property("user_id") - .HasColumnType("INTEGER"); - - b.HasKey("role_id", "user_id"); - - b.HasIndex("user_id"); - - b.ToTable("users_to_roles"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") - .WithMany("Instances") - .HasForeignKey("timeslot_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("EventTimeslot"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeSlot") - .WithMany("Preconfigurations") - .HasForeignKey("event_timeslot_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("EventTimeSlot"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventEntity", "Event") - .WithMany("Timeslots") - .HasForeignKey("EventId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.MinigolfMapEntity", "Map") - .WithMany("EventTimeslots") - .HasForeignKey("MapId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Event"); - - b.Navigation("Map"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") - .WithMany("Registrations") - .HasForeignKey("EventTimeslotId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "FallbackEventTimeslot") - .WithMany() - .HasForeignKey("FallbackEventTimeslotId") - .OnDelete(DeleteBehavior.SetNull); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "Player") - .WithMany() - .HasForeignKey("PlayerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("EventTimeslot"); - - b.Navigation("FallbackEventTimeslot"); - - b.Navigation("Player"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => - { - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "User") - .WithMany("PushSubscriptions") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("event_instances_to_users", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventInstanceEntity", null) - .WithMany() - .HasForeignKey("event_instance_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_avoided_users", b => - { - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("avoided_user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_event_instance_preconfigurations", b => - { - b.HasOne("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", null) - .WithMany() - .HasForeignKey("event_instance_preconfiguration_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_preferred_users", b => - { - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("preferred_user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("users_to_roles", b => - { - b.HasOne("MinigolfFriday.Data.Entities.RoleEntity", null) - .WithMany() - .HasForeignKey("role_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) - .WithMany() - .HasForeignKey("user_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => - { - b.Navigation("Timeslots"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => - { - b.Navigation("Instances"); - - b.Navigation("Preconfigurations"); - - b.Navigation("Registrations"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => - { - b.Navigation("EventTimeslots"); - }); - - modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => - { - b.Navigation("PushSubscriptions"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MinigolfFriday.Data; + +#nullable disable + +namespace MinigolfFriday.Migrations.Sqlite.Migrations +{ + [DbContext(typeof(DatabaseContext))] + partial class DatabaseContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Date") + .HasColumnType("TEXT") + .HasColumnName("date"); + + b.Property("RegistrationDeadline") + .HasColumnType("TEXT") + .HasColumnName("registration_deadline"); + + b.Property("StartedAt") + .HasColumnType("TEXT") + .HasColumnName("started_at"); + + b.HasKey("Id"); + + b.ToTable("events", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("GroupCode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnName("group_code"); + + b.Property("timeslot_id") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("timeslot_id"); + + b.ToTable("event_instances", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("event_timeslot_id") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("event_timeslot_id"); + + b.ToTable("event_instance_preconfigurations", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("EventId") + .HasColumnType("INTEGER") + .HasColumnName("event_id"); + + b.Property("IsFallbackAllowed") + .HasColumnType("INTEGER") + .HasColumnName("is_fallback_allowed"); + + b.Property("MapId") + .HasColumnType("INTEGER") + .HasColumnName("map_id"); + + b.Property("Time") + .HasColumnType("TEXT") + .HasColumnName("time"); + + b.HasKey("Id"); + + b.HasIndex("MapId"); + + b.HasIndex("EventId", "Time") + .IsUnique(); + + b.ToTable("event_timeslots", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("EventTimeslotId") + .HasColumnType("INTEGER") + .HasColumnName("event_timeslot_id"); + + b.Property("FallbackEventTimeslotId") + .HasColumnType("INTEGER") + .HasColumnName("fallback_event_timeslot_id"); + + b.Property("PlayerId") + .HasColumnType("INTEGER") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("EventTimeslotId"); + + b.HasIndex("FallbackEventTimeslotId"); + + b.HasIndex("PlayerId"); + + b.ToTable("event_timeslot_registration", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnName("active"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("TEXT") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("maps", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.RoleEntity", b => + { + b.Property("Id") + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("roles", (string)null); + + b.HasData( + new + { + Id = 0, + Name = "Player" + }, + new + { + Id = 1, + Name = "Admin" + }); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Alias") + .HasMaxLength(150) + .HasColumnType("TEXT") + .HasColumnName("alias"); + + b.Property("LoginToken") + .HasMaxLength(32) + .HasColumnType("TEXT") + .HasColumnName("login_token"); + + b.HasKey("Id"); + + b.HasIndex("LoginToken") + .IsUnique(); + + b.ToTable("users", (string)null); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Auth") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnName("auth"); + + b.Property("Endpoint") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnName("endpoint"); + + b.Property("Lang") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnName("lang"); + + b.Property("P256DH") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnName("p256dh"); + + b.Property("UserId") + .HasColumnType("INTEGER") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("Endpoint") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("user_push_subscriptions", (string)null); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.Property("event_instance_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("event_instance_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("event_instances_to_users"); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.Property("avoided_user_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("avoided_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_avoided_users"); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.Property("event_instance_preconfiguration_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("event_instance_preconfiguration_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_event_instance_preconfigurations"); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.Property("preferred_user_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("preferred_user_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_preferred_users"); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.Property("role_id") + .HasColumnType("INTEGER"); + + b.Property("user_id") + .HasColumnType("INTEGER"); + + b.HasKey("role_id", "user_id"); + + b.HasIndex("user_id"); + + b.ToTable("users_to_roles"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstanceEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Instances") + .HasForeignKey("timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeSlot") + .WithMany("Preconfigurations") + .HasForeignKey("event_timeslot_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeSlot"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventEntity", "Event") + .WithMany("Timeslots") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.MinigolfMapEntity", "Map") + .WithMany("EventTimeslots") + .HasForeignKey("MapId"); + + b.Navigation("Event"); + + b.Navigation("Map"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotRegistrationEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "EventTimeslot") + .WithMany("Registrations") + .HasForeignKey("EventTimeslotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.EventTimeslotEntity", "FallbackEventTimeslot") + .WithMany() + .HasForeignKey("FallbackEventTimeslotId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EventTimeslot"); + + b.Navigation("FallbackEventTimeslot"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserPushSubscriptionEntity", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", "User") + .WithMany("PushSubscriptions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("event_instances_to_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstanceEntity", null) + .WithMany() + .HasForeignKey("event_instance_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_avoided_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("avoided_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_event_instance_preconfigurations", b => + { + b.HasOne("MinigolfFriday.Data.Entities.EventInstancePreconfigurationEntity", null) + .WithMany() + .HasForeignKey("event_instance_preconfiguration_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_preferred_users", b => + { + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("preferred_user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("users_to_roles", b => + { + b.HasOne("MinigolfFriday.Data.Entities.RoleEntity", null) + .WithMany() + .HasForeignKey("role_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MinigolfFriday.Data.Entities.UserEntity", null) + .WithMany() + .HasForeignKey("user_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventEntity", b => + { + b.Navigation("Timeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.EventTimeslotEntity", b => + { + b.Navigation("Instances"); + + b.Navigation("Preconfigurations"); + + b.Navigation("Registrations"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.MinigolfMapEntity", b => + { + b.Navigation("EventTimeslots"); + }); + + modelBuilder.Entity("MinigolfFriday.Data.Entities.UserEntity", b => + { + b.Navigation("PushSubscriptions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/test/MinigolfFriday.IntegrationTests/Endpoints/Administration/Events/Timeslots/UpdateEventTimeslotTests.cs b/test/MinigolfFriday.IntegrationTests/Endpoints/Administration/Events/Timeslots/UpdateEventTimeslotTests.cs index 1355ed2..bdee666 100644 --- a/test/MinigolfFriday.IntegrationTests/Endpoints/Administration/Events/Timeslots/UpdateEventTimeslotTests.cs +++ b/test/MinigolfFriday.IntegrationTests/Endpoints/Administration/Events/Timeslots/UpdateEventTimeslotTests.cs @@ -20,25 +20,6 @@ await sut.AppClient.UpdateEventTimeslotAsync( (await sut.AppClient.GetEventAsync(@event.Id)).Event.Should().BeEquivalentTo(@event); } - [TestMethod] - [DatabaseProviderDataSource] - public async Task UpdateEventTimeslot_IsFallbackAllowed_Success( - DatabaseProvider databaseProvider - ) - { - await using var sut = await Sut.CreateAsync(databaseProvider); - var map = await sut.MinigolfMap().BuildAsync(); - var @event = await sut.Event().WithTimeslot(map.Id).BuildAsync(); - - await sut.AppClient.UpdateEventTimeslotAsync( - @event.Timeslots.ElementAt(0).Id, - new() { IsFallbackAllowed = true } - ); - - @event.Timeslots.ElementAt(0).IsFallbackAllowed = true; - (await sut.AppClient.GetEventAsync(@event.Id)).Event.Should().BeEquivalentTo(@event); - } - [TestMethod] [DatabaseProviderDataSource] public async Task UpdateEventTimeslot_All_Success(DatabaseProvider databaseProvider)