From 115b977f8aac029269a9308d0284f8a85493af27 Mon Sep 17 00:00:00 2001 From: Joseph Sawyer Date: Tue, 22 Oct 2024 01:07:37 +0100 Subject: [PATCH 1/6] feat: add mssql sqlserver support --- .../Context/MsSql/ExternalMsSqlContext.cs | 16 + .../Context/MsSql/OmbiMsSqlContext.cs | 16 + .../Context/MsSql/SettingsMsSqlContext.cs | 16 + src/Ombi.Store/Migration.md | 17 + .../20241022000032_Initial.Designer.cs | 635 ++++++++ .../ExternalMsSql/20241022000032_Initial.cs | 434 ++++++ .../ExternalMsSqlContextModelSnapshot.cs | 632 ++++++++ .../20241021235959_Initial.Designer.cs | 1362 +++++++++++++++++ .../OmbiMsSql/20241021235959_Initial.cs | 938 ++++++++++++ .../OmbiMsSqlContextModelSnapshot.cs | 1359 ++++++++++++++++ .../20241022000052_Initial.Designer.cs | 67 + .../SettingsMsSql/20241022000052_Initial.cs | 52 + .../SettingsMsSqlContextModelSnapshot.cs | 64 + src/Ombi.Store/Ombi.Store.csproj | 1 + src/Ombi/Extensions/DatabaseExtensions.cs | 44 +- src/Ombi/Ombi.csproj | 1 + 16 files changed, 5652 insertions(+), 2 deletions(-) create mode 100644 src/Ombi.Store/Context/MsSql/ExternalMsSqlContext.cs create mode 100644 src/Ombi.Store/Context/MsSql/OmbiMsSqlContext.cs create mode 100644 src/Ombi.Store/Context/MsSql/SettingsMsSqlContext.cs create mode 100644 src/Ombi.Store/Migrations/ExternalMsSql/20241022000032_Initial.Designer.cs create mode 100644 src/Ombi.Store/Migrations/ExternalMsSql/20241022000032_Initial.cs create mode 100644 src/Ombi.Store/Migrations/ExternalMsSql/ExternalMsSqlContextModelSnapshot.cs create mode 100644 src/Ombi.Store/Migrations/OmbiMsSql/20241021235959_Initial.Designer.cs create mode 100644 src/Ombi.Store/Migrations/OmbiMsSql/20241021235959_Initial.cs create mode 100644 src/Ombi.Store/Migrations/OmbiMsSql/OmbiMsSqlContextModelSnapshot.cs create mode 100644 src/Ombi.Store/Migrations/SettingsMsSql/20241022000052_Initial.Designer.cs create mode 100644 src/Ombi.Store/Migrations/SettingsMsSql/20241022000052_Initial.cs create mode 100644 src/Ombi.Store/Migrations/SettingsMsSql/SettingsMsSqlContextModelSnapshot.cs diff --git a/src/Ombi.Store/Context/MsSql/ExternalMsSqlContext.cs b/src/Ombi.Store/Context/MsSql/ExternalMsSqlContext.cs new file mode 100644 index 000000000..1c110cd93 --- /dev/null +++ b/src/Ombi.Store/Context/MsSql/ExternalMsSqlContext.cs @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore; + +namespace Ombi.Store.Context.MsSql; + +public sealed class ExternalMsSqlContext : ExternalContext +{ + private static bool _created; + + public ExternalMsSqlContext(DbContextOptions options) : base(options) + { + if (_created) return; + + _created = true; + Database.Migrate(); + } +} \ No newline at end of file diff --git a/src/Ombi.Store/Context/MsSql/OmbiMsSqlContext.cs b/src/Ombi.Store/Context/MsSql/OmbiMsSqlContext.cs new file mode 100644 index 000000000..ec765bbf5 --- /dev/null +++ b/src/Ombi.Store/Context/MsSql/OmbiMsSqlContext.cs @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore; + +namespace Ombi.Store.Context.MsSql; + +public sealed class OmbiMsSqlContext : OmbiContext +{ + private static bool _created; + + public OmbiMsSqlContext(DbContextOptions options) : base(options) + { + if (_created) return; + _created = true; + + Database.Migrate(); + } +} \ No newline at end of file diff --git a/src/Ombi.Store/Context/MsSql/SettingsMsSqlContext.cs b/src/Ombi.Store/Context/MsSql/SettingsMsSqlContext.cs new file mode 100644 index 000000000..d9e4763b2 --- /dev/null +++ b/src/Ombi.Store/Context/MsSql/SettingsMsSqlContext.cs @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore; + +namespace Ombi.Store.Context.MsSql; + +public sealed class SettingsMsSqlContext : SettingsContext +{ + private static bool _created; + + public SettingsMsSqlContext(DbContextOptions options) : base(options) + { + if (_created) return; + + _created = true; + Database.Migrate(); + } +} \ No newline at end of file diff --git a/src/Ombi.Store/Migration.md b/src/Ombi.Store/Migration.md index ca8e65180..c8f3d8da5 100644 --- a/src/Ombi.Store/Migration.md +++ b/src/Ombi.Store/Migration.md @@ -54,6 +54,23 @@ If running migrations for any db provider other than Sqlite, then ensure the dat } ``` +### MSSQL Example +``` +{ + "OmbiDatabase": { + "Type": "MSSQL", + "ConnectionString": "Server=localhost;Database=ombi;User Id=ombi;Password=ombi;TrustServerCertificate=True" + }, + "SettingsDatabase": { + "Type": "MSSQL", + "ConnectionString": "Server=localhost;Database=ombi;User Id=ombi;Password=ombi;TrustServerCertificate=True" + }, + "ExternalDatabase": { + "Type": "MSSQL", + "ConnectionString": "Server=localhost;Database=ombi;User Id=ombi;Password=ombi;TrustServerCertificate=True" + } +} +``` ### Postgres Example ``` diff --git a/src/Ombi.Store/Migrations/ExternalMsSql/20241022000032_Initial.Designer.cs b/src/Ombi.Store/Migrations/ExternalMsSql/20241022000032_Initial.Designer.cs new file mode 100644 index 000000000..0decb5c54 --- /dev/null +++ b/src/Ombi.Store/Migrations/ExternalMsSql/20241022000032_Initial.Designer.cs @@ -0,0 +1,635 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.MsSql; + +#nullable disable + +namespace Ombi.Store.Migrations.ExternalMsSql +{ + [DbContext(typeof(ExternalMsSqlContext))] + [Migration("20241022000032_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("CouchPotatoCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("EmbyId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Has4K") + .HasColumnType("bit"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("Quality") + .HasColumnType("nvarchar(max)"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("EmbyContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("EmbyId") + .HasColumnType("nvarchar(max)"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("EmbyEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("Has4K") + .HasColumnType("bit"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("JellyfinId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("Quality") + .HasColumnType("nvarchar(max)"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("JellyfinContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("JellyfinId") + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("JellyfinEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("ArtistId") + .HasColumnType("int"); + + b.Property("ForeignAlbumId") + .HasColumnType("nvarchar(max)"); + + b.Property("Monitored") + .HasColumnType("bit"); + + b.Property("PercentOfTracks") + .HasColumnType("decimal(18,2)"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("LidarrAlbumCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ArtistId") + .HasColumnType("int"); + + b.Property("ArtistName") + .HasColumnType("nvarchar(max)"); + + b.Property("ForeignArtistId") + .HasColumnType("nvarchar(max)"); + + b.Property("Monitored") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.ToTable("LidarrArtistCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("GrandparentKey") + .HasColumnType("nvarchar(450)"); + + b.Property("Key") + .HasColumnType("nvarchar(max)"); + + b.Property("ParentKey") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("GrandparentKey"); + + b.ToTable("PlexEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ParentKey") + .HasColumnType("nvarchar(max)"); + + b.Property("PlexContentId") + .HasColumnType("nvarchar(max)"); + + b.Property("PlexServerContentId") + .HasColumnType("int"); + + b.Property("SeasonKey") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PlexServerContentId"); + + b.ToTable("PlexSeasonsContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("Has4K") + .HasColumnType("bit"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Key") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Quality") + .HasColumnType("nvarchar(max)"); + + b.Property("ReleaseYear") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("PlexServerContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexWatchlistHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("TmdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("PlexWatchlistHistory"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Has4K") + .HasColumnType("bit"); + + b.Property("HasFile") + .HasColumnType("bit"); + + b.Property("HasRegular") + .HasColumnType("bit"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RadarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SickRageCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SickRageEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SonarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("HasFile") + .HasColumnType("bit"); + + b.Property("MovieDbId") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SonarrEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserPlayedEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("UserPlayedEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserPlayedMovie", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("UserPlayedMovie"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.HasOne("Ombi.Store.Entities.EmbyContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("EmbyId"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinEpisode", b => + { + b.HasOne("Ombi.Store.Entities.JellyfinContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("JellyfinId"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent", "Series") + .WithMany("Episodes") + .HasForeignKey("GrandparentKey") + .HasPrincipalKey("Key"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent", null) + .WithMany("Seasons") + .HasForeignKey("PlexServerContentId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Navigation("Episodes"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinContent", b => + { + b.Navigation("Episodes"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b => + { + b.Navigation("Episodes"); + + b.Navigation("Seasons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/ExternalMsSql/20241022000032_Initial.cs b/src/Ombi.Store/Migrations/ExternalMsSql/20241022000032_Initial.cs new file mode 100644 index 000000000..e288ac119 --- /dev/null +++ b/src/Ombi.Store/Migrations/ExternalMsSql/20241022000032_Initial.cs @@ -0,0 +1,434 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Ombi.Store.Migrations.ExternalMsSql +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "CouchPotatoCache", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TheMovieDbId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CouchPotatoCache", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "EmbyContent", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProviderId = table.Column(type: "nvarchar(max)", nullable: true), + EmbyId = table.Column(type: "nvarchar(450)", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: true), + ImdbId = table.Column(type: "nvarchar(max)", nullable: true), + TvDbId = table.Column(type: "nvarchar(max)", nullable: true), + TheMovieDbId = table.Column(type: "nvarchar(max)", nullable: true), + Type = table.Column(type: "int", nullable: false), + Quality = table.Column(type: "nvarchar(max)", nullable: true), + Has4K = table.Column(type: "bit", nullable: false), + Url = table.Column(type: "nvarchar(max)", nullable: true), + AddedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EmbyContent", x => x.Id); + table.UniqueConstraint("AK_EmbyContent_EmbyId", x => x.EmbyId); + }); + + migrationBuilder.CreateTable( + name: "JellyfinContent", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProviderId = table.Column(type: "nvarchar(max)", nullable: true), + JellyfinId = table.Column(type: "nvarchar(450)", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: true), + ImdbId = table.Column(type: "nvarchar(max)", nullable: true), + TvDbId = table.Column(type: "nvarchar(max)", nullable: true), + TheMovieDbId = table.Column(type: "nvarchar(max)", nullable: true), + Type = table.Column(type: "int", nullable: false), + Quality = table.Column(type: "nvarchar(max)", nullable: true), + Has4K = table.Column(type: "bit", nullable: false), + Url = table.Column(type: "nvarchar(max)", nullable: true), + AddedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_JellyfinContent", x => x.Id); + table.UniqueConstraint("AK_JellyfinContent_JellyfinId", x => x.JellyfinId); + }); + + migrationBuilder.CreateTable( + name: "LidarrAlbumCache", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ArtistId = table.Column(type: "int", nullable: false), + ForeignAlbumId = table.Column(type: "nvarchar(max)", nullable: true), + TrackCount = table.Column(type: "int", nullable: false), + ReleaseDate = table.Column(type: "datetime2", nullable: false), + Monitored = table.Column(type: "bit", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: true), + PercentOfTracks = table.Column(type: "decimal(18,2)", nullable: false), + AddedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_LidarrAlbumCache", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "LidarrArtistCache", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ArtistId = table.Column(type: "int", nullable: false), + ArtistName = table.Column(type: "nvarchar(max)", nullable: true), + ForeignArtistId = table.Column(type: "nvarchar(max)", nullable: true), + Monitored = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_LidarrArtistCache", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "PlexServerContent", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ReleaseYear = table.Column(type: "nvarchar(max)", nullable: true), + Key = table.Column(type: "nvarchar(450)", nullable: false), + RequestId = table.Column(type: "int", nullable: true), + Title = table.Column(type: "nvarchar(max)", nullable: true), + ImdbId = table.Column(type: "nvarchar(max)", nullable: true), + TvDbId = table.Column(type: "nvarchar(max)", nullable: true), + TheMovieDbId = table.Column(type: "nvarchar(max)", nullable: true), + Type = table.Column(type: "int", nullable: false), + Quality = table.Column(type: "nvarchar(max)", nullable: true), + Has4K = table.Column(type: "bit", nullable: false), + Url = table.Column(type: "nvarchar(max)", nullable: true), + AddedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PlexServerContent", x => x.Id); + table.UniqueConstraint("AK_PlexServerContent_Key", x => x.Key); + }); + + migrationBuilder.CreateTable( + name: "PlexWatchlistHistory", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TmdbId = table.Column(type: "nvarchar(max)", nullable: true), + UserId = table.Column(type: "nvarchar(max)", nullable: true), + AddedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PlexWatchlistHistory", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "RadarrCache", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TheMovieDbId = table.Column(type: "int", nullable: false), + HasFile = table.Column(type: "bit", nullable: false), + Has4K = table.Column(type: "bit", nullable: false), + HasRegular = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RadarrCache", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "SickRageCache", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TvDbId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SickRageCache", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "SickRageEpisodeCache", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SeasonNumber = table.Column(type: "int", nullable: false), + EpisodeNumber = table.Column(type: "int", nullable: false), + TvDbId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SickRageEpisodeCache", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "SonarrCache", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TvDbId = table.Column(type: "int", nullable: false), + TheMovieDbId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SonarrCache", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "SonarrEpisodeCache", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SeasonNumber = table.Column(type: "int", nullable: false), + EpisodeNumber = table.Column(type: "int", nullable: false), + TvDbId = table.Column(type: "int", nullable: false), + MovieDbId = table.Column(type: "int", nullable: false), + HasFile = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SonarrEpisodeCache", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "UserPlayedEpisode", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TheMovieDbId = table.Column(type: "int", nullable: false), + SeasonNumber = table.Column(type: "int", nullable: false), + EpisodeNumber = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserPlayedEpisode", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "UserPlayedMovie", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TheMovieDbId = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserPlayedMovie", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "EmbyEpisode", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + EmbyId = table.Column(type: "nvarchar(max)", nullable: true), + ParentId = table.Column(type: "nvarchar(450)", nullable: true), + ProviderId = table.Column(type: "nvarchar(max)", nullable: true), + AddedAt = table.Column(type: "datetime2", nullable: false), + TvDbId = table.Column(type: "nvarchar(max)", nullable: true), + ImdbId = table.Column(type: "nvarchar(max)", nullable: true), + TheMovieDbId = table.Column(type: "nvarchar(max)", nullable: true), + EpisodeNumber = table.Column(type: "int", nullable: false), + SeasonNumber = table.Column(type: "int", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_EmbyEpisode", x => x.Id); + table.ForeignKey( + name: "FK_EmbyEpisode_EmbyContent_ParentId", + column: x => x.ParentId, + principalTable: "EmbyContent", + principalColumn: "EmbyId"); + }); + + migrationBuilder.CreateTable( + name: "JellyfinEpisode", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + JellyfinId = table.Column(type: "nvarchar(max)", nullable: true), + ParentId = table.Column(type: "nvarchar(450)", nullable: true), + ProviderId = table.Column(type: "nvarchar(max)", nullable: true), + AddedAt = table.Column(type: "datetime2", nullable: false), + TvDbId = table.Column(type: "nvarchar(max)", nullable: true), + ImdbId = table.Column(type: "nvarchar(max)", nullable: true), + TheMovieDbId = table.Column(type: "nvarchar(max)", nullable: true), + EpisodeNumber = table.Column(type: "int", nullable: false), + SeasonNumber = table.Column(type: "int", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_JellyfinEpisode", x => x.Id); + table.ForeignKey( + name: "FK_JellyfinEpisode_JellyfinContent_ParentId", + column: x => x.ParentId, + principalTable: "JellyfinContent", + principalColumn: "JellyfinId"); + }); + + migrationBuilder.CreateTable( + name: "PlexEpisode", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Key = table.Column(type: "nvarchar(max)", nullable: true), + ParentKey = table.Column(type: "nvarchar(max)", nullable: true), + GrandparentKey = table.Column(type: "nvarchar(450)", nullable: true), + EpisodeNumber = table.Column(type: "int", nullable: false), + SeasonNumber = table.Column(type: "int", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PlexEpisode", x => x.Id); + table.ForeignKey( + name: "FK_PlexEpisode_PlexServerContent_GrandparentKey", + column: x => x.GrandparentKey, + principalTable: "PlexServerContent", + principalColumn: "Key"); + }); + + migrationBuilder.CreateTable( + name: "PlexSeasonsContent", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PlexContentId = table.Column(type: "nvarchar(max)", nullable: true), + SeasonNumber = table.Column(type: "int", nullable: false), + SeasonKey = table.Column(type: "nvarchar(max)", nullable: true), + ParentKey = table.Column(type: "nvarchar(max)", nullable: true), + PlexServerContentId = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PlexSeasonsContent", x => x.Id); + table.ForeignKey( + name: "FK_PlexSeasonsContent_PlexServerContent_PlexServerContentId", + column: x => x.PlexServerContentId, + principalTable: "PlexServerContent", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_EmbyEpisode_ParentId", + table: "EmbyEpisode", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_JellyfinEpisode_ParentId", + table: "JellyfinEpisode", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_PlexEpisode_GrandparentKey", + table: "PlexEpisode", + column: "GrandparentKey"); + + migrationBuilder.CreateIndex( + name: "IX_PlexSeasonsContent_PlexServerContentId", + table: "PlexSeasonsContent", + column: "PlexServerContentId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CouchPotatoCache"); + + migrationBuilder.DropTable( + name: "EmbyEpisode"); + + migrationBuilder.DropTable( + name: "JellyfinEpisode"); + + migrationBuilder.DropTable( + name: "LidarrAlbumCache"); + + migrationBuilder.DropTable( + name: "LidarrArtistCache"); + + migrationBuilder.DropTable( + name: "PlexEpisode"); + + migrationBuilder.DropTable( + name: "PlexSeasonsContent"); + + migrationBuilder.DropTable( + name: "PlexWatchlistHistory"); + + migrationBuilder.DropTable( + name: "RadarrCache"); + + migrationBuilder.DropTable( + name: "SickRageCache"); + + migrationBuilder.DropTable( + name: "SickRageEpisodeCache"); + + migrationBuilder.DropTable( + name: "SonarrCache"); + + migrationBuilder.DropTable( + name: "SonarrEpisodeCache"); + + migrationBuilder.DropTable( + name: "UserPlayedEpisode"); + + migrationBuilder.DropTable( + name: "UserPlayedMovie"); + + migrationBuilder.DropTable( + name: "EmbyContent"); + + migrationBuilder.DropTable( + name: "JellyfinContent"); + + migrationBuilder.DropTable( + name: "PlexServerContent"); + } + } +} diff --git a/src/Ombi.Store/Migrations/ExternalMsSql/ExternalMsSqlContextModelSnapshot.cs b/src/Ombi.Store/Migrations/ExternalMsSql/ExternalMsSqlContextModelSnapshot.cs new file mode 100644 index 000000000..5a649f035 --- /dev/null +++ b/src/Ombi.Store/Migrations/ExternalMsSql/ExternalMsSqlContextModelSnapshot.cs @@ -0,0 +1,632 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.MsSql; + +#nullable disable + +namespace Ombi.Store.Migrations.ExternalMsSql +{ + [DbContext(typeof(ExternalMsSqlContext))] + partial class ExternalMsSqlContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("CouchPotatoCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("EmbyId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Has4K") + .HasColumnType("bit"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("Quality") + .HasColumnType("nvarchar(max)"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("EmbyContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("EmbyId") + .HasColumnType("nvarchar(max)"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("EmbyEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("Has4K") + .HasColumnType("bit"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("JellyfinId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("Quality") + .HasColumnType("nvarchar(max)"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("JellyfinContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("JellyfinId") + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("JellyfinEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("ArtistId") + .HasColumnType("int"); + + b.Property("ForeignAlbumId") + .HasColumnType("nvarchar(max)"); + + b.Property("Monitored") + .HasColumnType("bit"); + + b.Property("PercentOfTracks") + .HasColumnType("decimal(18,2)"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("LidarrAlbumCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ArtistId") + .HasColumnType("int"); + + b.Property("ArtistName") + .HasColumnType("nvarchar(max)"); + + b.Property("ForeignArtistId") + .HasColumnType("nvarchar(max)"); + + b.Property("Monitored") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.ToTable("LidarrArtistCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("GrandparentKey") + .HasColumnType("nvarchar(450)"); + + b.Property("Key") + .HasColumnType("nvarchar(max)"); + + b.Property("ParentKey") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("GrandparentKey"); + + b.ToTable("PlexEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ParentKey") + .HasColumnType("nvarchar(max)"); + + b.Property("PlexContentId") + .HasColumnType("nvarchar(max)"); + + b.Property("PlexServerContentId") + .HasColumnType("int"); + + b.Property("SeasonKey") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PlexServerContentId"); + + b.ToTable("PlexSeasonsContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("Has4K") + .HasColumnType("bit"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Key") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Quality") + .HasColumnType("nvarchar(max)"); + + b.Property("ReleaseYear") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TvDbId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("PlexServerContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexWatchlistHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("TmdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("PlexWatchlistHistory"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Has4K") + .HasColumnType("bit"); + + b.Property("HasFile") + .HasColumnType("bit"); + + b.Property("HasRegular") + .HasColumnType("bit"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RadarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SickRageCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SickRageEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SonarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("HasFile") + .HasColumnType("bit"); + + b.Property("MovieDbId") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SonarrEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserPlayedEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("UserPlayedEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserPlayedMovie", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("UserPlayedMovie"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.HasOne("Ombi.Store.Entities.EmbyContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("EmbyId"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinEpisode", b => + { + b.HasOne("Ombi.Store.Entities.JellyfinContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("JellyfinId"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent", "Series") + .WithMany("Episodes") + .HasForeignKey("GrandparentKey") + .HasPrincipalKey("Key"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent", null) + .WithMany("Seasons") + .HasForeignKey("PlexServerContentId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Navigation("Episodes"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinContent", b => + { + b.Navigation("Episodes"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b => + { + b.Navigation("Episodes"); + + b.Navigation("Seasons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiMsSql/20241021235959_Initial.Designer.cs b/src/Ombi.Store/Migrations/OmbiMsSql/20241021235959_Initial.Designer.cs new file mode 100644 index 000000000..c11bb1485 --- /dev/null +++ b/src/Ombi.Store/Migrations/OmbiMsSql/20241021235959_Initial.Designer.cs @@ -0,0 +1,1362 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.MsSql; + +#nullable disable + +namespace Ombi.Store.Migrations.OmbiMsSql +{ + [DbContext(typeof(OmbiMsSqlContext))] + [Migration("20241021235959_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Audit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AuditArea") + .HasColumnType("int"); + + b.Property("AuditType") + .HasColumnType("int"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("User") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Audit"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.MobileDevices", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("Token") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("MobileDevices"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationTemplates", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Agent") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("NotificationType") + .HasColumnType("int"); + + b.Property("Subject") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("NotificationTemplates"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("PlayerId") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("Alias") + .HasColumnType("nvarchar(max)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("EpisodeRequestLimit") + .HasColumnType("int"); + + b.Property("EpisodeRequestLimitType") + .HasColumnType("int"); + + b.Property("Language") + .HasColumnType("nvarchar(max)"); + + b.Property("LastLoggedIn") + .HasColumnType("datetime2"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("MediaServerToken") + .HasColumnType("nvarchar(max)"); + + b.Property("MovieRequestLimit") + .HasColumnType("int"); + + b.Property("MovieRequestLimitType") + .HasColumnType("int"); + + b.Property("MusicRequestLimit") + .HasColumnType("int"); + + b.Property("MusicRequestLimitType") + .HasColumnType("int"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProviderUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("StreamingCountry") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserAccessToken") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("UserType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexWatchlistUserError", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MediaServerToken") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("PlexWatchlistUserError"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RecentlyAddedLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("AlbumId") + .HasColumnType("nvarchar(max)"); + + b.Property("ContentId") + .HasColumnType("int"); + + b.Property("ContentType") + .HasColumnType("int"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RecentlyAddedLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestQueue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("Dts") + .HasColumnType("datetime2"); + + b.Property("Error") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RetryCount") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RequestQueue"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestSubscription"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Approved") + .HasColumnType("bit"); + + b.Property("ArtistName") + .HasColumnType("nvarchar(max)"); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Cover") + .HasColumnType("nvarchar(max)"); + + b.Property("Denied") + .HasColumnType("bit"); + + b.Property("DeniedReason") + .HasColumnType("nvarchar(max)"); + + b.Property("Disk") + .HasColumnType("nvarchar(max)"); + + b.Property("ForeignAlbumId") + .HasColumnType("nvarchar(max)"); + + b.Property("ForeignArtistId") + .HasColumnType("nvarchar(max)"); + + b.Property("MarkedAsApproved") + .HasColumnType("datetime2"); + + b.Property("MarkedAsAvailable") + .HasColumnType("datetime2"); + + b.Property("MarkedAsDenied") + .HasColumnType("datetime2"); + + b.Property("Rating") + .HasColumnType("decimal(18,2)"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("RequestedByAlias") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestedDate") + .HasColumnType("datetime2"); + + b.Property("RequestedUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("AlbumRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Approved") + .HasColumnType("bit"); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Denied") + .HasColumnType("bit"); + + b.Property("DeniedReason") + .HasColumnType("nvarchar(max)"); + + b.Property("IssueId") + .HasColumnType("int"); + + b.Property("MarkedAsApproved") + .HasColumnType("datetime2"); + + b.Property("MarkedAsAvailable") + .HasColumnType("datetime2"); + + b.Property("MarkedAsDenied") + .HasColumnType("datetime2"); + + b.Property("ParentRequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("RequestedByAlias") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestedDate") + .HasColumnType("datetime2"); + + b.Property("RequestedUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("SeriesType") + .HasColumnType("int"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentRequestId"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("IssueCategory"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Comment") + .HasColumnType("nvarchar(max)"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("IssuesId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("IssuesId"); + + b.HasIndex("UserId"); + + b.ToTable("IssueComments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IssueCategoryId") + .HasColumnType("int"); + + b.Property("IssueId") + .HasColumnType("int"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("ResovledDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Subject") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UserReportedId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("IssueCategoryId"); + + b.HasIndex("IssueId"); + + b.HasIndex("UserReportedId"); + + b.ToTable("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Approved") + .HasColumnType("bit"); + + b.Property("Approved4K") + .HasColumnType("bit"); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Available4K") + .HasColumnType("bit"); + + b.Property("Background") + .HasColumnType("nvarchar(max)"); + + b.Property("Denied") + .HasColumnType("bit"); + + b.Property("Denied4K") + .HasColumnType("bit"); + + b.Property("DeniedReason") + .HasColumnType("nvarchar(max)"); + + b.Property("DeniedReason4K") + .HasColumnType("nvarchar(max)"); + + b.Property("DigitalReleaseDate") + .HasColumnType("datetime2"); + + b.Property("Has4KRequest") + .HasColumnType("bit"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("IssueId") + .HasColumnType("int"); + + b.Property("LangCode") + .HasColumnType("nvarchar(max)"); + + b.Property("MarkedAsApproved") + .HasColumnType("datetime2"); + + b.Property("MarkedAsApproved4K") + .HasColumnType("datetime2"); + + b.Property("MarkedAsAvailable") + .HasColumnType("datetime2"); + + b.Property("MarkedAsAvailable4K") + .HasColumnType("datetime2"); + + b.Property("MarkedAsDenied") + .HasColumnType("datetime2"); + + b.Property("MarkedAsDenied4K") + .HasColumnType("datetime2"); + + b.Property("Overview") + .HasColumnType("nvarchar(max)"); + + b.Property("PosterPath") + .HasColumnType("nvarchar(max)"); + + b.Property("QualityOverride") + .HasColumnType("int"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("RequestedByAlias") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestedDate") + .HasColumnType("datetime2"); + + b.Property("RequestedDate4k") + .HasColumnType("datetime2"); + + b.Property("RequestedUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RootPathOverride") + .HasColumnType("int"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("MovieRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeCount") + .HasColumnType("int"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Background") + .HasColumnType("nvarchar(max)"); + + b.Property("ExternalProviderId") + .HasColumnType("int"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("LanguageProfile") + .HasColumnType("int"); + + b.Property("Overview") + .HasColumnType("nvarchar(max)"); + + b.Property("PosterPath") + .HasColumnType("nvarchar(max)"); + + b.Property("QualityOverride") + .HasColumnType("int"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("RootFolder") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalSeasons") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("TvRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Token") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Agent") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Radarr4KQualityProfile") + .HasColumnType("int"); + + b.Property("Radarr4KRootPath") + .HasColumnType("int"); + + b.Property("RadarrQualityProfile") + .HasColumnType("int"); + + b.Property("RadarrRootPath") + .HasColumnType("int"); + + b.Property("SonarrQualityProfile") + .HasColumnType("int"); + + b.Property("SonarrQualityProfileAnime") + .HasColumnType("int"); + + b.Property("SonarrRootPath") + .HasColumnType("int"); + + b.Property("SonarrRootPathAnime") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserQualityProfiles"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("VoteType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Votes"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AirDate") + .HasColumnType("datetime2"); + + b.Property("Approved") + .HasColumnType("bit"); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("Requested") + .HasColumnType("bit"); + + b.Property("SeasonId") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("SeasonId"); + + b.ToTable("EpisodeRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChildRequestId") + .HasColumnType("int"); + + b.Property("Overview") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChildRequestId"); + + b.ToTable("SeasonRequests"); + }); + + 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("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", 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("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Ombi.Store.Entities.MobileDevices", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("NotificationUserIds") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.TvRequests", "ParentRequest") + .WithMany("ChildRequests") + .HasForeignKey("ParentRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("ParentRequest"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.HasOne("Ombi.Store.Entities.Requests.Issues", "Issues") + .WithMany("Comments") + .HasForeignKey("IssuesId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Issues"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.HasOne("Ombi.Store.Entities.Requests.IssueCategory", "IssueCategory") + .WithMany() + .HasForeignKey("IssueCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", null) + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.Requests.MovieRequests", null) + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "UserReported") + .WithMany() + .HasForeignKey("UserReportedId"); + + b.Navigation("IssueCategory"); + + b.Navigation("UserReported"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("UserNotificationPreferences") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season") + .WithMany("Episodes") + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", "ChildRequest") + .WithMany("SeasonRequests") + .HasForeignKey("ChildRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildRequest"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Navigation("NotificationUserIds"); + + b.Navigation("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Navigation("Issues"); + + b.Navigation("SeasonRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Navigation("Comments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Navigation("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Navigation("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Navigation("Episodes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiMsSql/20241021235959_Initial.cs b/src/Ombi.Store/Migrations/OmbiMsSql/20241021235959_Initial.cs new file mode 100644 index 000000000..3ad91e7ae --- /dev/null +++ b/src/Ombi.Store/Migrations/OmbiMsSql/20241021235959_Initial.cs @@ -0,0 +1,938 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Ombi.Store.Migrations.OmbiMsSql +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AspNetRoles", + columns: table => new + { + Id = table.Column(type: "nvarchar(450)", nullable: false), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetUsers", + columns: table => new + { + Id = table.Column(type: "nvarchar(450)", nullable: false), + Alias = table.Column(type: "nvarchar(max)", nullable: true), + UserType = table.Column(type: "int", nullable: false), + ProviderUserId = table.Column(type: "nvarchar(max)", nullable: true), + LastLoggedIn = table.Column(type: "datetime2", nullable: true), + Language = table.Column(type: "nvarchar(max)", nullable: true), + StreamingCountry = table.Column(type: "nvarchar(max)", nullable: false), + MovieRequestLimit = table.Column(type: "int", nullable: true), + EpisodeRequestLimit = table.Column(type: "int", nullable: true), + MusicRequestLimit = table.Column(type: "int", nullable: true), + MovieRequestLimitType = table.Column(type: "int", nullable: true), + EpisodeRequestLimitType = table.Column(type: "int", nullable: true), + MusicRequestLimitType = table.Column(type: "int", nullable: true), + UserAccessToken = table.Column(type: "nvarchar(max)", nullable: true), + MediaServerToken = table.Column(type: "nvarchar(max)", nullable: true), + PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), + SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "bit", nullable: false), + PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false), + TwoFactorEnabled = table.Column(type: "bit", nullable: false), + LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), + LockoutEnabled = table.Column(type: "bit", nullable: false), + AccessFailedCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Audit", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DateTime = table.Column(type: "datetime2", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: true), + AuditType = table.Column(type: "int", nullable: false), + AuditArea = table.Column(type: "int", nullable: false), + User = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Audit", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IssueCategory", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Value = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IssueCategory", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "NotificationTemplates", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + NotificationType = table.Column(type: "int", nullable: false), + Agent = table.Column(type: "int", nullable: false), + Subject = table.Column(type: "nvarchar(max)", nullable: true), + Message = table.Column(type: "nvarchar(max)", nullable: true), + Enabled = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_NotificationTemplates", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "PlexWatchlistUserError", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(max)", nullable: true), + MediaServerToken = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PlexWatchlistUserError", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "RecentlyAddedLog", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Type = table.Column(type: "int", nullable: false), + ContentType = table.Column(type: "int", nullable: false), + ContentId = table.Column(type: "int", nullable: false), + EpisodeNumber = table.Column(type: "int", nullable: true), + SeasonNumber = table.Column(type: "int", nullable: true), + AlbumId = table.Column(type: "nvarchar(max)", nullable: true), + AddedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RecentlyAddedLog", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "RequestQueue", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RequestId = table.Column(type: "int", nullable: false), + Type = table.Column(type: "int", nullable: false), + Dts = table.Column(type: "datetime2", nullable: false), + Error = table.Column(type: "nvarchar(max)", nullable: true), + Completed = table.Column(type: "datetime2", nullable: true), + RetryCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RequestQueue", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TvRequests", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TvDbId = table.Column(type: "int", nullable: false), + ExternalProviderId = table.Column(type: "int", nullable: false), + ImdbId = table.Column(type: "nvarchar(max)", nullable: true), + QualityOverride = table.Column(type: "int", nullable: true), + RootFolder = table.Column(type: "int", nullable: true), + LanguageProfile = table.Column(type: "int", nullable: true), + Overview = table.Column(type: "nvarchar(max)", nullable: true), + Title = table.Column(type: "nvarchar(max)", nullable: true), + PosterPath = table.Column(type: "nvarchar(max)", nullable: true), + Background = table.Column(type: "nvarchar(max)", nullable: true), + ReleaseDate = table.Column(type: "datetime2", nullable: false), + Status = table.Column(type: "nvarchar(max)", nullable: true), + TotalSeasons = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TvRequests", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetRoleClaims", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoleId = table.Column(type: "nvarchar(450)", nullable: false), + ClaimType = table.Column(type: "nvarchar(max)", nullable: true), + ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AlbumRequests", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ForeignAlbumId = table.Column(type: "nvarchar(max)", nullable: true), + ForeignArtistId = table.Column(type: "nvarchar(max)", nullable: true), + Disk = table.Column(type: "nvarchar(max)", nullable: true), + Cover = table.Column(type: "nvarchar(max)", nullable: true), + Rating = table.Column(type: "decimal(18,2)", nullable: false), + ReleaseDate = table.Column(type: "datetime2", nullable: false), + ArtistName = table.Column(type: "nvarchar(max)", nullable: true), + Title = table.Column(type: "nvarchar(max)", nullable: true), + Approved = table.Column(type: "bit", nullable: false), + MarkedAsApproved = table.Column(type: "datetime2", nullable: false), + RequestedDate = table.Column(type: "datetime2", nullable: false), + Available = table.Column(type: "bit", nullable: false), + MarkedAsAvailable = table.Column(type: "datetime2", nullable: true), + RequestedUserId = table.Column(type: "nvarchar(450)", nullable: true), + Denied = table.Column(type: "bit", nullable: true), + MarkedAsDenied = table.Column(type: "datetime2", nullable: false), + DeniedReason = table.Column(type: "nvarchar(max)", nullable: true), + RequestType = table.Column(type: "int", nullable: false), + RequestedByAlias = table.Column(type: "nvarchar(max)", nullable: true), + Source = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AlbumRequests", x => x.Id); + table.ForeignKey( + name: "FK_AlbumRequests_AspNetUsers_RequestedUserId", + column: x => x.RequestedUserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserClaims", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(450)", nullable: false), + ClaimType = table.Column(type: "nvarchar(max)", nullable: true), + ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetUserClaims_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserLogins", + columns: table => new + { + LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), + ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), + ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), + UserId = table.Column(type: "nvarchar(450)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_AspNetUserLogins_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserRoles", + columns: table => new + { + UserId = table.Column(type: "nvarchar(450)", nullable: false), + RoleId = table.Column(type: "nvarchar(450)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserTokens", + columns: table => new + { + UserId = table.Column(type: "nvarchar(450)", nullable: false), + LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), + Name = table.Column(type: "nvarchar(450)", nullable: false), + Value = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AspNetUserTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MobileDevices", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Token = table.Column(type: "nvarchar(max)", nullable: true), + UserId = table.Column(type: "nvarchar(450)", nullable: true), + AddedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MobileDevices", x => x.Id); + table.ForeignKey( + name: "FK_MobileDevices_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "MovieRequests", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TheMovieDbId = table.Column(type: "int", nullable: false), + IssueId = table.Column(type: "int", nullable: true), + RootPathOverride = table.Column(type: "int", nullable: false), + QualityOverride = table.Column(type: "int", nullable: false), + Has4KRequest = table.Column(type: "bit", nullable: false), + Approved4K = table.Column(type: "bit", nullable: false), + MarkedAsApproved4K = table.Column(type: "datetime2", nullable: false), + RequestedDate4k = table.Column(type: "datetime2", nullable: false), + Available4K = table.Column(type: "bit", nullable: false), + MarkedAsAvailable4K = table.Column(type: "datetime2", nullable: true), + Denied4K = table.Column(type: "bit", nullable: true), + MarkedAsDenied4K = table.Column(type: "datetime2", nullable: false), + DeniedReason4K = table.Column(type: "nvarchar(max)", nullable: true), + LangCode = table.Column(type: "nvarchar(max)", nullable: true), + Title = table.Column(type: "nvarchar(max)", nullable: true), + Approved = table.Column(type: "bit", nullable: false), + MarkedAsApproved = table.Column(type: "datetime2", nullable: false), + RequestedDate = table.Column(type: "datetime2", nullable: false), + Available = table.Column(type: "bit", nullable: false), + MarkedAsAvailable = table.Column(type: "datetime2", nullable: true), + RequestedUserId = table.Column(type: "nvarchar(450)", nullable: true), + Denied = table.Column(type: "bit", nullable: true), + MarkedAsDenied = table.Column(type: "datetime2", nullable: false), + DeniedReason = table.Column(type: "nvarchar(max)", nullable: true), + RequestType = table.Column(type: "int", nullable: false), + RequestedByAlias = table.Column(type: "nvarchar(max)", nullable: true), + Source = table.Column(type: "int", nullable: false), + ImdbId = table.Column(type: "nvarchar(max)", nullable: true), + Overview = table.Column(type: "nvarchar(max)", nullable: true), + PosterPath = table.Column(type: "nvarchar(max)", nullable: true), + ReleaseDate = table.Column(type: "datetime2", nullable: false), + DigitalReleaseDate = table.Column(type: "datetime2", nullable: true), + Status = table.Column(type: "nvarchar(max)", nullable: true), + Background = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_MovieRequests", x => x.Id); + table.ForeignKey( + name: "FK_MovieRequests_AspNetUsers_RequestedUserId", + column: x => x.RequestedUserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "NotificationUserId", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PlayerId = table.Column(type: "nvarchar(max)", nullable: true), + UserId = table.Column(type: "nvarchar(450)", nullable: true), + AddedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_NotificationUserId", x => x.Id); + table.ForeignKey( + name: "FK_NotificationUserId_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "RequestLog", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(450)", nullable: true), + RequestType = table.Column(type: "int", nullable: false), + RequestDate = table.Column(type: "datetime2", nullable: false), + RequestId = table.Column(type: "int", nullable: false), + EpisodeCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RequestLog", x => x.Id); + table.ForeignKey( + name: "FK_RequestLog_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "RequestSubscription", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(450)", nullable: true), + RequestId = table.Column(type: "int", nullable: false), + RequestType = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RequestSubscription", x => x.Id); + table.ForeignKey( + name: "FK_RequestSubscription_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Tokens", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Token = table.Column(type: "nvarchar(max)", nullable: true), + UserId = table.Column(type: "nvarchar(450)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tokens", x => x.Id); + table.ForeignKey( + name: "FK_Tokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "UserNotificationPreferences", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(450)", nullable: true), + Agent = table.Column(type: "int", nullable: false), + Enabled = table.Column(type: "bit", nullable: false), + Value = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserNotificationPreferences", x => x.Id); + table.ForeignKey( + name: "FK_UserNotificationPreferences_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "UserQualityProfiles", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(450)", nullable: true), + SonarrQualityProfileAnime = table.Column(type: "int", nullable: false), + SonarrRootPathAnime = table.Column(type: "int", nullable: false), + SonarrRootPath = table.Column(type: "int", nullable: false), + SonarrQualityProfile = table.Column(type: "int", nullable: false), + RadarrRootPath = table.Column(type: "int", nullable: false), + RadarrQualityProfile = table.Column(type: "int", nullable: false), + Radarr4KRootPath = table.Column(type: "int", nullable: false), + Radarr4KQualityProfile = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserQualityProfiles", x => x.Id); + table.ForeignKey( + name: "FK_UserQualityProfiles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Votes", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RequestId = table.Column(type: "int", nullable: false), + VoteType = table.Column(type: "int", nullable: false), + RequestType = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "nvarchar(450)", nullable: true), + Date = table.Column(type: "datetime2", nullable: false), + Deleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Votes", x => x.Id); + table.ForeignKey( + name: "FK_Votes_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "ChildRequests", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ParentRequestId = table.Column(type: "int", nullable: false), + IssueId = table.Column(type: "int", nullable: true), + SeriesType = table.Column(type: "int", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: true), + Approved = table.Column(type: "bit", nullable: false), + MarkedAsApproved = table.Column(type: "datetime2", nullable: false), + RequestedDate = table.Column(type: "datetime2", nullable: false), + Available = table.Column(type: "bit", nullable: false), + MarkedAsAvailable = table.Column(type: "datetime2", nullable: true), + RequestedUserId = table.Column(type: "nvarchar(450)", nullable: true), + Denied = table.Column(type: "bit", nullable: true), + MarkedAsDenied = table.Column(type: "datetime2", nullable: false), + DeniedReason = table.Column(type: "nvarchar(max)", nullable: true), + RequestType = table.Column(type: "int", nullable: false), + RequestedByAlias = table.Column(type: "nvarchar(max)", nullable: true), + Source = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChildRequests", x => x.Id); + table.ForeignKey( + name: "FK_ChildRequests_AspNetUsers_RequestedUserId", + column: x => x.RequestedUserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_ChildRequests_TvRequests_ParentRequestId", + column: x => x.ParentRequestId, + principalTable: "TvRequests", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Issues", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(max)", nullable: true), + RequestType = table.Column(type: "int", nullable: false), + ProviderId = table.Column(type: "nvarchar(max)", nullable: true), + RequestId = table.Column(type: "int", nullable: true), + Subject = table.Column(type: "nvarchar(max)", nullable: true), + Description = table.Column(type: "nvarchar(max)", nullable: true), + IssueCategoryId = table.Column(type: "int", nullable: false), + Status = table.Column(type: "int", nullable: false), + ResovledDate = table.Column(type: "datetime2", nullable: true), + CreatedDate = table.Column(type: "datetime2", nullable: false), + UserReportedId = table.Column(type: "nvarchar(450)", nullable: true), + IssueId = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Issues", x => x.Id); + table.ForeignKey( + name: "FK_Issues_AspNetUsers_UserReportedId", + column: x => x.UserReportedId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Issues_ChildRequests_IssueId", + column: x => x.IssueId, + principalTable: "ChildRequests", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Issues_IssueCategory_IssueCategoryId", + column: x => x.IssueCategoryId, + principalTable: "IssueCategory", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Issues_MovieRequests_IssueId", + column: x => x.IssueId, + principalTable: "MovieRequests", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "SeasonRequests", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SeasonNumber = table.Column(type: "int", nullable: false), + Overview = table.Column(type: "nvarchar(max)", nullable: true), + ChildRequestId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SeasonRequests", x => x.Id); + table.ForeignKey( + name: "FK_SeasonRequests_ChildRequests_ChildRequestId", + column: x => x.ChildRequestId, + principalTable: "ChildRequests", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IssueComments", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(450)", nullable: true), + Comment = table.Column(type: "nvarchar(max)", nullable: true), + IssuesId = table.Column(type: "int", nullable: true), + Date = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IssueComments", x => x.Id); + table.ForeignKey( + name: "FK_IssueComments_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_IssueComments_Issues_IssuesId", + column: x => x.IssuesId, + principalTable: "Issues", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "EpisodeRequests", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + EpisodeNumber = table.Column(type: "int", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: true), + AirDate = table.Column(type: "datetime2", nullable: false), + Url = table.Column(type: "nvarchar(max)", nullable: true), + Available = table.Column(type: "bit", nullable: false), + Approved = table.Column(type: "bit", nullable: false), + Requested = table.Column(type: "bit", nullable: false), + SeasonId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EpisodeRequests", x => x.Id); + table.ForeignKey( + name: "FK_EpisodeRequests_SeasonRequests_SeasonId", + column: x => x.SeasonId, + principalTable: "SeasonRequests", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AlbumRequests_RequestedUserId", + table: "AlbumRequests", + column: "RequestedUserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetRoleClaims_RoleId", + table: "AspNetRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "AspNetRoles", + column: "NormalizedName", + unique: true, + filter: "[NormalizedName] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserClaims_UserId", + table: "AspNetUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserLogins_UserId", + table: "AspNetUserLogins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserRoles_RoleId", + table: "AspNetUserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + table: "AspNetUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + table: "AspNetUsers", + column: "NormalizedUserName", + unique: true, + filter: "[NormalizedUserName] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_ChildRequests_ParentRequestId", + table: "ChildRequests", + column: "ParentRequestId"); + + migrationBuilder.CreateIndex( + name: "IX_ChildRequests_RequestedUserId", + table: "ChildRequests", + column: "RequestedUserId"); + + migrationBuilder.CreateIndex( + name: "IX_EpisodeRequests_SeasonId", + table: "EpisodeRequests", + column: "SeasonId"); + + migrationBuilder.CreateIndex( + name: "IX_IssueComments_IssuesId", + table: "IssueComments", + column: "IssuesId"); + + migrationBuilder.CreateIndex( + name: "IX_IssueComments_UserId", + table: "IssueComments", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Issues_IssueCategoryId", + table: "Issues", + column: "IssueCategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_Issues_IssueId", + table: "Issues", + column: "IssueId"); + + migrationBuilder.CreateIndex( + name: "IX_Issues_UserReportedId", + table: "Issues", + column: "UserReportedId"); + + migrationBuilder.CreateIndex( + name: "IX_MobileDevices_UserId", + table: "MobileDevices", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_MovieRequests_RequestedUserId", + table: "MovieRequests", + column: "RequestedUserId"); + + migrationBuilder.CreateIndex( + name: "IX_NotificationUserId_UserId", + table: "NotificationUserId", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_RequestLog_UserId", + table: "RequestLog", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_RequestSubscription_UserId", + table: "RequestSubscription", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_SeasonRequests_ChildRequestId", + table: "SeasonRequests", + column: "ChildRequestId"); + + migrationBuilder.CreateIndex( + name: "IX_Tokens_UserId", + table: "Tokens", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserNotificationPreferences_UserId", + table: "UserNotificationPreferences", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserQualityProfiles_UserId", + table: "UserQualityProfiles", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Votes_UserId", + table: "Votes", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AlbumRequests"); + + migrationBuilder.DropTable( + name: "AspNetRoleClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserLogins"); + + migrationBuilder.DropTable( + name: "AspNetUserRoles"); + + migrationBuilder.DropTable( + name: "AspNetUserTokens"); + + migrationBuilder.DropTable( + name: "Audit"); + + migrationBuilder.DropTable( + name: "EpisodeRequests"); + + migrationBuilder.DropTable( + name: "IssueComments"); + + migrationBuilder.DropTable( + name: "MobileDevices"); + + migrationBuilder.DropTable( + name: "NotificationTemplates"); + + migrationBuilder.DropTable( + name: "NotificationUserId"); + + migrationBuilder.DropTable( + name: "PlexWatchlistUserError"); + + migrationBuilder.DropTable( + name: "RecentlyAddedLog"); + + migrationBuilder.DropTable( + name: "RequestLog"); + + migrationBuilder.DropTable( + name: "RequestQueue"); + + migrationBuilder.DropTable( + name: "RequestSubscription"); + + migrationBuilder.DropTable( + name: "Tokens"); + + migrationBuilder.DropTable( + name: "UserNotificationPreferences"); + + migrationBuilder.DropTable( + name: "UserQualityProfiles"); + + migrationBuilder.DropTable( + name: "Votes"); + + migrationBuilder.DropTable( + name: "AspNetRoles"); + + migrationBuilder.DropTable( + name: "SeasonRequests"); + + migrationBuilder.DropTable( + name: "Issues"); + + migrationBuilder.DropTable( + name: "ChildRequests"); + + migrationBuilder.DropTable( + name: "IssueCategory"); + + migrationBuilder.DropTable( + name: "MovieRequests"); + + migrationBuilder.DropTable( + name: "TvRequests"); + + migrationBuilder.DropTable( + name: "AspNetUsers"); + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiMsSql/OmbiMsSqlContextModelSnapshot.cs b/src/Ombi.Store/Migrations/OmbiMsSql/OmbiMsSqlContextModelSnapshot.cs new file mode 100644 index 000000000..966edda11 --- /dev/null +++ b/src/Ombi.Store/Migrations/OmbiMsSql/OmbiMsSqlContextModelSnapshot.cs @@ -0,0 +1,1359 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.MsSql; + +#nullable disable + +namespace Ombi.Store.Migrations.OmbiMsSql +{ + [DbContext(typeof(OmbiMsSqlContext))] + partial class OmbiMsSqlContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Audit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AuditArea") + .HasColumnType("int"); + + b.Property("AuditType") + .HasColumnType("int"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("User") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Audit"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.MobileDevices", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("Token") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("MobileDevices"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationTemplates", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Agent") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("NotificationType") + .HasColumnType("int"); + + b.Property("Subject") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("NotificationTemplates"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("PlayerId") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("Alias") + .HasColumnType("nvarchar(max)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("EpisodeRequestLimit") + .HasColumnType("int"); + + b.Property("EpisodeRequestLimitType") + .HasColumnType("int"); + + b.Property("Language") + .HasColumnType("nvarchar(max)"); + + b.Property("LastLoggedIn") + .HasColumnType("datetime2"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("MediaServerToken") + .HasColumnType("nvarchar(max)"); + + b.Property("MovieRequestLimit") + .HasColumnType("int"); + + b.Property("MovieRequestLimitType") + .HasColumnType("int"); + + b.Property("MusicRequestLimit") + .HasColumnType("int"); + + b.Property("MusicRequestLimitType") + .HasColumnType("int"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProviderUserId") + .HasColumnType("nvarchar(max)"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("StreamingCountry") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserAccessToken") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("UserType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexWatchlistUserError", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MediaServerToken") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("PlexWatchlistUserError"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RecentlyAddedLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("AlbumId") + .HasColumnType("nvarchar(max)"); + + b.Property("ContentId") + .HasColumnType("int"); + + b.Property("ContentType") + .HasColumnType("int"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RecentlyAddedLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestQueue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("Dts") + .HasColumnType("datetime2"); + + b.Property("Error") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RetryCount") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RequestQueue"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestSubscription"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Approved") + .HasColumnType("bit"); + + b.Property("ArtistName") + .HasColumnType("nvarchar(max)"); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Cover") + .HasColumnType("nvarchar(max)"); + + b.Property("Denied") + .HasColumnType("bit"); + + b.Property("DeniedReason") + .HasColumnType("nvarchar(max)"); + + b.Property("Disk") + .HasColumnType("nvarchar(max)"); + + b.Property("ForeignAlbumId") + .HasColumnType("nvarchar(max)"); + + b.Property("ForeignArtistId") + .HasColumnType("nvarchar(max)"); + + b.Property("MarkedAsApproved") + .HasColumnType("datetime2"); + + b.Property("MarkedAsAvailable") + .HasColumnType("datetime2"); + + b.Property("MarkedAsDenied") + .HasColumnType("datetime2"); + + b.Property("Rating") + .HasColumnType("decimal(18,2)"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("RequestedByAlias") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestedDate") + .HasColumnType("datetime2"); + + b.Property("RequestedUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("AlbumRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Approved") + .HasColumnType("bit"); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Denied") + .HasColumnType("bit"); + + b.Property("DeniedReason") + .HasColumnType("nvarchar(max)"); + + b.Property("IssueId") + .HasColumnType("int"); + + b.Property("MarkedAsApproved") + .HasColumnType("datetime2"); + + b.Property("MarkedAsAvailable") + .HasColumnType("datetime2"); + + b.Property("MarkedAsDenied") + .HasColumnType("datetime2"); + + b.Property("ParentRequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("RequestedByAlias") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestedDate") + .HasColumnType("datetime2"); + + b.Property("RequestedUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("SeriesType") + .HasColumnType("int"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentRequestId"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("IssueCategory"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Comment") + .HasColumnType("nvarchar(max)"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("IssuesId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("IssuesId"); + + b.HasIndex("UserId"); + + b.ToTable("IssueComments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IssueCategoryId") + .HasColumnType("int"); + + b.Property("IssueId") + .HasColumnType("int"); + + b.Property("ProviderId") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("ResovledDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Subject") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UserReportedId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("IssueCategoryId"); + + b.HasIndex("IssueId"); + + b.HasIndex("UserReportedId"); + + b.ToTable("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Approved") + .HasColumnType("bit"); + + b.Property("Approved4K") + .HasColumnType("bit"); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Available4K") + .HasColumnType("bit"); + + b.Property("Background") + .HasColumnType("nvarchar(max)"); + + b.Property("Denied") + .HasColumnType("bit"); + + b.Property("Denied4K") + .HasColumnType("bit"); + + b.Property("DeniedReason") + .HasColumnType("nvarchar(max)"); + + b.Property("DeniedReason4K") + .HasColumnType("nvarchar(max)"); + + b.Property("DigitalReleaseDate") + .HasColumnType("datetime2"); + + b.Property("Has4KRequest") + .HasColumnType("bit"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("IssueId") + .HasColumnType("int"); + + b.Property("LangCode") + .HasColumnType("nvarchar(max)"); + + b.Property("MarkedAsApproved") + .HasColumnType("datetime2"); + + b.Property("MarkedAsApproved4K") + .HasColumnType("datetime2"); + + b.Property("MarkedAsAvailable") + .HasColumnType("datetime2"); + + b.Property("MarkedAsAvailable4K") + .HasColumnType("datetime2"); + + b.Property("MarkedAsDenied") + .HasColumnType("datetime2"); + + b.Property("MarkedAsDenied4K") + .HasColumnType("datetime2"); + + b.Property("Overview") + .HasColumnType("nvarchar(max)"); + + b.Property("PosterPath") + .HasColumnType("nvarchar(max)"); + + b.Property("QualityOverride") + .HasColumnType("int"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("RequestedByAlias") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestedDate") + .HasColumnType("datetime2"); + + b.Property("RequestedDate4k") + .HasColumnType("datetime2"); + + b.Property("RequestedUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RootPathOverride") + .HasColumnType("int"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("MovieRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EpisodeCount") + .HasColumnType("int"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Background") + .HasColumnType("nvarchar(max)"); + + b.Property("ExternalProviderId") + .HasColumnType("int"); + + b.Property("ImdbId") + .HasColumnType("nvarchar(max)"); + + b.Property("LanguageProfile") + .HasColumnType("int"); + + b.Property("Overview") + .HasColumnType("nvarchar(max)"); + + b.Property("PosterPath") + .HasColumnType("nvarchar(max)"); + + b.Property("QualityOverride") + .HasColumnType("int"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("RootFolder") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalSeasons") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("TvRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Token") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Agent") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Radarr4KQualityProfile") + .HasColumnType("int"); + + b.Property("Radarr4KRootPath") + .HasColumnType("int"); + + b.Property("RadarrQualityProfile") + .HasColumnType("int"); + + b.Property("RadarrRootPath") + .HasColumnType("int"); + + b.Property("SonarrQualityProfile") + .HasColumnType("int"); + + b.Property("SonarrQualityProfileAnime") + .HasColumnType("int"); + + b.Property("SonarrRootPath") + .HasColumnType("int"); + + b.Property("SonarrRootPathAnime") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserQualityProfiles"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("VoteType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Votes"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AirDate") + .HasColumnType("datetime2"); + + b.Property("Approved") + .HasColumnType("bit"); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("Requested") + .HasColumnType("bit"); + + b.Property("SeasonId") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("SeasonId"); + + b.ToTable("EpisodeRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChildRequestId") + .HasColumnType("int"); + + b.Property("Overview") + .HasColumnType("nvarchar(max)"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChildRequestId"); + + b.ToTable("SeasonRequests"); + }); + + 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("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", 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("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Ombi.Store.Entities.MobileDevices", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("NotificationUserIds") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.TvRequests", "ParentRequest") + .WithMany("ChildRequests") + .HasForeignKey("ParentRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("ParentRequest"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.HasOne("Ombi.Store.Entities.Requests.Issues", "Issues") + .WithMany("Comments") + .HasForeignKey("IssuesId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Issues"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.HasOne("Ombi.Store.Entities.Requests.IssueCategory", "IssueCategory") + .WithMany() + .HasForeignKey("IssueCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", null) + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.Requests.MovieRequests", null) + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "UserReported") + .WithMany() + .HasForeignKey("UserReportedId"); + + b.Navigation("IssueCategory"); + + b.Navigation("UserReported"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("UserNotificationPreferences") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season") + .WithMany("Episodes") + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", "ChildRequest") + .WithMany("SeasonRequests") + .HasForeignKey("ChildRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildRequest"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Navigation("NotificationUserIds"); + + b.Navigation("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Navigation("Issues"); + + b.Navigation("SeasonRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Navigation("Comments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Navigation("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Navigation("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Navigation("Episodes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/SettingsMsSql/20241022000052_Initial.Designer.cs b/src/Ombi.Store/Migrations/SettingsMsSql/20241022000052_Initial.Designer.cs new file mode 100644 index 000000000..9fb08a5ee --- /dev/null +++ b/src/Ombi.Store/Migrations/SettingsMsSql/20241022000052_Initial.Designer.cs @@ -0,0 +1,67 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.MsSql; + +#nullable disable + +namespace Ombi.Store.Migrations.SettingsMsSql +{ + [DbContext(typeof(SettingsMsSqlContext))] + [Migration("20241022000052_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ApplicationConfiguration"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("SettingsName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("GlobalSettings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/SettingsMsSql/20241022000052_Initial.cs b/src/Ombi.Store/Migrations/SettingsMsSql/20241022000052_Initial.cs new file mode 100644 index 000000000..2ef9b5740 --- /dev/null +++ b/src/Ombi.Store/Migrations/SettingsMsSql/20241022000052_Initial.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Ombi.Store.Migrations.SettingsMsSql +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ApplicationConfiguration", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Type = table.Column(type: "int", nullable: false), + Value = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ApplicationConfiguration", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "GlobalSettings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Content = table.Column(type: "nvarchar(max)", nullable: true), + SettingsName = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GlobalSettings", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ApplicationConfiguration"); + + migrationBuilder.DropTable( + name: "GlobalSettings"); + } + } +} diff --git a/src/Ombi.Store/Migrations/SettingsMsSql/SettingsMsSqlContextModelSnapshot.cs b/src/Ombi.Store/Migrations/SettingsMsSql/SettingsMsSqlContextModelSnapshot.cs new file mode 100644 index 000000000..e68b22385 --- /dev/null +++ b/src/Ombi.Store/Migrations/SettingsMsSql/SettingsMsSqlContextModelSnapshot.cs @@ -0,0 +1,64 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.MsSql; + +#nullable disable + +namespace Ombi.Store.Migrations.SettingsMsSql +{ + [DbContext(typeof(SettingsMsSqlContext))] + partial class SettingsMsSqlContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ApplicationConfiguration"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("SettingsName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("GlobalSettings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Ombi.Store.csproj b/src/Ombi.Store/Ombi.Store.csproj index ca12ab3f2..3a1b462ab 100644 --- a/src/Ombi.Store/Ombi.Store.csproj +++ b/src/Ombi.Store/Ombi.Store.csproj @@ -18,6 +18,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Ombi/Extensions/DatabaseExtensions.cs b/src/Ombi/Extensions/DatabaseExtensions.cs index c56e2f52d..f761530be 100644 --- a/src/Ombi/Extensions/DatabaseExtensions.cs +++ b/src/Ombi/Extensions/DatabaseExtensions.cs @@ -5,25 +5,26 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; -using MySqlConnector; using Newtonsoft.Json; using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; using Ombi.Helpers; using Ombi.Store.Context; +using Ombi.Store.Context.MsSql; using Ombi.Store.Context.MySql; using Ombi.Store.Context.Sqlite; using Ombi.Store.Context.Postgres; using Polly; using Pomelo.EntityFrameworkCore.MySql.Storage.Internal; using SQLitePCL; +using SettingsContext = Ombi.Store.Context.SettingsContext; namespace Ombi.Extensions { public static class DatabaseExtensions { - public const string SqliteDatabase = "Sqlite"; public const string MySqlDatabase = "MySQL"; + public const string MsSqlDatabase = "MSSQL"; public const string PostgresDatabase = "Postgres"; public static void ConfigureDatabases(this IServiceCollection services, IHealthChecksBuilder hcBuilder) @@ -41,6 +42,10 @@ public static void ConfigureDatabases(this IServiceCollection services, IHealthC services.AddDbContext(x => ConfigureMySql(x, configuration.OmbiDatabase)); AddMySqlHealthCheck(hcBuilder, "Ombi Database", configuration.OmbiDatabase); break; + case var type when type.Equals(MsSqlDatabase, StringComparison.InvariantCultureIgnoreCase): + services.AddDbContext(x => ConfigureMsSql(x, configuration.OmbiDatabase)); + AddMsSqlHealthCheck(hcBuilder, "Ombi Database", configuration.OmbiDatabase); + break; case var type when type.Equals(PostgresDatabase, StringComparison.InvariantCultureIgnoreCase): services.AddDbContext(x => ConfigurePostgres(x, configuration.OmbiDatabase)); AddPostgresHealthCheck(hcBuilder, "Ombi Database", configuration.OmbiDatabase); @@ -57,6 +62,10 @@ public static void ConfigureDatabases(this IServiceCollection services, IHealthC services.AddDbContext(x => ConfigureMySql(x, configuration.ExternalDatabase)); AddMySqlHealthCheck(hcBuilder, "External Database", configuration.ExternalDatabase); break; + case var type when type.Equals(MsSqlDatabase, StringComparison.InvariantCultureIgnoreCase): + services.AddDbContext(x => ConfigureMsSql(x, configuration.ExternalDatabase)); + AddMsSqlHealthCheck(hcBuilder, "External Database", configuration.ExternalDatabase); + break; case var type when type.Equals(PostgresDatabase, StringComparison.InvariantCultureIgnoreCase): services.AddDbContext(x => ConfigurePostgres(x, configuration.ExternalDatabase)); AddPostgresHealthCheck(hcBuilder, "External Database", configuration.ExternalDatabase); @@ -73,6 +82,10 @@ public static void ConfigureDatabases(this IServiceCollection services, IHealthC services.AddDbContext(x => ConfigureMySql(x, configuration.SettingsDatabase)); AddMySqlHealthCheck(hcBuilder, "Settings Database", configuration.SettingsDatabase); break; + case var type when type.Equals(MsSqlDatabase, StringComparison.InvariantCultureIgnoreCase): + services.AddDbContext(x => ConfigureMsSql(x, configuration.SettingsDatabase)); + AddMsSqlHealthCheck(hcBuilder, "Settings Database", configuration.SettingsDatabase); + break; case var type when type.Equals(PostgresDatabase, StringComparison.InvariantCultureIgnoreCase): services.AddDbContext(x => ConfigurePostgres(x, configuration.SettingsDatabase)); AddPostgresHealthCheck(hcBuilder, "Settings Database", configuration.SettingsDatabase); @@ -131,6 +144,20 @@ private static void AddMySqlHealthCheck(IHealthChecksBuilder builder, string dbN } } + private static void AddMsSqlHealthCheck(IHealthChecksBuilder builder, string dbName, + PerDatabaseConfiguration config) + { + if (builder is not null) + { + builder.AddSqlServer( + connectionString: config.ConnectionString, + name: dbName, + failureStatus: HealthStatus.Unhealthy, + tags: ["db"] + ); + } + } + private static void AddPostgresHealthCheck(IHealthChecksBuilder builder, string dbName, PerDatabaseConfiguration config) { if (builder != null) @@ -165,6 +192,19 @@ public static void ConfigureMySql(DbContextOptionsBuilder options, PerDatabaseCo }); } + public static void ConfigureMsSql(DbContextOptionsBuilder options, PerDatabaseConfiguration config) + { + if (string.IsNullOrEmpty(config.ConnectionString)) + { + throw new ArgumentNullException("ConnectionString for the MsSql database is empty"); + } + + options.UseSqlServer(config.ConnectionString, e => + { + e.EnableRetryOnFailure(); + }); + } + public static void ConfigurePostgres(DbContextOptionsBuilder options, PerDatabaseConfiguration config) { options.UseNpgsql(config.ConnectionString, b => diff --git a/src/Ombi/Ombi.csproj b/src/Ombi/Ombi.csproj index 4e7b55b8b..82e5dcd00 100644 --- a/src/Ombi/Ombi.csproj +++ b/src/Ombi/Ombi.csproj @@ -67,6 +67,7 @@ + From 89f60e69de66b6deb363eb380e2d4ca603a6dd6a Mon Sep 17 00:00:00 2001 From: Joseph Sawyer Date: Tue, 22 Oct 2024 19:30:07 +0100 Subject: [PATCH 2/6] ignore Rider and macOS junk and exclude migrations from sonar analysis --- .github/workflows/sonarscan.yml | 2 +- .gitignore | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarscan.yml b/.github/workflows/sonarscan.yml index 42cfa3030..49f69913c 100644 --- a/.github/workflows/sonarscan.yml +++ b/.github/workflows/sonarscan.yml @@ -45,6 +45,6 @@ jobs: # The organization and project arguments (see /o and /k) are displayed # on the project dashboard in SonarCloud. run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"Ombi-app_Ombi" /o:"ombi-app" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + .\.sonar\scanner\dotnet-sonarscanner begin /k:"Ombi-app_Ombi" /o:"ombi-app" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="src/Ombi.Store/Migrations/*" dotnet build src/Ombi.sln -c NonUiBuild .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" diff --git a/.gitignore b/.gitignore index 143b2fc13..8f62c8e6b 100644 --- a/.gitignore +++ b/.gitignore @@ -138,7 +138,7 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings +# TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj @@ -245,6 +245,29 @@ _Pvt_Extensions /Tools/* *.db-journal +# Common IntelliJ Platform excludes + +# User specific +**/.idea/**/workspace.xml +**/.idea/**/tasks.xml +**/.idea/shelf/* +**/.idea/dictionaries +**/.idea/httpRequests/ + +# Sensitive or high-churn files +**/.idea/**/dataSources/ +**/.idea/**/dataSources.ids +**/.idea/**/dataSources.xml +**/.idea/**/dataSources.local.xml +**/.idea/**/sqlDataSources.xml +**/.idea/**/dynamic.xml + +# Rider +# Rider auto-generates .iml files, and contentModel.xml +**/.idea/**/*.iml +**/.idea/**/contentModel.xml +**/.idea/**/modules.xml + # Ignore local vscode config *.vscode /src/Ombi/database.json From 0a865f7b114aed258beca60104a376e160a0aac9 Mon Sep 17 00:00:00 2001 From: Joseph Sawyer Date: Tue, 22 Oct 2024 19:34:59 +0100 Subject: [PATCH 3/6] ** exclusion rule --- .github/workflows/sonarscan.yml | 2 +- .gitignore | 26 ++++---------------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/.github/workflows/sonarscan.yml b/.github/workflows/sonarscan.yml index 49f69913c..7cd9dc039 100644 --- a/.github/workflows/sonarscan.yml +++ b/.github/workflows/sonarscan.yml @@ -45,6 +45,6 @@ jobs: # The organization and project arguments (see /o and /k) are displayed # on the project dashboard in SonarCloud. run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"Ombi-app_Ombi" /o:"ombi-app" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="src/Ombi.Store/Migrations/*" + .\.sonar\scanner\dotnet-sonarscanner begin /k:"Ombi-app_Ombi" /o:"ombi-app" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="src/Ombi.Store/Migrations/**" dotnet build src/Ombi.sln -c NonUiBuild .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" diff --git a/.gitignore b/.gitignore index 8f62c8e6b..9ce0412ee 100644 --- a/.gitignore +++ b/.gitignore @@ -245,28 +245,10 @@ _Pvt_Extensions /Tools/* *.db-journal -# Common IntelliJ Platform excludes - -# User specific -**/.idea/**/workspace.xml -**/.idea/**/tasks.xml -**/.idea/shelf/* -**/.idea/dictionaries -**/.idea/httpRequests/ - -# Sensitive or high-churn files -**/.idea/**/dataSources/ -**/.idea/**/dataSources.ids -**/.idea/**/dataSources.xml -**/.idea/**/dataSources.local.xml -**/.idea/**/sqlDataSources.xml -**/.idea/**/dynamic.xml - -# Rider -# Rider auto-generates .iml files, and contentModel.xml -**/.idea/**/*.iml -**/.idea/**/contentModel.xml -**/.idea/**/modules.xml +# JetBrains Rider shame +**/.idea/** +# macOS shame +.DS_Store # Ignore local vscode config *.vscode From b677f9d295af15119dd650cacaa75501365864e9 Mon Sep 17 00:00:00 2001 From: Joseph Sawyer Date: Tue, 22 Oct 2024 19:36:43 +0100 Subject: [PATCH 4/6] remove idea ignore and rejoice with our fellow Riders! --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9ce0412ee..2573e53a5 100644 --- a/.gitignore +++ b/.gitignore @@ -245,8 +245,6 @@ _Pvt_Extensions /Tools/* *.db-journal -# JetBrains Rider shame -**/.idea/** # macOS shame .DS_Store From 0b4a1044ced13414e483acb6a8c1ec638c0266d5 Mon Sep 17 00:00:00 2001 From: Joseph Sawyer Date: Tue, 22 Oct 2024 19:43:57 +0100 Subject: [PATCH 5/6] exclude /**/* --- .github/workflows/sonarscan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarscan.yml b/.github/workflows/sonarscan.yml index 7cd9dc039..a4776ff1c 100644 --- a/.github/workflows/sonarscan.yml +++ b/.github/workflows/sonarscan.yml @@ -45,6 +45,6 @@ jobs: # The organization and project arguments (see /o and /k) are displayed # on the project dashboard in SonarCloud. run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"Ombi-app_Ombi" /o:"ombi-app" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="src/Ombi.Store/Migrations/**" + .\.sonar\scanner\dotnet-sonarscanner begin /k:"Ombi-app_Ombi" /o:"ombi-app" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="src/Ombi.Store/Migrations/**/*" dotnet build src/Ombi.sln -c NonUiBuild .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" From be3e1268aea292bf37fa12d255a76fc2ad9145ba Mon Sep 17 00:00:00 2001 From: Joseph Sawyer Date: Tue, 22 Oct 2024 19:50:48 +0100 Subject: [PATCH 6/6] try cdp.exclusions --- .github/workflows/sonarscan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarscan.yml b/.github/workflows/sonarscan.yml index a4776ff1c..bcb24f877 100644 --- a/.github/workflows/sonarscan.yml +++ b/.github/workflows/sonarscan.yml @@ -45,6 +45,6 @@ jobs: # The organization and project arguments (see /o and /k) are displayed # on the project dashboard in SonarCloud. run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"Ombi-app_Ombi" /o:"ombi-app" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="src/Ombi.Store/Migrations/**/*" + .\.sonar\scanner\dotnet-sonarscanner begin /k:"Ombi-app_Ombi" /o:"ombi-app" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cdp.exclusions="src/Ombi.Store/Migrations/**/*" dotnet build src/Ombi.sln -c NonUiBuild .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"