new models

This commit is contained in:
2024-03-18 00:14:08 +01:00
Unverified
parent 26bbbf80c2
commit 6d1b30db47
31 changed files with 4820 additions and 524 deletions

View File

@@ -9,6 +9,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WatchIt.Database.Model.Media;
namespace WatchIt.Database.Model.Account
{
@@ -20,17 +21,14 @@ namespace WatchIt.Database.Model.Account
public string Username { get; set; }
public string Email { get; set; }
public string Description { get; set; }
public Guid AccountProfilePictureId { get; set; }
// BackgroundPicture key to MovieImages
// public Guid BackgroundPicture { get; set; }
public Guid? ProfilePictureId { get; set; }
public Guid? BackgroundPictureId { get; set; }
public byte[] Password { get; set; }
public string LeftSalt { get; set; }
public string RightSalt { get; set; }
public bool IsAdmin { get; set; } = false;
public DateTimeOffset CreationDate { get; set; }
public DateTimeOffset LastActive { get; set; }
public DateTime CreationDate { get; set; }
public DateTime LastActive { get; set; }
#endregion
@@ -38,7 +36,8 @@ namespace WatchIt.Database.Model.Account
#region NAVIGATION
public AccountProfilePicture AccountProfilePicture { get; set; }
public AccountProfilePicture? ProfilePicture { get; set; }
public MediaPhotoImage? BackgroundPicture { get; set; }
#endregion
@@ -65,10 +64,15 @@ namespace WatchIt.Database.Model.Account
builder.Property(x => x.Description)
.HasMaxLength(1000);
builder.HasOne(x => x.AccountProfilePicture)
builder.HasOne(x => x.ProfilePicture)
.WithOne(x => x.Account)
.HasForeignKey<Account>(e => e.AccountProfilePictureId);
builder.Property(x => x.AccountProfilePictureId);
.HasForeignKey<Account>(e => e.ProfilePictureId);
builder.Property(x => x.ProfilePictureId);
builder.HasOne(x => x.BackgroundPicture)
.WithMany()
.HasForeignKey(x => x.BackgroundPictureId);
builder.Property(x => x.BackgroundPictureId);
builder.Property(x => x.Password)
.HasMaxLength(1000)

View File

@@ -17,7 +17,7 @@ namespace WatchIt.Database.Model.Account
public Guid Id { get; set; }
public byte[] Image { get; set; }
public string MimeType { get; set; }
public DateTimeOffset UploadDate { get; set; }
public DateTime UploadDate { get; set; }
#endregion

View File

@@ -19,6 +19,15 @@ namespace WatchIt.Database.Model.Genre
#region NAVIGATION
public ICollection<GenreMedia> GenreMedia { get; set; }
public ICollection<Media.Media> Media { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<Genre>.Build(EntityTypeBuilder<Genre> builder)
@@ -35,6 +44,11 @@ namespace WatchIt.Database.Model.Genre
builder.Property(x => x.Description)
.HasMaxLength(1000);
// Navigation
builder.HasMany(x => x.Media)
.WithMany(x => x.Genres)
.UsingEntity<GenreMedia>();
}
static IEnumerable<Genre> IEntity<Genre>.InsertData() => new List<Genre>

View File

@@ -0,0 +1,52 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WatchIt.Database.Model.Media;
namespace WatchIt.Database.Model.Genre
{
public class GenreMedia : IEntity<GenreMedia>
{
#region PROPERTIES
public long MediaId { get; set; }
public short GenreId { get; set; }
#endregion
#region NAVIGATION
public Media.Media Media { get; set; }
public Genre Genre { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<GenreMedia>.Build(EntityTypeBuilder<GenreMedia> builder)
{
builder.HasOne(x => x.Media)
.WithMany(x => x.GenreMedia)
.HasForeignKey(x => x.MediaId)
.IsRequired();
builder.Property(x => x.MediaId)
.IsRequired();
builder.HasOne(x => x.Genre)
.WithMany(x => x.GenreMedia)
.HasForeignKey(x => x.GenreId)
.IsRequired();
builder.Property(x => x.GenreId)
.IsRequired();
}
#endregion
}
}

View File

@@ -0,0 +1,76 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WatchIt.Database.Model.Account;
using WatchIt.Database.Model.Genre;
namespace WatchIt.Database.Model.Media
{
public class Media : IEntity<Media>
{
#region PROPERTIES
public long Id { get; set; }
public string Title { get; set; }
public string? OriginalTitle { get; set; }
public string? Description { get; set; }
public DateTime? ReleaseDate { get; set; }
public TimeSpan? Length { get; set; }
public Guid? MediaPosterImageId { get; set; }
#endregion
#region NAVIGATION
public MediaPosterImage? MediaPosterImage { get; set; }
public ICollection<MediaPhotoImage> MediaPhotoImages { get; set; }
public ICollection<GenreMedia> GenreMedia { get; set; }
public ICollection<Genre.Genre> Genres { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<Media>.Build(EntityTypeBuilder<Media> builder)
{
builder.HasKey(x => x.Id);
builder.HasIndex(x => x.Id)
.IsUnique();
builder.Property(x => x.Id)
.IsRequired();
builder.Property(x => x.Title)
.HasMaxLength(250)
.IsRequired();
builder.Property(x => x.OriginalTitle)
.HasMaxLength(250);
builder.Property(x => x.Description)
.HasMaxLength(1000);
builder.Property(x => x.ReleaseDate);
builder.Property(x => x.Length);
builder.HasOne(x => x.MediaPosterImage)
.WithOne(x => x.Media)
.HasForeignKey<Media>(x => x.MediaPosterImageId);
builder.Property(x => x.MediaPosterImageId);
// Navigation
builder.HasMany(x => x.Genres)
.WithMany(x => x.Media)
.UsingEntity<GenreMedia>();
}
#endregion
}
}

View File

@@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WatchIt.Database.Model.Media
{
public class MediaMovie : IEntity<MediaMovie>
{
#region PROPERTIES
public long Id { get; set; }
public decimal? Budget { get; set; }
#endregion
#region NAVIGATION
public Media Media { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<MediaMovie>.Build(EntityTypeBuilder<MediaMovie> builder)
{
builder.HasKey(x => x.Id);
builder.HasOne(x => x.Media)
.WithOne()
.HasForeignKey<Media>(x => x.Id)
.IsRequired();
builder.HasIndex(x => x.Id)
.IsUnique();
builder.Property(x => x.Id)
.IsRequired();
builder.Property(x => x.Budget)
.HasColumnType("money");
}
#endregion
}
}

View File

@@ -0,0 +1,76 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace WatchIt.Database.Model.Media
{
public class MediaPhotoImage : IEntity<MediaPhotoImage>
{
#region PROPERTIES
public Guid Id { get; set; }
public long MediaId { get; set; }
public byte[] Image { get; set; }
public string MimeType { get; set; }
public DateTime UploadDate { get; set; }
public bool IsMediaBackground { get; set; }
public bool IsUniversalBackground { get; set; }
#endregion
#region NAVIGATION
public Media Media { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<MediaPhotoImage>.Build(EntityTypeBuilder<MediaPhotoImage> builder)
{
builder.HasKey(x => x.Id);
builder.HasIndex(x => x.Id)
.IsUnique();
builder.Property(x => x.Id)
.IsRequired();
builder.HasOne(x => x.Media)
.WithMany(x => x.MediaPhotoImages)
.HasForeignKey(x => x.MediaId)
.IsRequired();
builder.Property(x => x.MediaId)
.IsRequired();
builder.Property(x => x.Image)
.HasMaxLength(-1)
.IsRequired();
builder.Property(x => x.MimeType)
.HasMaxLength(50)
.IsRequired();
builder.Property(x => x.UploadDate)
.IsRequired()
.HasDefaultValueSql("now()");
builder.Property(x => x.IsMediaBackground)
.IsRequired()
.HasDefaultValue(false);
builder.Property(x => x.IsUniversalBackground)
.IsRequired()
.HasDefaultValue(false);
}
#endregion
}
}

View File

@@ -0,0 +1,57 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WatchIt.Database.Model.Media
{
public class MediaPosterImage : IEntity<MediaPosterImage>
{
#region PROPERTIES
public Guid Id { get; set; }
public byte[] Image { get; set; }
public string MimeType { get; set; }
public DateTime UploadDate { get; set; }
#endregion
#region NAVIGATION
public Media Media { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<MediaPosterImage>.Build(EntityTypeBuilder<MediaPosterImage> builder)
{
builder.HasKey(x => x.Id);
builder.HasIndex(x => x.Id)
.IsUnique();
builder.Property(x => x.Id)
.IsRequired();
builder.Property(x => x.Image)
.HasMaxLength(-1)
.IsRequired();
builder.Property(x => x.MimeType)
.HasMaxLength(50)
.IsRequired();
builder.Property(x => x.UploadDate)
.IsRequired()
.HasDefaultValueSql("now()");
}
#endregion
}
}

View File

@@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WatchIt.Database.Model.Media
{
public class MediaSeries : IEntity<MediaSeries>
{
#region PROPERTIES
public long Id { get; set; }
public bool HasEnded { get; set; }
#endregion
#region NAVIGATION
public Media Media { get; set; }
public ICollection<MediaSeriesSeason> MediaSeriesSeasons { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<MediaSeries>.Build(EntityTypeBuilder<MediaSeries> builder)
{
builder.HasKey(x => x.Id);
builder.HasOne(x => x.Media)
.WithOne()
.HasForeignKey<Media>(x => x.Id)
.IsRequired();
builder.HasIndex(x => x.Id)
.IsUnique();
builder.Property(x => x.Id)
.IsRequired();
builder.Property(x => x.HasEnded);
}
#endregion
}
}

View File

@@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WatchIt.Database.Model.Media
{
public class MediaSeriesEpisode : IEntity<MediaSeriesEpisode>
{
#region PROPERTIES
public Guid Id { get; set; }
public Guid MediaSeriesSeasonId { get; set; }
public short Number { get; set; }
public string? Name { get; set; }
public bool IsSpecial { get; set; }
#endregion
#region NAVIGATION
public MediaSeriesSeason MediaSeriesSeason { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<MediaSeriesEpisode>.Build(EntityTypeBuilder<MediaSeriesEpisode> builder)
{
builder.HasKey(x => x.Id);
builder.HasIndex(x => x.Id)
.IsUnique();
builder.Property(x => x.Id)
.IsRequired();
builder.HasOne(x => x.MediaSeriesSeason)
.WithMany(x => x.MediaSeriesEpisodes)
.HasForeignKey(x => x.MediaSeriesSeasonId)
.IsRequired();
builder.Property(x => x.MediaSeriesSeasonId)
.IsRequired();
builder.Property(x => x.Number)
.IsRequired();
builder.Property(x => x.Name);
builder.Property(x => x.IsSpecial)
.IsRequired()
.HasDefaultValue(false);
}
#endregion
}
}

View File

@@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WatchIt.Database.Model.Media
{
public class MediaSeriesSeason : IEntity<MediaSeriesSeason>
{
#region PROPERTIES
public Guid Id { get; set; }
public long MediaSeriesId { get; set; }
public short Number { get; set; }
public string? Name { get; set; }
#endregion
#region NAVIGATION
public MediaSeries MediaSeries { get; set; }
public ICollection<MediaSeriesEpisode> MediaSeriesEpisodes { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<MediaSeriesSeason>.Build(EntityTypeBuilder<MediaSeriesSeason> builder)
{
builder.HasKey(x => x.Id);
builder.HasIndex(x => x.Id)
.IsUnique();
builder.Property(x => x.Id)
.IsRequired();
builder.HasOne(x => x.MediaSeries)
.WithMany(x => x.MediaSeriesSeasons)
.HasForeignKey(x => x.MediaSeriesId)
.IsRequired();
builder.Property(x => x.MediaSeriesId)
.IsRequired();
builder.Property(x => x.Number)
.IsRequired();
builder.Property(x => x.Name);
}
#endregion
}
}

View File

@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using WatchIt.Database.Model;
using WatchIt.Database.Model.Account;
using WatchIt.Database.Model.Genre;
using WatchIt.Database.Model.Media;
namespace WatchIt.Database
{
@@ -31,6 +32,16 @@ namespace WatchIt.Database
// Genre
public virtual DbSet<Genre> Genres { get; set; }
public virtual DbSet<GenreMedia> GenresMedia { get; set; }
// Media
public virtual DbSet<Media> Media { get; set; }
public virtual DbSet<MediaMovie> MediaMovies { get; set; }
public virtual DbSet<MediaSeries> MediaSeries { get; set; }
public virtual DbSet<MediaSeriesSeason> MediaSeriesSeasons { get; set; }
public virtual DbSet<MediaSeriesEpisode> MediaSeriesEpisodes { get; set; }
public virtual DbSet<MediaPosterImage> MediaPosterImages { get; set; }
public virtual DbSet<MediaPhotoImage> MediaPhotoImages { get; set; }
#endregion
@@ -46,8 +57,18 @@ namespace WatchIt.Database
EntityBuilder.Build<Account>(modelBuilder);
EntityBuilder.Build<AccountProfilePicture>(modelBuilder);
// Media
EntityBuilder.Build<Media>(modelBuilder);
EntityBuilder.Build<MediaMovie>(modelBuilder);
EntityBuilder.Build<MediaSeries>(modelBuilder);
EntityBuilder.Build<MediaSeriesSeason>(modelBuilder);
EntityBuilder.Build<MediaSeriesEpisode>(modelBuilder);
EntityBuilder.Build<MediaPosterImage>(modelBuilder);
EntityBuilder.Build<MediaPhotoImage>(modelBuilder);
// Genre
EntityBuilder.Build<Genre>(modelBuilder);
EntityBuilder.Build<GenreMedia>(modelBuilder);
}
#endregion

View File

@@ -1,166 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WatchIt.Database;
#nullable disable
namespace WatchIt.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240317131418_Migration1")]
partial class Migration1
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid>("AccountProfilePictureId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(320)
.HasColumnType("character varying(320)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("LeftSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<byte[]>("Password")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("AccountProfilePictureId")
.IsUnique();
b.HasIndex("Id")
.IsUnique();
b.ToTable("Accounts");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTimeOffset>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountProfilePictures");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("Genres");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "AccountProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "AccountProfilePictureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AccountProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Navigation("Account")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,109 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AccountProfilePictures",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Image = table.Column<byte[]>(type: "bytea", maxLength: -1, nullable: false),
MimeType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
UploadDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("PK_AccountProfilePictures", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Genres",
columns: table => new
{
Id = table.Column<short>(type: "smallint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Genres", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Username = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Email = table.Column<string>(type: "character varying(320)", maxLength: 320, nullable: false),
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: false),
AccountProfilePictureId = table.Column<Guid>(type: "uuid", nullable: false),
Password = table.Column<byte[]>(type: "bytea", maxLength: 1000, nullable: false),
LeftSalt = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
RightSalt = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
CreationDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
LastActive = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
table.ForeignKey(
name: "FK_Accounts_AccountProfilePictures_AccountProfilePictureId",
column: x => x.AccountProfilePictureId,
principalTable: "AccountProfilePictures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AccountProfilePictures_Id",
table: "AccountProfilePictures",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Accounts_AccountProfilePictureId",
table: "Accounts",
column: "AccountProfilePictureId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Accounts_Id",
table: "Accounts",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Genres_Id",
table: "Genres",
column: "Id",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Accounts");
migrationBuilder.DropTable(
name: "Genres");
migrationBuilder.DropTable(
name: "AccountProfilePictures");
}
}
}

View File

@@ -1,183 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WatchIt.Database;
#nullable disable
namespace WatchIt.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240317132500_Migration2")]
partial class Migration2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid>("AccountProfilePictureId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(320)
.HasColumnType("character varying(320)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("LeftSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<byte[]>("Password")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("AccountProfilePictureId")
.IsUnique();
b.HasIndex("Id")
.IsUnique();
b.ToTable("Accounts");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTimeOffset>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountProfilePictures");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("Genres");
b.HasData(
new
{
Id = (short)1,
Name = "Comedy"
},
new
{
Id = (short)2,
Name = "Thriller"
},
new
{
Id = (short)3,
Name = "Horror"
});
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "AccountProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "AccountProfilePictureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AccountProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Navigation("Account")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,45 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "Genres",
columns: new[] { "Id", "Description", "Name" },
values: new object[,]
{
{ (short)1, null, "Comedy" },
{ (short)2, null, "Thriller" },
{ (short)3, null, "Horror" }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Genres",
keyColumn: "Id",
keyValue: (short)1);
migrationBuilder.DeleteData(
table: "Genres",
keyColumn: "Id",
keyValue: (short)2);
migrationBuilder.DeleteData(
table: "Genres",
keyColumn: "Id",
keyValue: (short)3);
}
}
}

View File

@@ -0,0 +1,378 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WatchIt.Database;
#nullable disable
namespace WatchIt.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240317200431_Migration1")]
partial class Migration1
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid?>("BackgroundPictureId")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(320)
.HasColumnType("character varying(320)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("LeftSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<byte[]>("Password")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<Guid?>("ProfilePictureId")
.HasColumnType("uuid");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("BackgroundPictureId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("ProfilePictureId")
.IsUnique();
b.ToTable("Accounts");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountProfilePictures");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("Genres");
b.HasData(
new
{
Id = (short)1,
Name = "Comedy"
},
new
{
Id = (short)2,
Name = "Thriller"
},
new
{
Id = (short)3,
Name = "Horror"
});
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.Property<short>("GenreId")
.HasColumnType("smallint");
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.HasKey("GenreId", "MediaId");
b.HasIndex("MediaId");
b.ToTable("GenreMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<TimeSpan?>("Length")
.HasColumnType("interval");
b.Property<Guid?>("MediaPosterImageId")
.HasColumnType("uuid");
b.Property<string>("OriginalTitle")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaPosterImageId")
.IsUnique();
b.ToTable("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<bool>("IsMediaBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsUniversalBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaId");
b.ToTable("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaPosterImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaPhotoImage", "BackgroundPicture")
.WithMany()
.HasForeignKey("BackgroundPictureId");
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "ProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "ProfilePictureId");
b.Navigation("BackgroundPicture");
b.Navigation("ProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.HasOne("WatchIt.Database.Model.Genre.Genre", "Genre")
.WithMany("GenreMedia")
.HasForeignKey("GenreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("GenreMedia")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Genre");
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaPosterImage", "MediaPosterImage")
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "MediaPosterImageId");
b.Navigation("MediaPosterImage");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("MediaPhotoImages")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Navigation("Account")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Navigation("GenreMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Navigation("GenreMedia");
b.Navigation("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Navigation("Media")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,261 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AccountProfilePictures",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Image = table.Column<byte[]>(type: "bytea", maxLength: -1, nullable: false),
MimeType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
UploadDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("PK_AccountProfilePictures", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Genres",
columns: table => new
{
Id = table.Column<short>(type: "smallint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Genres", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MediaPosterImages",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Image = table.Column<byte[]>(type: "bytea", maxLength: -1, nullable: false),
MimeType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
UploadDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("PK_MediaPosterImages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Media",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Title = table.Column<string>(type: "character varying(250)", maxLength: 250, nullable: false),
OriginalTitle = table.Column<string>(type: "character varying(250)", maxLength: 250, nullable: true),
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
ReleaseDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Length = table.Column<TimeSpan>(type: "interval", nullable: true),
MediaPosterImageId = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Media", x => x.Id);
table.ForeignKey(
name: "FK_Media_MediaPosterImages_MediaPosterImageId",
column: x => x.MediaPosterImageId,
principalTable: "MediaPosterImages",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "GenreMedia",
columns: table => new
{
MediaId = table.Column<long>(type: "bigint", nullable: false),
GenreId = table.Column<short>(type: "smallint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GenreMedia", x => new { x.GenreId, x.MediaId });
table.ForeignKey(
name: "FK_GenreMedia_Genres_GenreId",
column: x => x.GenreId,
principalTable: "Genres",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GenreMedia_Media_MediaId",
column: x => x.MediaId,
principalTable: "Media",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MediaPhotoImages",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
MediaId = table.Column<long>(type: "bigint", nullable: false),
Image = table.Column<byte[]>(type: "bytea", maxLength: -1, nullable: false),
MimeType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
UploadDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
IsMediaBackground = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
IsUniversalBackground = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MediaPhotoImages", x => x.Id);
table.ForeignKey(
name: "FK_MediaPhotoImages_Media_MediaId",
column: x => x.MediaId,
principalTable: "Media",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Username = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Email = table.Column<string>(type: "character varying(320)", maxLength: 320, nullable: false),
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: false),
ProfilePictureId = table.Column<Guid>(type: "uuid", nullable: true),
BackgroundPictureId = table.Column<Guid>(type: "uuid", nullable: true),
Password = table.Column<byte[]>(type: "bytea", maxLength: 1000, nullable: false),
LeftSalt = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
RightSalt = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
LastActive = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
table.ForeignKey(
name: "FK_Accounts_AccountProfilePictures_ProfilePictureId",
column: x => x.ProfilePictureId,
principalTable: "AccountProfilePictures",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Accounts_MediaPhotoImages_BackgroundPictureId",
column: x => x.BackgroundPictureId,
principalTable: "MediaPhotoImages",
principalColumn: "Id");
});
migrationBuilder.InsertData(
table: "Genres",
columns: new[] { "Id", "Description", "Name" },
values: new object[,]
{
{ (short)1, null, "Comedy" },
{ (short)2, null, "Thriller" },
{ (short)3, null, "Horror" }
});
migrationBuilder.CreateIndex(
name: "IX_AccountProfilePictures_Id",
table: "AccountProfilePictures",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Accounts_BackgroundPictureId",
table: "Accounts",
column: "BackgroundPictureId");
migrationBuilder.CreateIndex(
name: "IX_Accounts_Id",
table: "Accounts",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Accounts_ProfilePictureId",
table: "Accounts",
column: "ProfilePictureId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_GenreMedia_MediaId",
table: "GenreMedia",
column: "MediaId");
migrationBuilder.CreateIndex(
name: "IX_Genres_Id",
table: "Genres",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Media_Id",
table: "Media",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Media_MediaPosterImageId",
table: "Media",
column: "MediaPosterImageId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_MediaPhotoImages_Id",
table: "MediaPhotoImages",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_MediaPhotoImages_MediaId",
table: "MediaPhotoImages",
column: "MediaId");
migrationBuilder.CreateIndex(
name: "IX_MediaPosterImages_Id",
table: "MediaPosterImages",
column: "Id",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Accounts");
migrationBuilder.DropTable(
name: "GenreMedia");
migrationBuilder.DropTable(
name: "AccountProfilePictures");
migrationBuilder.DropTable(
name: "MediaPhotoImages");
migrationBuilder.DropTable(
name: "Genres");
migrationBuilder.DropTable(
name: "Media");
migrationBuilder.DropTable(
name: "MediaPosterImages");
}
}
}

View File

@@ -0,0 +1,378 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WatchIt.Database;
#nullable disable
namespace WatchIt.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240317203820_Migration2")]
partial class Migration2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid?>("BackgroundPictureId")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(320)
.HasColumnType("character varying(320)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("LeftSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<byte[]>("Password")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<Guid?>("ProfilePictureId")
.HasColumnType("uuid");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("BackgroundPictureId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("ProfilePictureId")
.IsUnique();
b.ToTable("Accounts");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountProfilePictures");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("Genres");
b.HasData(
new
{
Id = (short)1,
Name = "Comedy"
},
new
{
Id = (short)2,
Name = "Thriller"
},
new
{
Id = (short)3,
Name = "Horror"
});
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.Property<short>("GenreId")
.HasColumnType("smallint");
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.HasKey("GenreId", "MediaId");
b.HasIndex("MediaId");
b.ToTable("GenresMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<TimeSpan?>("Length")
.HasColumnType("interval");
b.Property<Guid?>("MediaPosterImageId")
.HasColumnType("uuid");
b.Property<string>("OriginalTitle")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaPosterImageId")
.IsUnique();
b.ToTable("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<bool>("IsMediaBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsUniversalBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaId");
b.ToTable("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaPosterImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaPhotoImage", "BackgroundPicture")
.WithMany()
.HasForeignKey("BackgroundPictureId");
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "ProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "ProfilePictureId");
b.Navigation("BackgroundPicture");
b.Navigation("ProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.HasOne("WatchIt.Database.Model.Genre.Genre", "Genre")
.WithMany("GenreMedia")
.HasForeignKey("GenreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("GenreMedia")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Genre");
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaPosterImage", "MediaPosterImage")
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "MediaPosterImageId");
b.Navigation("MediaPosterImage");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("MediaPhotoImages")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Navigation("Account")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Navigation("GenreMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Navigation("GenreMedia");
b.Navigation("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Navigation("Media")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,102 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_GenreMedia_Genres_GenreId",
table: "GenreMedia");
migrationBuilder.DropForeignKey(
name: "FK_GenreMedia_Media_MediaId",
table: "GenreMedia");
migrationBuilder.DropPrimaryKey(
name: "PK_GenreMedia",
table: "GenreMedia");
migrationBuilder.RenameTable(
name: "GenreMedia",
newName: "GenresMedia");
migrationBuilder.RenameIndex(
name: "IX_GenreMedia_MediaId",
table: "GenresMedia",
newName: "IX_GenresMedia_MediaId");
migrationBuilder.AddPrimaryKey(
name: "PK_GenresMedia",
table: "GenresMedia",
columns: new[] { "GenreId", "MediaId" });
migrationBuilder.AddForeignKey(
name: "FK_GenresMedia_Genres_GenreId",
table: "GenresMedia",
column: "GenreId",
principalTable: "Genres",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_GenresMedia_Media_MediaId",
table: "GenresMedia",
column: "MediaId",
principalTable: "Media",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_GenresMedia_Genres_GenreId",
table: "GenresMedia");
migrationBuilder.DropForeignKey(
name: "FK_GenresMedia_Media_MediaId",
table: "GenresMedia");
migrationBuilder.DropPrimaryKey(
name: "PK_GenresMedia",
table: "GenresMedia");
migrationBuilder.RenameTable(
name: "GenresMedia",
newName: "GenreMedia");
migrationBuilder.RenameIndex(
name: "IX_GenresMedia_MediaId",
table: "GenreMedia",
newName: "IX_GenreMedia_MediaId");
migrationBuilder.AddPrimaryKey(
name: "PK_GenreMedia",
table: "GenreMedia",
columns: new[] { "GenreId", "MediaId" });
migrationBuilder.AddForeignKey(
name: "FK_GenreMedia_Genres_GenreId",
table: "GenreMedia",
column: "GenreId",
principalTable: "Genres",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_GenreMedia_Media_MediaId",
table: "GenreMedia",
column: "MediaId",
principalTable: "Media",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -0,0 +1,406 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WatchIt.Database;
#nullable disable
namespace WatchIt.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240317204255_Migration3")]
partial class Migration3
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid?>("BackgroundPictureId")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(320)
.HasColumnType("character varying(320)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("LeftSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<byte[]>("Password")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<Guid?>("ProfilePictureId")
.HasColumnType("uuid");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("BackgroundPictureId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("ProfilePictureId")
.IsUnique();
b.ToTable("Accounts");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountProfilePictures");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("Genres");
b.HasData(
new
{
Id = (short)1,
Name = "Comedy"
},
new
{
Id = (short)2,
Name = "Thriller"
},
new
{
Id = (short)3,
Name = "Horror"
});
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.Property<short>("GenreId")
.HasColumnType("smallint");
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.HasKey("GenreId", "MediaId");
b.HasIndex("MediaId");
b.ToTable("GenresMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<TimeSpan?>("Length")
.HasColumnType("interval");
b.Property<Guid?>("MediaPosterImageId")
.HasColumnType("uuid");
b.Property<string>("OriginalTitle")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaPosterImageId")
.IsUnique();
b.ToTable("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<decimal?>("Budget")
.HasColumnType("money");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaMovies");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<bool>("IsMediaBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsUniversalBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaId");
b.ToTable("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaPosterImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaPhotoImage", "BackgroundPicture")
.WithMany()
.HasForeignKey("BackgroundPictureId");
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "ProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "ProfilePictureId");
b.Navigation("BackgroundPicture");
b.Navigation("ProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.HasOne("WatchIt.Database.Model.Genre.Genre", "Genre")
.WithMany("GenreMedia")
.HasForeignKey("GenreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("GenreMedia")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Genre");
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaMovie", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaPosterImage", "MediaPosterImage")
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "MediaPosterImageId");
b.Navigation("MediaPosterImage");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("MediaPhotoImages")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Navigation("Account")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Navigation("GenreMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Navigation("GenreMedia");
b.Navigation("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Navigation("Media")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,71 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration3 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<long>(
name: "Id",
table: "Media",
type: "bigint",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint")
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.CreateTable(
name: "MediaMovies",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Budget = table.Column<decimal>(type: "money", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MediaMovies", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_MediaMovies_Id",
table: "MediaMovies",
column: "Id",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_Media_MediaMovies_Id",
table: "Media",
column: "Id",
principalTable: "MediaMovies",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Media_MediaMovies_Id",
table: "Media");
migrationBuilder.DropTable(
name: "MediaMovies");
migrationBuilder.AlterColumn<long>(
name: "Id",
table: "Media",
type: "bigint",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
}
}
}

View File

@@ -0,0 +1,475 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WatchIt.Database;
#nullable disable
namespace WatchIt.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240317220502_Migration4")]
partial class Migration4
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid?>("BackgroundPictureId")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(320)
.HasColumnType("character varying(320)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("LeftSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<byte[]>("Password")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<Guid?>("ProfilePictureId")
.HasColumnType("uuid");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("BackgroundPictureId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("ProfilePictureId")
.IsUnique();
b.ToTable("Accounts");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountProfilePictures");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("Genres");
b.HasData(
new
{
Id = (short)1,
Name = "Comedy"
},
new
{
Id = (short)2,
Name = "Thriller"
},
new
{
Id = (short)3,
Name = "Horror"
});
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.Property<short>("GenreId")
.HasColumnType("smallint");
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.HasKey("GenreId", "MediaId");
b.HasIndex("MediaId");
b.ToTable("GenresMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<TimeSpan?>("Length")
.HasColumnType("interval");
b.Property<Guid?>("MediaPosterImageId")
.HasColumnType("uuid");
b.Property<string>("OriginalTitle")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaPosterImageId")
.IsUnique();
b.ToTable("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<decimal?>("Budget")
.HasColumnType("money");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaMovies");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<bool>("IsMediaBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsUniversalBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaId");
b.ToTable("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaPosterImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<bool>("HasEnded")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("IsSpecial")
.HasColumnType("boolean");
b.Property<long>("MediaSeriesId")
.HasColumnType("bigint");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<short>("Number")
.HasColumnType("smallint");
b.HasKey("Id");
b.HasIndex("MediaSeriesId");
b.ToTable("MediaSeriesSeason");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaPhotoImage", "BackgroundPicture")
.WithMany()
.HasForeignKey("BackgroundPictureId");
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "ProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "ProfilePictureId");
b.Navigation("BackgroundPicture");
b.Navigation("ProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.HasOne("WatchIt.Database.Model.Genre.Genre", "Genre")
.WithMany("GenreMedia")
.HasForeignKey("GenreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("GenreMedia")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Genre");
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaMovie", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaPosterImage", "MediaPosterImage")
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "MediaPosterImageId");
b.Navigation("MediaPosterImage");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("MediaPhotoImages")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", "MediaSeries")
.WithMany("MediaSeriesSeasons")
.HasForeignKey("MediaSeriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Navigation("Account")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Navigation("GenreMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Navigation("GenreMedia");
b.Navigation("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Navigation("Media")
.IsRequired();
b.Navigation("MediaSeriesSeasons");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,83 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration4 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "MediaSeries",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
HasEnded = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MediaSeries", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MediaSeriesSeason",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
MediaSeriesId = table.Column<long>(type: "bigint", nullable: false),
Number = table.Column<short>(type: "smallint", nullable: false),
Name = table.Column<string>(type: "text", nullable: true),
IsSpecial = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MediaSeriesSeason", x => x.Id);
table.ForeignKey(
name: "FK_MediaSeriesSeason_MediaSeries_MediaSeriesId",
column: x => x.MediaSeriesId,
principalTable: "MediaSeries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_MediaSeries_Id",
table: "MediaSeries",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_MediaSeriesSeason_MediaSeriesId",
table: "MediaSeriesSeason",
column: "MediaSeriesId");
migrationBuilder.AddForeignKey(
name: "FK_Media_MediaSeries_Id",
table: "Media",
column: "Id",
principalTable: "MediaSeries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Media_MediaSeries_Id",
table: "Media");
migrationBuilder.DropTable(
name: "MediaSeriesSeason");
migrationBuilder.DropTable(
name: "MediaSeries");
}
}
}

View File

@@ -0,0 +1,480 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WatchIt.Database;
#nullable disable
namespace WatchIt.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240317220558_Migration5")]
partial class Migration5
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid?>("BackgroundPictureId")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(320)
.HasColumnType("character varying(320)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("LeftSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<byte[]>("Password")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<Guid?>("ProfilePictureId")
.HasColumnType("uuid");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("BackgroundPictureId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("ProfilePictureId")
.IsUnique();
b.ToTable("Accounts");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountProfilePictures");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("Genres");
b.HasData(
new
{
Id = (short)1,
Name = "Comedy"
},
new
{
Id = (short)2,
Name = "Thriller"
},
new
{
Id = (short)3,
Name = "Horror"
});
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.Property<short>("GenreId")
.HasColumnType("smallint");
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.HasKey("GenreId", "MediaId");
b.HasIndex("MediaId");
b.ToTable("GenresMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<TimeSpan?>("Length")
.HasColumnType("interval");
b.Property<Guid?>("MediaPosterImageId")
.HasColumnType("uuid");
b.Property<string>("OriginalTitle")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaPosterImageId")
.IsUnique();
b.ToTable("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<decimal?>("Budget")
.HasColumnType("money");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaMovies");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<bool>("IsMediaBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsUniversalBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaId");
b.ToTable("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaPosterImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<bool>("HasEnded")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("IsSpecial")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<long>("MediaSeriesId")
.HasColumnType("bigint");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<short>("Number")
.HasColumnType("smallint");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaSeriesId");
b.ToTable("MediaSeriesSeasons");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaPhotoImage", "BackgroundPicture")
.WithMany()
.HasForeignKey("BackgroundPictureId");
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "ProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "ProfilePictureId");
b.Navigation("BackgroundPicture");
b.Navigation("ProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.HasOne("WatchIt.Database.Model.Genre.Genre", "Genre")
.WithMany("GenreMedia")
.HasForeignKey("GenreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("GenreMedia")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Genre");
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaMovie", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaPosterImage", "MediaPosterImage")
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "MediaPosterImageId");
b.Navigation("MediaPosterImage");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("MediaPhotoImages")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", "MediaSeries")
.WithMany("MediaSeriesSeasons")
.HasForeignKey("MediaSeriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Navigation("Account")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Navigation("GenreMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Navigation("GenreMedia");
b.Navigation("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Navigation("Media")
.IsRequired();
b.Navigation("MediaSeriesSeasons");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,106 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration5 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_MediaSeriesSeason_MediaSeries_MediaSeriesId",
table: "MediaSeriesSeason");
migrationBuilder.DropPrimaryKey(
name: "PK_MediaSeriesSeason",
table: "MediaSeriesSeason");
migrationBuilder.RenameTable(
name: "MediaSeriesSeason",
newName: "MediaSeriesSeasons");
migrationBuilder.RenameIndex(
name: "IX_MediaSeriesSeason_MediaSeriesId",
table: "MediaSeriesSeasons",
newName: "IX_MediaSeriesSeasons_MediaSeriesId");
migrationBuilder.AlterColumn<bool>(
name: "IsSpecial",
table: "MediaSeriesSeasons",
type: "boolean",
nullable: false,
defaultValue: false,
oldClrType: typeof(bool),
oldType: "boolean");
migrationBuilder.AddPrimaryKey(
name: "PK_MediaSeriesSeasons",
table: "MediaSeriesSeasons",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_MediaSeriesSeasons_Id",
table: "MediaSeriesSeasons",
column: "Id",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_MediaSeriesSeasons_MediaSeries_MediaSeriesId",
table: "MediaSeriesSeasons",
column: "MediaSeriesId",
principalTable: "MediaSeries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_MediaSeriesSeasons_MediaSeries_MediaSeriesId",
table: "MediaSeriesSeasons");
migrationBuilder.DropPrimaryKey(
name: "PK_MediaSeriesSeasons",
table: "MediaSeriesSeasons");
migrationBuilder.DropIndex(
name: "IX_MediaSeriesSeasons_Id",
table: "MediaSeriesSeasons");
migrationBuilder.RenameTable(
name: "MediaSeriesSeasons",
newName: "MediaSeriesSeason");
migrationBuilder.RenameIndex(
name: "IX_MediaSeriesSeasons_MediaSeriesId",
table: "MediaSeriesSeason",
newName: "IX_MediaSeriesSeason_MediaSeriesId");
migrationBuilder.AlterColumn<bool>(
name: "IsSpecial",
table: "MediaSeriesSeason",
type: "boolean",
nullable: false,
oldClrType: typeof(bool),
oldType: "boolean",
oldDefaultValue: false);
migrationBuilder.AddPrimaryKey(
name: "PK_MediaSeriesSeason",
table: "MediaSeriesSeason",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_MediaSeriesSeason_MediaSeries_MediaSeriesId",
table: "MediaSeriesSeason",
column: "MediaSeriesId",
principalTable: "MediaSeries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -0,0 +1,516 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WatchIt.Database;
#nullable disable
namespace WatchIt.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240317230106_Migration6")]
partial class Migration6
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid?>("BackgroundPictureId")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(320)
.HasColumnType("character varying(320)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("LeftSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<byte[]>("Password")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<Guid?>("ProfilePictureId")
.HasColumnType("uuid");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("BackgroundPictureId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("ProfilePictureId")
.IsUnique();
b.ToTable("Accounts");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountProfilePictures");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("Genres");
b.HasData(
new
{
Id = (short)1,
Name = "Comedy"
},
new
{
Id = (short)2,
Name = "Thriller"
},
new
{
Id = (short)3,
Name = "Horror"
});
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.Property<short>("GenreId")
.HasColumnType("smallint");
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.HasKey("GenreId", "MediaId");
b.HasIndex("MediaId");
b.ToTable("GenresMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<TimeSpan?>("Length")
.HasColumnType("interval");
b.Property<Guid?>("MediaPosterImageId")
.HasColumnType("uuid");
b.Property<string>("OriginalTitle")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaPosterImageId")
.IsUnique();
b.ToTable("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<decimal?>("Budget")
.HasColumnType("money");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaMovies");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<bool>("IsMediaBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsUniversalBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaId");
b.ToTable("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaPosterImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<bool>("HasEnded")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesEpisode", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("IsSpecial")
.HasColumnType("boolean");
b.Property<Guid>("MediaSeriesSeasonId")
.HasColumnType("uuid");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<short>("Number")
.HasColumnType("smallint");
b.HasKey("Id");
b.HasIndex("MediaSeriesSeasonId");
b.ToTable("MediaSeriesEpisode");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<long>("MediaSeriesId")
.HasColumnType("bigint");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<short>("Number")
.HasColumnType("smallint");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaSeriesId");
b.ToTable("MediaSeriesSeasons");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaPhotoImage", "BackgroundPicture")
.WithMany()
.HasForeignKey("BackgroundPictureId");
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "ProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "ProfilePictureId");
b.Navigation("BackgroundPicture");
b.Navigation("ProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.HasOne("WatchIt.Database.Model.Genre.Genre", "Genre")
.WithMany("GenreMedia")
.HasForeignKey("GenreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("GenreMedia")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Genre");
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaMovie", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaPosterImage", "MediaPosterImage")
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "MediaPosterImageId");
b.Navigation("MediaPosterImage");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("MediaPhotoImages")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesEpisode", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaSeriesSeason", "MediaSeriesSeason")
.WithMany("MediaSeriesEpisodes")
.HasForeignKey("MediaSeriesSeasonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MediaSeriesSeason");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", "MediaSeries")
.WithMany("MediaSeriesSeasons")
.HasForeignKey("MediaSeriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Navigation("Account")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Navigation("GenreMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Navigation("GenreMedia");
b.Navigation("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Navigation("Media")
.IsRequired();
b.Navigation("MediaSeriesSeasons");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.Navigation("MediaSeriesEpisodes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,59 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration6 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsSpecial",
table: "MediaSeriesSeasons");
migrationBuilder.CreateTable(
name: "MediaSeriesEpisode",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
MediaSeriesSeasonId = table.Column<Guid>(type: "uuid", nullable: false),
Number = table.Column<short>(type: "smallint", nullable: false),
Name = table.Column<string>(type: "text", nullable: true),
IsSpecial = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MediaSeriesEpisode", x => x.Id);
table.ForeignKey(
name: "FK_MediaSeriesEpisode_MediaSeriesSeasons_MediaSeriesSeasonId",
column: x => x.MediaSeriesSeasonId,
principalTable: "MediaSeriesSeasons",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_MediaSeriesEpisode_MediaSeriesSeasonId",
table: "MediaSeriesEpisode",
column: "MediaSeriesSeasonId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MediaSeriesEpisode");
migrationBuilder.AddColumn<bool>(
name: "IsSpecial",
table: "MediaSeriesSeasons",
type: "boolean",
nullable: false,
defaultValue: false);
}
}
}

View File

@@ -0,0 +1,521 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WatchIt.Database;
#nullable disable
namespace WatchIt.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240317230336_Migration7")]
partial class Migration7
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid?>("BackgroundPictureId")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(320)
.HasColumnType("character varying(320)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.Property<string>("LeftSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<byte[]>("Password")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<Guid?>("ProfilePictureId")
.HasColumnType("uuid");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("BackgroundPictureId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("ProfilePictureId")
.IsUnique();
b.ToTable("Accounts");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountProfilePictures");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("Genres");
b.HasData(
new
{
Id = (short)1,
Name = "Comedy"
},
new
{
Id = (short)2,
Name = "Thriller"
},
new
{
Id = (short)3,
Name = "Horror"
});
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.Property<short>("GenreId")
.HasColumnType("smallint");
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.HasKey("GenreId", "MediaId");
b.HasIndex("MediaId");
b.ToTable("GenresMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<TimeSpan?>("Length")
.HasColumnType("interval");
b.Property<Guid?>("MediaPosterImageId")
.HasColumnType("uuid");
b.Property<string>("OriginalTitle")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaPosterImageId")
.IsUnique();
b.ToTable("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<decimal?>("Budget")
.HasColumnType("money");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaMovies");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<bool>("IsMediaBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsUniversalBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaId");
b.ToTable("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaPosterImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<bool>("HasEnded")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesEpisode", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("IsSpecial")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<Guid>("MediaSeriesSeasonId")
.HasColumnType("uuid");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<short>("Number")
.HasColumnType("smallint");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaSeriesSeasonId");
b.ToTable("MediaSeriesEpisodes");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<long>("MediaSeriesId")
.HasColumnType("bigint");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<short>("Number")
.HasColumnType("smallint");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaSeriesId");
b.ToTable("MediaSeriesSeasons");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaPhotoImage", "BackgroundPicture")
.WithMany()
.HasForeignKey("BackgroundPictureId");
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "ProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "ProfilePictureId");
b.Navigation("BackgroundPicture");
b.Navigation("ProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.HasOne("WatchIt.Database.Model.Genre.Genre", "Genre")
.WithMany("GenreMedia")
.HasForeignKey("GenreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("GenreMedia")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Genre");
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaMovie", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaPosterImage", "MediaPosterImage")
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "MediaPosterImageId");
b.Navigation("MediaPosterImage");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("MediaPhotoImages")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesEpisode", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaSeriesSeason", "MediaSeriesSeason")
.WithMany("MediaSeriesEpisodes")
.HasForeignKey("MediaSeriesSeasonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MediaSeriesSeason");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", "MediaSeries")
.WithMany("MediaSeriesSeasons")
.HasForeignKey("MediaSeriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Navigation("Account")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Navigation("GenreMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Navigation("GenreMedia");
b.Navigation("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Navigation("Media")
.IsRequired();
b.Navigation("MediaSeriesSeasons");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.Navigation("MediaSeriesEpisodes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,106 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration7 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_MediaSeriesEpisode_MediaSeriesSeasons_MediaSeriesSeasonId",
table: "MediaSeriesEpisode");
migrationBuilder.DropPrimaryKey(
name: "PK_MediaSeriesEpisode",
table: "MediaSeriesEpisode");
migrationBuilder.RenameTable(
name: "MediaSeriesEpisode",
newName: "MediaSeriesEpisodes");
migrationBuilder.RenameIndex(
name: "IX_MediaSeriesEpisode_MediaSeriesSeasonId",
table: "MediaSeriesEpisodes",
newName: "IX_MediaSeriesEpisodes_MediaSeriesSeasonId");
migrationBuilder.AlterColumn<bool>(
name: "IsSpecial",
table: "MediaSeriesEpisodes",
type: "boolean",
nullable: false,
defaultValue: false,
oldClrType: typeof(bool),
oldType: "boolean");
migrationBuilder.AddPrimaryKey(
name: "PK_MediaSeriesEpisodes",
table: "MediaSeriesEpisodes",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_MediaSeriesEpisodes_Id",
table: "MediaSeriesEpisodes",
column: "Id",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_MediaSeriesEpisodes_MediaSeriesSeasons_MediaSeriesSeasonId",
table: "MediaSeriesEpisodes",
column: "MediaSeriesSeasonId",
principalTable: "MediaSeriesSeasons",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_MediaSeriesEpisodes_MediaSeriesSeasons_MediaSeriesSeasonId",
table: "MediaSeriesEpisodes");
migrationBuilder.DropPrimaryKey(
name: "PK_MediaSeriesEpisodes",
table: "MediaSeriesEpisodes");
migrationBuilder.DropIndex(
name: "IX_MediaSeriesEpisodes_Id",
table: "MediaSeriesEpisodes");
migrationBuilder.RenameTable(
name: "MediaSeriesEpisodes",
newName: "MediaSeriesEpisode");
migrationBuilder.RenameIndex(
name: "IX_MediaSeriesEpisodes_MediaSeriesSeasonId",
table: "MediaSeriesEpisode",
newName: "IX_MediaSeriesEpisode_MediaSeriesSeasonId");
migrationBuilder.AlterColumn<bool>(
name: "IsSpecial",
table: "MediaSeriesEpisode",
type: "boolean",
nullable: false,
oldClrType: typeof(bool),
oldType: "boolean",
oldDefaultValue: false);
migrationBuilder.AddPrimaryKey(
name: "PK_MediaSeriesEpisode",
table: "MediaSeriesEpisode",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_MediaSeriesEpisode_MediaSeriesSeasons_MediaSeriesSeasonId",
table: "MediaSeriesEpisode",
column: "MediaSeriesSeasonId",
principalTable: "MediaSeriesSeasons",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -30,10 +30,10 @@ namespace WatchIt.Database.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<Guid>("AccountProfilePictureId")
b.Property<Guid?>("BackgroundPictureId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreationDate")
b.Property<DateTime>("CreationDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
@@ -51,7 +51,7 @@ namespace WatchIt.Database.Migrations
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("LastActive")
b.Property<DateTime>("LastActive")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
@@ -66,6 +66,9 @@ namespace WatchIt.Database.Migrations
.HasMaxLength(1000)
.HasColumnType("bytea");
b.Property<Guid?>("ProfilePictureId")
.HasColumnType("uuid");
b.Property<string>("RightSalt")
.IsRequired()
.HasMaxLength(20)
@@ -78,12 +81,14 @@ namespace WatchIt.Database.Migrations
b.HasKey("Id");
b.HasIndex("AccountProfilePictureId")
.IsUnique();
b.HasIndex("BackgroundPictureId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("ProfilePictureId")
.IsUnique();
b.ToTable("Accounts");
});
@@ -103,7 +108,7 @@ namespace WatchIt.Database.Migrations
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTimeOffset>("UploadDate")
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
@@ -158,15 +163,311 @@ namespace WatchIt.Database.Migrations
});
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.Property<short>("GenreId")
.HasColumnType("smallint");
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.HasKey("GenreId", "MediaId");
b.HasIndex("MediaId");
b.ToTable("GenresMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<TimeSpan?>("Length")
.HasColumnType("interval");
b.Property<Guid?>("MediaPosterImageId")
.HasColumnType("uuid");
b.Property<string>("OriginalTitle")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaPosterImageId")
.IsUnique();
b.ToTable("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<decimal?>("Budget")
.HasColumnType("money");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaMovies");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<bool>("IsMediaBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsUniversalBackground")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<long>("MediaId")
.HasColumnType("bigint");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaId");
b.ToTable("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Image")
.IsRequired()
.HasMaxLength(-1)
.HasColumnType("bytea");
b.Property<string>("MimeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("UploadDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("now()");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaPosterImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<bool>("HasEnded")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesEpisode", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("IsSpecial")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<Guid>("MediaSeriesSeasonId")
.HasColumnType("uuid");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<short>("Number")
.HasColumnType("smallint");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaSeriesSeasonId");
b.ToTable("MediaSeriesEpisodes");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<long>("MediaSeriesId")
.HasColumnType("bigint");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<short>("Number")
.HasColumnType("smallint");
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("MediaSeriesId");
b.ToTable("MediaSeriesSeasons");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "AccountProfilePicture")
b.HasOne("WatchIt.Database.Model.Media.MediaPhotoImage", "BackgroundPicture")
.WithMany()
.HasForeignKey("BackgroundPictureId");
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "ProfilePicture")
.WithOne("Account")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "AccountProfilePictureId")
.HasForeignKey("WatchIt.Database.Model.Account.Account", "ProfilePictureId");
b.Navigation("BackgroundPicture");
b.Navigation("ProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.GenreMedia", b =>
{
b.HasOne("WatchIt.Database.Model.Genre.Genre", "Genre")
.WithMany("GenreMedia")
.HasForeignKey("GenreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AccountProfilePicture");
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("GenreMedia")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Genre");
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaMovie", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", null)
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Media.MediaPosterImage", "MediaPosterImage")
.WithOne("Media")
.HasForeignKey("WatchIt.Database.Model.Media.Media", "MediaPosterImageId");
b.Navigation("MediaPosterImage");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPhotoImage", b =>
{
b.HasOne("WatchIt.Database.Model.Media.Media", "Media")
.WithMany("MediaPhotoImages")
.HasForeignKey("MediaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Media");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesEpisode", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaSeriesSeason", "MediaSeriesSeason")
.WithMany("MediaSeriesEpisodes")
.HasForeignKey("MediaSeriesSeasonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MediaSeriesSeason");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.HasOne("WatchIt.Database.Model.Media.MediaSeries", "MediaSeries")
.WithMany("MediaSeriesSeasons")
.HasForeignKey("MediaSeriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MediaSeries");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
@@ -174,6 +475,43 @@ namespace WatchIt.Database.Migrations
b.Navigation("Account")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Genre.Genre", b =>
{
b.Navigation("GenreMedia");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.Media", b =>
{
b.Navigation("GenreMedia");
b.Navigation("MediaPhotoImages");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaMovie", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaPosterImage", b =>
{
b.Navigation("Media")
.IsRequired();
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeries", b =>
{
b.Navigation("Media")
.IsRequired();
b.Navigation("MediaSeriesSeasons");
});
modelBuilder.Entity("WatchIt.Database.Model.Media.MediaSeriesSeason", b =>
{
b.Navigation("MediaSeriesEpisodes");
});
#pragma warning restore 612, 618
}
}