From 205fb71316e3a405c299cba18725dcbdda7ceae9 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 25 May 2024 20:19:37 +0200 Subject: [PATCH] Datenstruktur angepasst --- songrequests_blazor/Data/Library.cs | 22 + songrequests_blazor/Data/LocalDbContext.cs | 60 ++- songrequests_blazor/Data/QueuedSong.cs | 11 +- songrequests_blazor/Data/Session.cs | 7 +- songrequests_blazor/Data/Song.cs | 16 +- songrequests_blazor/Data/User.cs | 1 + .../20240523182804_AddedQueueData.Designer.cs | 408 ------------------ .../20240523182804_AddedQueueData.cs | 130 ------ ...240523183306_CorrectedUserVotesRelation.cs | 80 ---- ...1342_AddQueueDataAndAdminUser.Designer.cs} | 182 ++++++-- ...20240525181342_AddQueueDataAndAdminUser.cs | 264 ++++++++++++ .../Migrations/LocalDbContextModelSnapshot.cs | 178 ++++++-- songrequests_blazor/data.db | Bin 143360 -> 172032 bytes songrequests_blazor/data.db-shm | Bin 0 -> 32768 bytes songrequests_blazor/data.db-wal | 0 15 files changed, 673 insertions(+), 686 deletions(-) create mode 100644 songrequests_blazor/Data/Library.cs delete mode 100644 songrequests_blazor/Migrations/20240523182804_AddedQueueData.Designer.cs delete mode 100644 songrequests_blazor/Migrations/20240523182804_AddedQueueData.cs delete mode 100644 songrequests_blazor/Migrations/20240523183306_CorrectedUserVotesRelation.cs rename songrequests_blazor/Migrations/{20240523183306_CorrectedUserVotesRelation.Designer.cs => 20240525181342_AddQueueDataAndAdminUser.Designer.cs} (69%) create mode 100644 songrequests_blazor/Migrations/20240525181342_AddQueueDataAndAdminUser.cs create mode 100644 songrequests_blazor/data.db-shm create mode 100644 songrequests_blazor/data.db-wal diff --git a/songrequests_blazor/Data/Library.cs b/songrequests_blazor/Data/Library.cs new file mode 100644 index 0000000..d85c3b6 --- /dev/null +++ b/songrequests_blazor/Data/Library.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace songrequests_blazor.Data +{ + public class Library + { + public int Id { get; set; } + public string Name { get; set; } = null!; + public List? Songs { get; set; } + public LibraryType Type { get; set; } + + [Column("Sessions_ID")] + public virtual List? UsedInSessions { get; set; } + + public enum LibraryType + { + Local, + Spotify + } + + } +} diff --git a/songrequests_blazor/Data/LocalDbContext.cs b/songrequests_blazor/Data/LocalDbContext.cs index 57979e9..d16450f 100644 --- a/songrequests_blazor/Data/LocalDbContext.cs +++ b/songrequests_blazor/Data/LocalDbContext.cs @@ -9,10 +9,11 @@ namespace songrequests_blazor.Data public DbSet Songs { get; set; } public DbSet Sessions { get; set; } - public DbSet QueuedSongs { get; set; } + public DbSet QueuedSongs { get; set; } + public DbSet Libraries { get; set; } public LocalDbContext(DbContextOptions options) : base(options) - { } + { } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { } @@ -20,6 +21,61 @@ namespace songrequests_blazor.Data protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); + + // // Foreign Keys und dazugehörige Indizes (aus anderem Beispiel, daher andere Klassen- und Spaltennamen) + // entity.HasIndex(e => e.MAC_ID, "FK_MAC_ID_idx"); + // entity.HasOne(d => d.Machine).WithMany(p => p.Logs).HasForeignKey(d => d.MAC_ID).HasConstraintName("FK_log_machine"); + + modelBuilder.Entity(entity => + { + entity.HasMany(l => l.Songs).WithOne(s => s.Library).HasForeignKey(s => s.Library_ID).HasConstraintName("FK_library_songs"); + //entity.HasMany(l => l.UsedInSessions).WithMany(s => s.EnabledLibraries).UsingEntity("Sessions_Libraries"); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(qs => qs.Song).WithMany(s => s.Queued).HasForeignKey(s => s.Song_ID).HasConstraintName("FK_queuedsongs_song"); + entity.HasMany(qs => qs.UserVotes).WithMany(u => u.VotedSongs).UsingEntity("QueuedSongs_UserVotes"); + entity.HasOne(qs => qs.AdddedBy).WithMany(u => u.AddedSongs).HasForeignKey(qs => qs.AddedBy_User_ID).HasConstraintName("FK_user_addedsongs"); + }); + + modelBuilder.Entity(entity => + { + entity.HasMany(ses => ses.EnabledLibraries).WithMany(l => l.UsedInSessions).UsingEntity("Sessions_Libraries"); + entity.HasMany(ses => ses.QueuedSongs).WithOne(qs => qs.Session).HasForeignKey(qs => qs.Session_ID).HasConstraintName("FK_Session_QueuedSongs"); + + }); + + + string AdminRoleGUID = "fc985a25-19ce-48ed-8443-c845f550960a"; + string AdminUserGUID = "5c2511d0-6a08-4950-babd-d107996749ba"; + + modelBuilder.Entity().HasData( + new IdentityRole { Id = AdminRoleGUID, Name = "Administrator", NormalizedName = "ADMINISTRATOR".ToUpper() } + ); + + var hasher = new PasswordHasher(); + var AdminUser = new IdentityUser() + { + Id = AdminUserGUID, // primary key + UserName = "admin@admin.com", + NormalizedUserName = "ADMIN@ADMIN.COM", + Email = "admin@admin.com", + NormalizedEmail = "ADMIN@ADMIN.COM" + }; + AdminUser.PasswordHash = hasher.HashPassword(AdminUser, "admin"); + + modelBuilder.Entity().HasData(AdminUser); + + modelBuilder.Entity>().HasData( + new IdentityUserRole + { + RoleId = AdminRoleGUID, + UserId = AdminUserGUID + } + ); + + // Erweitertes definieren des Datenbankmodells (falls benötigt): //modelBuilder.Entity(entity => //{ diff --git a/songrequests_blazor/Data/QueuedSong.cs b/songrequests_blazor/Data/QueuedSong.cs index baccd29..e53a136 100644 --- a/songrequests_blazor/Data/QueuedSong.cs +++ b/songrequests_blazor/Data/QueuedSong.cs @@ -4,10 +4,17 @@ { public int Id { get; set; } public int Position { get; set; } + public int Song_ID { get; set; } public Song Song { get; set; } = null!; - public DateTime Added { get; set; } - public DateTime Played { get; set; } + + public string? AddedBy_User_ID { get; set; } + public User? AdddedBy { get; set; } + public DateTime Added { get; set; } = DateTime.Now; + public DateTime? Played { get; set; } public List? UserVotes { get; set; } + public int Session_ID { get; set; } + public virtual Session Session { get; set; } = null!; + } } diff --git a/songrequests_blazor/Data/Session.cs b/songrequests_blazor/Data/Session.cs index 0776b89..ceb4f4b 100644 --- a/songrequests_blazor/Data/Session.cs +++ b/songrequests_blazor/Data/Session.cs @@ -5,7 +5,10 @@ public int Id { get; set; } public string? SessionCode { get; set; } - public List Queue { get; set; } = null!; - public DateTime Created { get; set; } + public bool Active { get; set; } + public List EnabledLibraries { get; set; } = null!; + public List QueuedSongs { get; set; } = null!; + + public DateTime Created { get; set; } = DateTime.Now; } } diff --git a/songrequests_blazor/Data/Song.cs b/songrequests_blazor/Data/Song.cs index 548c96c..ec010ee 100644 --- a/songrequests_blazor/Data/Song.cs +++ b/songrequests_blazor/Data/Song.cs @@ -7,7 +7,8 @@ namespace songrequests_blazor.Data public class Song { public int Id { get; set; } - + public string Uri { get; set; } = null!; + // Tag-Parameter public string Title { get; set; } = null!; public string? Artist { get; set; } @@ -16,19 +17,14 @@ namespace songrequests_blazor.Data public string? Genre { get; set; } public TimeSpan Length { get; set; } - // File-Parameter - public SourceType Source { get; set; } - public string SourceUri { get; set; } = null!; - // Statistics public int RequestCount { get; set; } - public enum SourceType - { - LocalFile, - Spotify - } + public int Library_ID { get; set; } + public virtual Library Library { get; set; } = null!; + + public virtual List? Queued { get; set; } } } diff --git a/songrequests_blazor/Data/User.cs b/songrequests_blazor/Data/User.cs index 374cd54..0e67b1c 100644 --- a/songrequests_blazor/Data/User.cs +++ b/songrequests_blazor/Data/User.cs @@ -5,5 +5,6 @@ namespace songrequests_blazor.Data public class User : IdentityUser { public List? VotedSongs { get; set; } + public List? AddedSongs { get; set; } } } diff --git a/songrequests_blazor/Migrations/20240523182804_AddedQueueData.Designer.cs b/songrequests_blazor/Migrations/20240523182804_AddedQueueData.Designer.cs deleted file mode 100644 index 3ebc431..0000000 --- a/songrequests_blazor/Migrations/20240523182804_AddedQueueData.Designer.cs +++ /dev/null @@ -1,408 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using songrequests_blazor.Data; - -#nullable disable - -namespace songrequests_blazor.Migrations -{ - [DbContext(typeof(LocalDbContext))] - [Migration("20240523182804_AddedQueueData")] - partial class AddedQueueData - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.5"); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("TEXT"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ClaimType") - .HasColumnType("TEXT"); - - b.Property("ClaimValue") - .HasColumnType("TEXT"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("AccessFailedCount") - .HasColumnType("INTEGER"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("TEXT"); - - b.Property("Discriminator") - .IsRequired() - .HasMaxLength(13) - .HasColumnType("TEXT"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.Property("EmailConfirmed") - .HasColumnType("INTEGER"); - - b.Property("LockoutEnabled") - .HasColumnType("INTEGER"); - - b.Property("LockoutEnd") - .HasColumnType("TEXT"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.Property("PasswordHash") - .HasColumnType("TEXT"); - - b.Property("PhoneNumber") - .HasColumnType("TEXT"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("INTEGER"); - - b.Property("SecurityStamp") - .HasColumnType("TEXT"); - - b.Property("TwoFactorEnabled") - .HasColumnType("INTEGER"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - - b.HasDiscriminator("Discriminator").HasValue("IdentityUser"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ClaimType") - .HasColumnType("TEXT"); - - b.Property("ClaimValue") - .HasColumnType("TEXT"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("TEXT"); - - b.Property("ProviderKey") - .HasColumnType("TEXT"); - - b.Property("ProviderDisplayName") - .HasColumnType("TEXT"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("TEXT"); - - b.Property("RoleId") - .HasColumnType("TEXT"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("TEXT"); - - b.Property("LoginProvider") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Value") - .HasColumnType("TEXT"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("songrequests_blazor.Data.QueuedSong", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Added") - .HasColumnType("TEXT"); - - b.Property("Played") - .HasColumnType("TEXT"); - - b.Property("Position") - .HasColumnType("INTEGER"); - - b.Property("SessionId") - .HasColumnType("INTEGER"); - - b.Property("SongId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("SessionId"); - - b.HasIndex("SongId"); - - b.ToTable("QueuedSongs"); - }); - - modelBuilder.Entity("songrequests_blazor.Data.Session", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Created") - .HasColumnType("TEXT"); - - b.Property("SessionCode") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Sessions"); - }); - - modelBuilder.Entity("songrequests_blazor.Data.Song", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Album") - .HasColumnType("TEXT"); - - b.Property("Artist") - .HasColumnType("TEXT"); - - b.Property("Genre") - .HasColumnType("TEXT"); - - b.Property("Length") - .HasColumnType("TEXT"); - - b.Property("RequestCount") - .HasColumnType("INTEGER"); - - b.Property("Source") - .HasColumnType("INTEGER"); - - b.Property("SourceUri") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Title") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Year") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.ToTable("Songs"); - }); - - modelBuilder.Entity("songrequests_blazor.Data.User", b => - { - b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); - - b.Property("QueuedSongId") - .HasColumnType("INTEGER"); - - b.HasIndex("QueuedSongId"); - - b.HasDiscriminator().HasValue("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("songrequests_blazor.Data.QueuedSong", b => - { - b.HasOne("songrequests_blazor.Data.Session", null) - .WithMany("Queue") - .HasForeignKey("SessionId"); - - b.HasOne("songrequests_blazor.Data.Song", "Song") - .WithMany() - .HasForeignKey("SongId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Song"); - }); - - modelBuilder.Entity("songrequests_blazor.Data.User", b => - { - b.HasOne("songrequests_blazor.Data.QueuedSong", null) - .WithMany("Votes") - .HasForeignKey("QueuedSongId"); - }); - - modelBuilder.Entity("songrequests_blazor.Data.QueuedSong", b => - { - b.Navigation("Votes"); - }); - - modelBuilder.Entity("songrequests_blazor.Data.Session", b => - { - b.Navigation("Queue"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/songrequests_blazor/Migrations/20240523182804_AddedQueueData.cs b/songrequests_blazor/Migrations/20240523182804_AddedQueueData.cs deleted file mode 100644 index 24ec6dc..0000000 --- a/songrequests_blazor/Migrations/20240523182804_AddedQueueData.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace songrequests_blazor.Migrations -{ - /// - public partial class AddedQueueData : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "RequestCount", - table: "Songs", - type: "INTEGER", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "Discriminator", - table: "AspNetUsers", - type: "TEXT", - maxLength: 13, - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "QueuedSongId", - table: "AspNetUsers", - type: "INTEGER", - nullable: true); - - migrationBuilder.CreateTable( - name: "Sessions", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - SessionCode = table.Column(type: "TEXT", nullable: true), - Created = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Sessions", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "QueuedSongs", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Position = table.Column(type: "INTEGER", nullable: false), - SongId = table.Column(type: "INTEGER", nullable: false), - Added = table.Column(type: "TEXT", nullable: false), - Played = table.Column(type: "TEXT", nullable: false), - SessionId = table.Column(type: "INTEGER", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_QueuedSongs", x => x.Id); - table.ForeignKey( - name: "FK_QueuedSongs_Sessions_SessionId", - column: x => x.SessionId, - principalTable: "Sessions", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_QueuedSongs_Songs_SongId", - column: x => x.SongId, - principalTable: "Songs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUsers_QueuedSongId", - table: "AspNetUsers", - column: "QueuedSongId"); - - migrationBuilder.CreateIndex( - name: "IX_QueuedSongs_SessionId", - table: "QueuedSongs", - column: "SessionId"); - - migrationBuilder.CreateIndex( - name: "IX_QueuedSongs_SongId", - table: "QueuedSongs", - column: "SongId"); - - migrationBuilder.AddForeignKey( - name: "FK_AspNetUsers_QueuedSongs_QueuedSongId", - table: "AspNetUsers", - column: "QueuedSongId", - principalTable: "QueuedSongs", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_AspNetUsers_QueuedSongs_QueuedSongId", - table: "AspNetUsers"); - - migrationBuilder.DropTable( - name: "QueuedSongs"); - - migrationBuilder.DropTable( - name: "Sessions"); - - migrationBuilder.DropIndex( - name: "IX_AspNetUsers_QueuedSongId", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "RequestCount", - table: "Songs"); - - migrationBuilder.DropColumn( - name: "Discriminator", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "QueuedSongId", - table: "AspNetUsers"); - } - } -} diff --git a/songrequests_blazor/Migrations/20240523183306_CorrectedUserVotesRelation.cs b/songrequests_blazor/Migrations/20240523183306_CorrectedUserVotesRelation.cs deleted file mode 100644 index 76c460e..0000000 --- a/songrequests_blazor/Migrations/20240523183306_CorrectedUserVotesRelation.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace songrequests_blazor.Migrations -{ - /// - public partial class CorrectedUserVotesRelation : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_AspNetUsers_QueuedSongs_QueuedSongId", - table: "AspNetUsers"); - - migrationBuilder.DropIndex( - name: "IX_AspNetUsers_QueuedSongId", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "QueuedSongId", - table: "AspNetUsers"); - - migrationBuilder.CreateTable( - name: "QueuedSongUser", - columns: table => new - { - VotedSongsId = table.Column(type: "INTEGER", nullable: false), - VotesId = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_QueuedSongUser", x => new { x.VotedSongsId, x.VotesId }); - table.ForeignKey( - name: "FK_QueuedSongUser_AspNetUsers_VotesId", - column: x => x.VotesId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_QueuedSongUser_QueuedSongs_VotedSongsId", - column: x => x.VotedSongsId, - principalTable: "QueuedSongs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_QueuedSongUser_VotesId", - table: "QueuedSongUser", - column: "VotesId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "QueuedSongUser"); - - migrationBuilder.AddColumn( - name: "QueuedSongId", - table: "AspNetUsers", - type: "INTEGER", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUsers_QueuedSongId", - table: "AspNetUsers", - column: "QueuedSongId"); - - migrationBuilder.AddForeignKey( - name: "FK_AspNetUsers_QueuedSongs_QueuedSongId", - table: "AspNetUsers", - column: "QueuedSongId", - principalTable: "QueuedSongs", - principalColumn: "Id"); - } - } -} diff --git a/songrequests_blazor/Migrations/20240523183306_CorrectedUserVotesRelation.Designer.cs b/songrequests_blazor/Migrations/20240525181342_AddQueueDataAndAdminUser.Designer.cs similarity index 69% rename from songrequests_blazor/Migrations/20240523183306_CorrectedUserVotesRelation.Designer.cs rename to songrequests_blazor/Migrations/20240525181342_AddQueueDataAndAdminUser.Designer.cs index bf28d12..0d3278c 100644 --- a/songrequests_blazor/Migrations/20240523183306_CorrectedUserVotesRelation.Designer.cs +++ b/songrequests_blazor/Migrations/20240525181342_AddQueueDataAndAdminUser.Designer.cs @@ -11,8 +11,8 @@ using songrequests_blazor.Data; namespace songrequests_blazor.Migrations { [DbContext(typeof(LocalDbContext))] - [Migration("20240523183306_CorrectedUserVotesRelation")] - partial class CorrectedUserVotesRelation + [Migration("20240525181342_AddQueueDataAndAdminUser")] + partial class AddQueueDataAndAdminUser { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -44,6 +44,14 @@ namespace songrequests_blazor.Migrations .HasDatabaseName("RoleNameIndex"); b.ToTable("AspNetRoles", (string)null); + + b.HasData( + new + { + Id = "fc985a25-19ce-48ed-8443-c845f550960a", + Name = "Administrator", + NormalizedName = "ADMINISTRATOR" + }); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => @@ -140,6 +148,24 @@ namespace songrequests_blazor.Migrations b.HasDiscriminator("Discriminator").HasValue("IdentityUser"); b.UseTphMappingStrategy(); + + b.HasData( + new + { + Id = "5c2511d0-6a08-4950-babd-d107996749ba", + AccessFailedCount = 0, + ConcurrencyStamp = "828466b4-e932-48c2-9ac5-2d5a16bbbade", + Email = "admin@admin.com", + EmailConfirmed = false, + LockoutEnabled = false, + NormalizedEmail = "ADMIN@ADMIN.COM", + NormalizedUserName = "ADMIN@ADMIN.COM", + PasswordHash = "AQAAAAIAAYagAAAAEAHO/Ra7WSxWtOXx++pYevyMsD+Wt/8tsCfJtQ59NaWFxF7BztGzvgNrnblXuYOkww==", + PhoneNumberConfirmed = false, + SecurityStamp = "23975ce5-b515-4a6a-a6b7-2a5e6d8c943e", + TwoFactorEnabled = false, + UserName = "admin@admin.com" + }); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => @@ -200,6 +226,13 @@ namespace songrequests_blazor.Migrations b.HasIndex("RoleId"); b.ToTable("AspNetUserRoles", (string)null); + + b.HasData( + new + { + UserId = "5c2511d0-6a08-4950-babd-d107996749ba", + RoleId = "fc985a25-19ce-48ed-8443-c845f550960a" + }); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => @@ -221,19 +254,52 @@ namespace songrequests_blazor.Migrations b.ToTable("AspNetUserTokens", (string)null); }); - modelBuilder.Entity("QueuedSongUser", b => + modelBuilder.Entity("QueuedSongs_UserVotes", b => { + b.Property("UserVotesId") + .HasColumnType("TEXT"); + b.Property("VotedSongsId") .HasColumnType("INTEGER"); - b.Property("VotesId") + b.HasKey("UserVotesId", "VotedSongsId"); + + b.HasIndex("VotedSongsId"); + + b.ToTable("QueuedSongs_UserVotes"); + }); + + modelBuilder.Entity("Sessions_Libraries", b => + { + b.Property("EnabledLibrariesId") + .HasColumnType("INTEGER"); + + b.Property("UsedInSessionsId") + .HasColumnType("INTEGER"); + + b.HasKey("EnabledLibrariesId", "UsedInSessionsId"); + + b.HasIndex("UsedInSessionsId"); + + b.ToTable("Sessions_Libraries"); + }); + + modelBuilder.Entity("songrequests_blazor.Data.Library", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() .HasColumnType("TEXT"); - b.HasKey("VotedSongsId", "VotesId"); + b.Property("Type") + .HasColumnType("INTEGER"); - b.HasIndex("VotesId"); + b.HasKey("Id"); - b.ToTable("QueuedSongUser"); + b.ToTable("Libraries"); }); modelBuilder.Entity("songrequests_blazor.Data.QueuedSong", b => @@ -245,23 +311,28 @@ namespace songrequests_blazor.Migrations b.Property("Added") .HasColumnType("TEXT"); - b.Property("Played") + b.Property("AddedBy_User_ID") + .HasColumnType("TEXT"); + + b.Property("Played") .HasColumnType("TEXT"); b.Property("Position") .HasColumnType("INTEGER"); - b.Property("SessionId") + b.Property("Session_ID") .HasColumnType("INTEGER"); - b.Property("SongId") + b.Property("Song_ID") .HasColumnType("INTEGER"); b.HasKey("Id"); - b.HasIndex("SessionId"); + b.HasIndex("AddedBy_User_ID"); - b.HasIndex("SongId"); + b.HasIndex("Session_ID"); + + b.HasIndex("Song_ID"); b.ToTable("QueuedSongs"); }); @@ -301,17 +372,17 @@ namespace songrequests_blazor.Migrations b.Property("Length") .HasColumnType("TEXT"); + b.Property("Library_ID") + .HasColumnType("INTEGER"); + b.Property("RequestCount") .HasColumnType("INTEGER"); - b.Property("Source") - .HasColumnType("INTEGER"); - - b.Property("SourceUri") + b.Property("Title") .IsRequired() .HasColumnType("TEXT"); - b.Property("Title") + b.Property("Uri") .IsRequired() .HasColumnType("TEXT"); @@ -320,6 +391,8 @@ namespace songrequests_blazor.Migrations b.HasKey("Id"); + b.HasIndex("Library_ID"); + b.ToTable("Songs"); }); @@ -381,39 +454,94 @@ namespace songrequests_blazor.Migrations .IsRequired(); }); - modelBuilder.Entity("QueuedSongUser", b => + modelBuilder.Entity("QueuedSongs_UserVotes", b => { + b.HasOne("songrequests_blazor.Data.User", null) + .WithMany() + .HasForeignKey("UserVotesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("songrequests_blazor.Data.QueuedSong", null) .WithMany() .HasForeignKey("VotedSongsId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + }); - b.HasOne("songrequests_blazor.Data.User", null) + modelBuilder.Entity("Sessions_Libraries", b => + { + b.HasOne("songrequests_blazor.Data.Library", null) .WithMany() - .HasForeignKey("VotesId") + .HasForeignKey("EnabledLibrariesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("songrequests_blazor.Data.Session", null) + .WithMany() + .HasForeignKey("UsedInSessionsId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); modelBuilder.Entity("songrequests_blazor.Data.QueuedSong", b => { - b.HasOne("songrequests_blazor.Data.Session", null) - .WithMany("Queue") - .HasForeignKey("SessionId"); + b.HasOne("songrequests_blazor.Data.User", "AdddedBy") + .WithMany("AddedSongs") + .HasForeignKey("AddedBy_User_ID") + .HasConstraintName("FK_user_addedsongs"); + + b.HasOne("songrequests_blazor.Data.Session", "Session") + .WithMany("QueuedSongs") + .HasForeignKey("Session_ID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_Session_QueuedSongs"); b.HasOne("songrequests_blazor.Data.Song", "Song") - .WithMany() - .HasForeignKey("SongId") + .WithMany("Queued") + .HasForeignKey("Song_ID") .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .IsRequired() + .HasConstraintName("FK_queuedsongs_song"); + + b.Navigation("AdddedBy"); + + b.Navigation("Session"); b.Navigation("Song"); }); + modelBuilder.Entity("songrequests_blazor.Data.Song", b => + { + b.HasOne("songrequests_blazor.Data.Library", "Library") + .WithMany("Songs") + .HasForeignKey("Library_ID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_library_songs"); + + b.Navigation("Library"); + }); + + modelBuilder.Entity("songrequests_blazor.Data.Library", b => + { + b.Navigation("Songs"); + }); + modelBuilder.Entity("songrequests_blazor.Data.Session", b => { - b.Navigation("Queue"); + b.Navigation("QueuedSongs"); + }); + + modelBuilder.Entity("songrequests_blazor.Data.Song", b => + { + b.Navigation("Queued"); + }); + + modelBuilder.Entity("songrequests_blazor.Data.User", b => + { + b.Navigation("AddedSongs"); }); #pragma warning restore 612, 618 } diff --git a/songrequests_blazor/Migrations/20240525181342_AddQueueDataAndAdminUser.cs b/songrequests_blazor/Migrations/20240525181342_AddQueueDataAndAdminUser.cs new file mode 100644 index 0000000..10330e3 --- /dev/null +++ b/songrequests_blazor/Migrations/20240525181342_AddQueueDataAndAdminUser.cs @@ -0,0 +1,264 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace songrequests_blazor.Migrations +{ + /// + public partial class AddQueueDataAndAdminUser : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "SourceUri", + table: "Songs", + newName: "Uri"); + + migrationBuilder.RenameColumn( + name: "Source", + table: "Songs", + newName: "RequestCount"); + + migrationBuilder.AddColumn( + name: "Library_ID", + table: "Songs", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "Discriminator", + table: "AspNetUsers", + type: "TEXT", + maxLength: 13, + nullable: false, + defaultValue: ""); + + migrationBuilder.CreateTable( + name: "Libraries", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + Type = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Libraries", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Sessions", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + SessionCode = table.Column(type: "TEXT", nullable: true), + Created = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Sessions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "QueuedSongs", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Position = table.Column(type: "INTEGER", nullable: false), + Song_ID = table.Column(type: "INTEGER", nullable: false), + AddedBy_User_ID = table.Column(type: "TEXT", nullable: true), + Added = table.Column(type: "TEXT", nullable: false), + Played = table.Column(type: "TEXT", nullable: true), + Session_ID = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_QueuedSongs", x => x.Id); + table.ForeignKey( + name: "FK_Session_QueuedSongs", + column: x => x.Session_ID, + principalTable: "Sessions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_queuedsongs_song", + column: x => x.Song_ID, + principalTable: "Songs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_user_addedsongs", + column: x => x.AddedBy_User_ID, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Sessions_Libraries", + columns: table => new + { + EnabledLibrariesId = table.Column(type: "INTEGER", nullable: false), + UsedInSessionsId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Sessions_Libraries", x => new { x.EnabledLibrariesId, x.UsedInSessionsId }); + table.ForeignKey( + name: "FK_Sessions_Libraries_Libraries_EnabledLibrariesId", + column: x => x.EnabledLibrariesId, + principalTable: "Libraries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Sessions_Libraries_Sessions_UsedInSessionsId", + column: x => x.UsedInSessionsId, + principalTable: "Sessions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "QueuedSongs_UserVotes", + columns: table => new + { + UserVotesId = table.Column(type: "TEXT", nullable: false), + VotedSongsId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_QueuedSongs_UserVotes", x => new { x.UserVotesId, x.VotedSongsId }); + table.ForeignKey( + name: "FK_QueuedSongs_UserVotes_AspNetUsers_UserVotesId", + column: x => x.UserVotesId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_QueuedSongs_UserVotes_QueuedSongs_VotedSongsId", + column: x => x.VotedSongsId, + principalTable: "QueuedSongs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "AspNetRoles", + columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, + values: new object[] { "fc985a25-19ce-48ed-8443-c845f550960a", null, "Administrator", "ADMINISTRATOR" }); + + migrationBuilder.InsertData( + table: "AspNetUsers", + columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Discriminator", "Email", "EmailConfirmed", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" }, + values: new object[] { "5c2511d0-6a08-4950-babd-d107996749ba", 0, "828466b4-e932-48c2-9ac5-2d5a16bbbade", "IdentityUser", "admin@admin.com", false, false, null, "ADMIN@ADMIN.COM", "ADMIN@ADMIN.COM", "AQAAAAIAAYagAAAAEAHO/Ra7WSxWtOXx++pYevyMsD+Wt/8tsCfJtQ59NaWFxF7BztGzvgNrnblXuYOkww==", null, false, "23975ce5-b515-4a6a-a6b7-2a5e6d8c943e", false, "admin@admin.com" }); + + migrationBuilder.InsertData( + table: "AspNetUserRoles", + columns: new[] { "RoleId", "UserId" }, + values: new object[] { "fc985a25-19ce-48ed-8443-c845f550960a", "5c2511d0-6a08-4950-babd-d107996749ba" }); + + migrationBuilder.CreateIndex( + name: "IX_Songs_Library_ID", + table: "Songs", + column: "Library_ID"); + + migrationBuilder.CreateIndex( + name: "IX_QueuedSongs_AddedBy_User_ID", + table: "QueuedSongs", + column: "AddedBy_User_ID"); + + migrationBuilder.CreateIndex( + name: "IX_QueuedSongs_Session_ID", + table: "QueuedSongs", + column: "Session_ID"); + + migrationBuilder.CreateIndex( + name: "IX_QueuedSongs_Song_ID", + table: "QueuedSongs", + column: "Song_ID"); + + migrationBuilder.CreateIndex( + name: "IX_QueuedSongs_UserVotes_VotedSongsId", + table: "QueuedSongs_UserVotes", + column: "VotedSongsId"); + + migrationBuilder.CreateIndex( + name: "IX_Sessions_Libraries_UsedInSessionsId", + table: "Sessions_Libraries", + column: "UsedInSessionsId"); + + migrationBuilder.AddForeignKey( + name: "FK_library_songs", + table: "Songs", + column: "Library_ID", + principalTable: "Libraries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_library_songs", + table: "Songs"); + + migrationBuilder.DropTable( + name: "QueuedSongs_UserVotes"); + + migrationBuilder.DropTable( + name: "Sessions_Libraries"); + + migrationBuilder.DropTable( + name: "QueuedSongs"); + + migrationBuilder.DropTable( + name: "Libraries"); + + migrationBuilder.DropTable( + name: "Sessions"); + + migrationBuilder.DropIndex( + name: "IX_Songs_Library_ID", + table: "Songs"); + + migrationBuilder.DeleteData( + table: "AspNetUserRoles", + keyColumns: new[] { "RoleId", "UserId" }, + keyValues: new object[] { "fc985a25-19ce-48ed-8443-c845f550960a", "5c2511d0-6a08-4950-babd-d107996749ba" }); + + migrationBuilder.DeleteData( + table: "AspNetRoles", + keyColumn: "Id", + keyValue: "fc985a25-19ce-48ed-8443-c845f550960a"); + + migrationBuilder.DeleteData( + table: "AspNetUsers", + keyColumn: "Id", + keyValue: "5c2511d0-6a08-4950-babd-d107996749ba"); + + migrationBuilder.DropColumn( + name: "Library_ID", + table: "Songs"); + + migrationBuilder.DropColumn( + name: "Discriminator", + table: "AspNetUsers"); + + migrationBuilder.RenameColumn( + name: "Uri", + table: "Songs", + newName: "SourceUri"); + + migrationBuilder.RenameColumn( + name: "RequestCount", + table: "Songs", + newName: "Source"); + } + } +} diff --git a/songrequests_blazor/Migrations/LocalDbContextModelSnapshot.cs b/songrequests_blazor/Migrations/LocalDbContextModelSnapshot.cs index 703e535..3787e82 100644 --- a/songrequests_blazor/Migrations/LocalDbContextModelSnapshot.cs +++ b/songrequests_blazor/Migrations/LocalDbContextModelSnapshot.cs @@ -41,6 +41,14 @@ namespace songrequests_blazor.Migrations .HasDatabaseName("RoleNameIndex"); b.ToTable("AspNetRoles", (string)null); + + b.HasData( + new + { + Id = "fc985a25-19ce-48ed-8443-c845f550960a", + Name = "Administrator", + NormalizedName = "ADMINISTRATOR" + }); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => @@ -137,6 +145,24 @@ namespace songrequests_blazor.Migrations b.HasDiscriminator("Discriminator").HasValue("IdentityUser"); b.UseTphMappingStrategy(); + + b.HasData( + new + { + Id = "5c2511d0-6a08-4950-babd-d107996749ba", + AccessFailedCount = 0, + ConcurrencyStamp = "828466b4-e932-48c2-9ac5-2d5a16bbbade", + Email = "admin@admin.com", + EmailConfirmed = false, + LockoutEnabled = false, + NormalizedEmail = "ADMIN@ADMIN.COM", + NormalizedUserName = "ADMIN@ADMIN.COM", + PasswordHash = "AQAAAAIAAYagAAAAEAHO/Ra7WSxWtOXx++pYevyMsD+Wt/8tsCfJtQ59NaWFxF7BztGzvgNrnblXuYOkww==", + PhoneNumberConfirmed = false, + SecurityStamp = "23975ce5-b515-4a6a-a6b7-2a5e6d8c943e", + TwoFactorEnabled = false, + UserName = "admin@admin.com" + }); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => @@ -197,6 +223,13 @@ namespace songrequests_blazor.Migrations b.HasIndex("RoleId"); b.ToTable("AspNetUserRoles", (string)null); + + b.HasData( + new + { + UserId = "5c2511d0-6a08-4950-babd-d107996749ba", + RoleId = "fc985a25-19ce-48ed-8443-c845f550960a" + }); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => @@ -218,19 +251,52 @@ namespace songrequests_blazor.Migrations b.ToTable("AspNetUserTokens", (string)null); }); - modelBuilder.Entity("QueuedSongUser", b => + modelBuilder.Entity("QueuedSongs_UserVotes", b => { + b.Property("UserVotesId") + .HasColumnType("TEXT"); + b.Property("VotedSongsId") .HasColumnType("INTEGER"); - b.Property("VotesId") + b.HasKey("UserVotesId", "VotedSongsId"); + + b.HasIndex("VotedSongsId"); + + b.ToTable("QueuedSongs_UserVotes"); + }); + + modelBuilder.Entity("Sessions_Libraries", b => + { + b.Property("EnabledLibrariesId") + .HasColumnType("INTEGER"); + + b.Property("UsedInSessionsId") + .HasColumnType("INTEGER"); + + b.HasKey("EnabledLibrariesId", "UsedInSessionsId"); + + b.HasIndex("UsedInSessionsId"); + + b.ToTable("Sessions_Libraries"); + }); + + modelBuilder.Entity("songrequests_blazor.Data.Library", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() .HasColumnType("TEXT"); - b.HasKey("VotedSongsId", "VotesId"); + b.Property("Type") + .HasColumnType("INTEGER"); - b.HasIndex("VotesId"); + b.HasKey("Id"); - b.ToTable("QueuedSongUser"); + b.ToTable("Libraries"); }); modelBuilder.Entity("songrequests_blazor.Data.QueuedSong", b => @@ -242,23 +308,28 @@ namespace songrequests_blazor.Migrations b.Property("Added") .HasColumnType("TEXT"); - b.Property("Played") + b.Property("AddedBy_User_ID") + .HasColumnType("TEXT"); + + b.Property("Played") .HasColumnType("TEXT"); b.Property("Position") .HasColumnType("INTEGER"); - b.Property("SessionId") + b.Property("Session_ID") .HasColumnType("INTEGER"); - b.Property("SongId") + b.Property("Song_ID") .HasColumnType("INTEGER"); b.HasKey("Id"); - b.HasIndex("SessionId"); + b.HasIndex("AddedBy_User_ID"); - b.HasIndex("SongId"); + b.HasIndex("Session_ID"); + + b.HasIndex("Song_ID"); b.ToTable("QueuedSongs"); }); @@ -298,17 +369,17 @@ namespace songrequests_blazor.Migrations b.Property("Length") .HasColumnType("TEXT"); + b.Property("Library_ID") + .HasColumnType("INTEGER"); + b.Property("RequestCount") .HasColumnType("INTEGER"); - b.Property("Source") - .HasColumnType("INTEGER"); - - b.Property("SourceUri") + b.Property("Title") .IsRequired() .HasColumnType("TEXT"); - b.Property("Title") + b.Property("Uri") .IsRequired() .HasColumnType("TEXT"); @@ -317,6 +388,8 @@ namespace songrequests_blazor.Migrations b.HasKey("Id"); + b.HasIndex("Library_ID"); + b.ToTable("Songs"); }); @@ -378,39 +451,94 @@ namespace songrequests_blazor.Migrations .IsRequired(); }); - modelBuilder.Entity("QueuedSongUser", b => + modelBuilder.Entity("QueuedSongs_UserVotes", b => { + b.HasOne("songrequests_blazor.Data.User", null) + .WithMany() + .HasForeignKey("UserVotesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("songrequests_blazor.Data.QueuedSong", null) .WithMany() .HasForeignKey("VotedSongsId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + }); - b.HasOne("songrequests_blazor.Data.User", null) + modelBuilder.Entity("Sessions_Libraries", b => + { + b.HasOne("songrequests_blazor.Data.Library", null) .WithMany() - .HasForeignKey("VotesId") + .HasForeignKey("EnabledLibrariesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("songrequests_blazor.Data.Session", null) + .WithMany() + .HasForeignKey("UsedInSessionsId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); modelBuilder.Entity("songrequests_blazor.Data.QueuedSong", b => { - b.HasOne("songrequests_blazor.Data.Session", null) - .WithMany("Queue") - .HasForeignKey("SessionId"); + b.HasOne("songrequests_blazor.Data.User", "AdddedBy") + .WithMany("AddedSongs") + .HasForeignKey("AddedBy_User_ID") + .HasConstraintName("FK_user_addedsongs"); + + b.HasOne("songrequests_blazor.Data.Session", "Session") + .WithMany("QueuedSongs") + .HasForeignKey("Session_ID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_Session_QueuedSongs"); b.HasOne("songrequests_blazor.Data.Song", "Song") - .WithMany() - .HasForeignKey("SongId") + .WithMany("Queued") + .HasForeignKey("Song_ID") .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .IsRequired() + .HasConstraintName("FK_queuedsongs_song"); + + b.Navigation("AdddedBy"); + + b.Navigation("Session"); b.Navigation("Song"); }); + modelBuilder.Entity("songrequests_blazor.Data.Song", b => + { + b.HasOne("songrequests_blazor.Data.Library", "Library") + .WithMany("Songs") + .HasForeignKey("Library_ID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_library_songs"); + + b.Navigation("Library"); + }); + + modelBuilder.Entity("songrequests_blazor.Data.Library", b => + { + b.Navigation("Songs"); + }); + modelBuilder.Entity("songrequests_blazor.Data.Session", b => { - b.Navigation("Queue"); + b.Navigation("QueuedSongs"); + }); + + modelBuilder.Entity("songrequests_blazor.Data.Song", b => + { + b.Navigation("Queued"); + }); + + modelBuilder.Entity("songrequests_blazor.Data.User", b => + { + b.Navigation("AddedSongs"); }); #pragma warning restore 612, 618 } diff --git a/songrequests_blazor/data.db b/songrequests_blazor/data.db index 2a083e78160bfeaabcf192651872cba4014048bd..92c73a421592e1c1179f344841ac83e533b64679 100644 GIT binary patch delta 4370 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 W%>CzG`TtLR&6`s!FY#Tr8vX~W@I4v; delta 2975 zcmc&$X>1$E72dbI;;|ArqAZ&_O`4Ko5!Nbua+h`ji&AKsI!N8I)TT6#m8N{uTL=!axudO@JO~TA+3Fqb-o6?d-~q zMOko+7HCP#>|F1?`QH2H%`Er574Ki zrs~nB?khhkoJ9?17_(1Nb@eV%GiZ@QAD}W?EPI60h!q(oRa)|ObfpWkbEoufpIt3|gbmN9YZ-Ml_v8EYGB%wCro& zYiVNkFfq8lk`Ev5D6_Xd^Sy8sY>tm9^f6jT>t#>RE2ul(cX(iUG(H&_?}-gX;)7Cm zUvkLAA#9m2$EDIA=KMDF8Tvc=r0kjhEpoFA1&mqI3`03zUt|5(*tMQ(>@7br__=SN z^9EH%B`EiM=vCJZ_Z3^(Icxtt`)g(&cL653L`@Uts(zumlX{OzT)Gs%kw;+(SMPwO z@>l4aP@ZGUuztJ=mcU8d?Ov}Jmb2w|oJoK#e8K~M{J96J*ZS4UP13p=Qs~%p4@(tGky4s4K z!;Bwy4d!b__$yUItx&cmc9A{}XMp2=2Y;hh9HaDss-ILHqN3!#`4_zu*u_>9@ zY)Bb1se*BGJ{8H&Cyc^G-Z-64iQ5deeYf52Js5;y>+GqV@vZoglokEl*xadOrc`Qj zu3+Tj8=UxJv=zI~)6HMqyddCDCj5a);efw0a9chQJlSIRYHd(--D@bHGRAv8 z!NW3K!NVdnq>);#&mODG_URj1^ z|Hk*+F-x(rTub`IHRp~Ib~i%+7j<|Y|6)J1VE-fFD1BJnKuXp6aF}qJ4}R}>!0rtO z;aSfXPnwLn>rAs}H~raQH=Be`_@D?~MEyT6(5+bT0>Z-=Y0kAVOESq&WONFDW0kJA zclj;q;R_e(4v#rsaTM^o7in*m#m$o7^geI%;lC)b%M1(0nyYbgl|I3dJj$D}R+=qX z{`Cz<+9i7Tr{t-*mJ#x9^SmT}Aj63EEi_Nv;gH{^k4eQDAG= z*SxqsFaMs8ene5k(&!3)sI$h{Fb}~JCLh8=WovgeR7B;Sn%E67X z$9t8yJk~ofGTz@iJsz4&Mk3L~L_8@?#}6m_ha%f4FZR>-q6rC7$PmLipUcV$uSj~1 z56c;a*Hq0|&~jN-BM@{cY=pz2$g3e~hF8);j@Q+Yz{_D#2!(Z7(5KJ8hDHaE^p9$N@xJkBDE9a^d%Jya0r~n#X(WZv zj=WM9I++Q05CSpg!u!SMPH5=8%!KnnP@8WiaH1{>b-7-0y+jCp*|k6)t)Tb+l--2L z3*^zWg%8#P=|5pNL3ep8m@jkS!vB%nCbxH1kh?en9)h3)_gshZnt0AQRhTWDv2yk0 p>oCs&dY?k?qi4`FgiGH+W8Z!tB9X96iH&{d}{p!v3e*;w?MXdk; diff --git a/songrequests_blazor/data.db-shm b/songrequests_blazor/data.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10 GIT binary patch literal 32768 zcmeIuAr62r3