genre added
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model;
|
||||
using WatchIt.Database.Model.Account;
|
||||
using WatchIt.Database.Model.Genre;
|
||||
|
||||
namespace WatchIt.Database
|
||||
{
|
||||
@@ -28,6 +29,9 @@ namespace WatchIt.Database
|
||||
public virtual DbSet<Account> Accounts { get; set; }
|
||||
public virtual DbSet<AccountProfilePicture> AccountProfilePictures { get; set; }
|
||||
|
||||
// Genre
|
||||
public virtual DbSet<Genre> Genres { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -41,6 +45,9 @@ namespace WatchIt.Database
|
||||
// Account
|
||||
EntityBuilder.Build<Account>(modelBuilder);
|
||||
EntityBuilder.Build<AccountProfilePicture>(modelBuilder);
|
||||
|
||||
// Genre
|
||||
EntityBuilder.Build<Genre>(modelBuilder);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -12,7 +12,7 @@ using WatchIt.Database;
|
||||
namespace WatchIt.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(DatabaseContext))]
|
||||
[Migration("20240317125055_Migration1")]
|
||||
[Migration("20240317131418_Migration1")]
|
||||
partial class Migration1
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -119,6 +119,31 @@ namespace WatchIt.Database.Migrations
|
||||
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")
|
||||
@@ -26,6 +26,20 @@ namespace WatchIt.Database.Migrations
|
||||
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
|
||||
@@ -71,6 +85,12 @@ namespace WatchIt.Database.Migrations
|
||||
table: "Accounts",
|
||||
column: "Id",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Genres_Id",
|
||||
table: "Genres",
|
||||
column: "Id",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -79,6 +99,9 @@ namespace WatchIt.Database.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "Accounts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Genres");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AccountProfilePictures");
|
||||
}
|
||||
183
WatchIt.Database/WatchIt.Database/Migrations/20240317132500_Migration2.Designer.cs
generated
Normal file
183
WatchIt.Database/WatchIt.Database/Migrations/20240317132500_Migration2.Designer.cs
generated
Normal file
@@ -0,0 +1,183 @@
|
||||
// <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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,6 +116,48 @@ namespace WatchIt.Database.Migrations
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user