From 08819c6738a4f82ccf07ae5ed60835b087f7bb34 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sun, 6 Nov 2022 02:10:44 -0600 Subject: Añadidos grupos y usuarios MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Migrations/20221106035140_AddUser.Designer.cs | 132 +++++++++++++ Migrations/20221106035140_AddUser.cs | 146 ++++++++++++++ Migrations/20221106041635_AddGroup.Designer.cs | 179 +++++++++++++++++ Migrations/20221106041635_AddGroup.cs | 64 +++++++ .../20221106055650_FixGroupModel.Designer.cs | 179 +++++++++++++++++ Migrations/20221106055650_FixGroupModel.cs | 19 ++ .../20221106061015_ConfigureManyToMany.Designer.cs | 213 +++++++++++++++++++++ Migrations/20221106061015_ConfigureManyToMany.cs | 47 +++++ ...221106062230_AddJoinTableReferences.Designer.cs | 193 +++++++++++++++++++ .../20221106062230_AddJoinTableReferences.cs | 47 +++++ .../20221106062917_AddJoinTableId.Designer.cs | 196 +++++++++++++++++++ Migrations/20221106062917_AddJoinTableId.cs | 26 +++ ...221106063041_AddJoinTablePrimaryKey.Designer.cs | 196 +++++++++++++++++++ .../20221106063041_AddJoinTablePrimaryKey.cs | 19 ++ .../20221106063220_DeleteJoinTableId.Designer.cs | 193 +++++++++++++++++++ Migrations/20221106063220_DeleteJoinTableId.cs | 26 +++ .../20221106063641_AddNullableFields.Designer.cs | 193 +++++++++++++++++++ Migrations/20221106063641_AddNullableFields.cs | 19 ++ Migrations/LibraryContextModelSnapshot.cs | 94 ++++++++- 19 files changed, 2179 insertions(+), 2 deletions(-) create mode 100644 Migrations/20221106035140_AddUser.Designer.cs create mode 100644 Migrations/20221106035140_AddUser.cs create mode 100644 Migrations/20221106041635_AddGroup.Designer.cs create mode 100644 Migrations/20221106041635_AddGroup.cs create mode 100644 Migrations/20221106055650_FixGroupModel.Designer.cs create mode 100644 Migrations/20221106055650_FixGroupModel.cs create mode 100644 Migrations/20221106061015_ConfigureManyToMany.Designer.cs create mode 100644 Migrations/20221106061015_ConfigureManyToMany.cs create mode 100644 Migrations/20221106062230_AddJoinTableReferences.Designer.cs create mode 100644 Migrations/20221106062230_AddJoinTableReferences.cs create mode 100644 Migrations/20221106062917_AddJoinTableId.Designer.cs create mode 100644 Migrations/20221106062917_AddJoinTableId.cs create mode 100644 Migrations/20221106063041_AddJoinTablePrimaryKey.Designer.cs create mode 100644 Migrations/20221106063041_AddJoinTablePrimaryKey.cs create mode 100644 Migrations/20221106063220_DeleteJoinTableId.Designer.cs create mode 100644 Migrations/20221106063220_DeleteJoinTableId.cs create mode 100644 Migrations/20221106063641_AddNullableFields.Designer.cs create mode 100644 Migrations/20221106063641_AddNullableFields.cs (limited to 'Migrations') diff --git a/Migrations/20221106035140_AddUser.Designer.cs b/Migrations/20221106035140_AddUser.Designer.cs new file mode 100644 index 0000000..5144011 --- /dev/null +++ b/Migrations/20221106035140_AddUser.Designer.cs @@ -0,0 +1,132 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20221106035140_AddUser")] + partial class AddUser + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("YearOfBirth") + .HasColumnType("integer"); + + b.Property("languages") + .IsRequired() + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("bigint"); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221106035140_AddUser.cs b/Migrations/20221106035140_AddUser.cs new file mode 100644 index 0000000..de69f56 --- /dev/null +++ b/Migrations/20221106035140_AddUser.cs @@ -0,0 +1,146 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class AddUser : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Title", + table: "Books", + type: "character varying(128)", + maxLength: 128, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ISBN", + table: "Books", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Genres", + table: "Books", + type: "text[]", + nullable: false, + defaultValue: new string[0], + oldClrType: typeof(string[]), + oldType: "text[]", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "languages", + table: "Authors", + type: "text[]", + nullable: false, + defaultValue: new string[0], + oldClrType: typeof(string[]), + oldType: "text[]", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Authors", + type: "character varying(64)", + maxLength: 64, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Country", + table: "Authors", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Email = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Users"); + + migrationBuilder.AlterColumn( + name: "Title", + table: "Books", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "ISBN", + table: "Books", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "Genres", + table: "Books", + type: "text[]", + nullable: true, + oldClrType: typeof(string[]), + oldType: "text[]"); + + migrationBuilder.AlterColumn( + name: "languages", + table: "Authors", + type: "text[]", + nullable: true, + oldClrType: typeof(string[]), + oldType: "text[]"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Authors", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "Country", + table: "Authors", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + } + } +} diff --git a/Migrations/20221106041635_AddGroup.Designer.cs b/Migrations/20221106041635_AddGroup.Designer.cs new file mode 100644 index 0000000..3db1b6d --- /dev/null +++ b/Migrations/20221106041635_AddGroup.Designer.cs @@ -0,0 +1,179 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20221106041635_AddGroup")] + partial class AddGroup + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("GroupUserAccount", b => + { + b.Property("GroupsId") + .HasColumnType("bigint"); + + b.Property("UsersId") + .HasColumnType("bigint"); + + b.HasKey("GroupsId", "UsersId"); + + b.HasIndex("UsersId"); + + b.ToTable("GroupUserAccount"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("YearOfBirth") + .HasColumnType("integer"); + + b.Property("languages") + .IsRequired() + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("bigint"); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", null) + .WithMany() + .HasForeignKey("GroupsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", null) + .WithMany() + .HasForeignKey("UsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221106041635_AddGroup.cs b/Migrations/20221106041635_AddGroup.cs new file mode 100644 index 0000000..23f5fc9 --- /dev/null +++ b/Migrations/20221106041635_AddGroup.cs @@ -0,0 +1,64 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class AddGroup : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Groups", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Groups", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "GroupUserAccount", + columns: table => new + { + GroupsId = table.Column(type: "bigint", nullable: false), + UsersId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupUserAccount", x => new { x.GroupsId, x.UsersId }); + table.ForeignKey( + name: "FK_GroupUserAccount_Groups_GroupsId", + column: x => x.GroupsId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupUserAccount_Users_UsersId", + column: x => x.UsersId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_GroupUserAccount_UsersId", + table: "GroupUserAccount", + column: "UsersId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "GroupUserAccount"); + + migrationBuilder.DropTable( + name: "Groups"); + } + } +} diff --git a/Migrations/20221106055650_FixGroupModel.Designer.cs b/Migrations/20221106055650_FixGroupModel.Designer.cs new file mode 100644 index 0000000..a474608 --- /dev/null +++ b/Migrations/20221106055650_FixGroupModel.Designer.cs @@ -0,0 +1,179 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20221106055650_FixGroupModel")] + partial class FixGroupModel + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("GroupUserAccount", b => + { + b.Property("GroupsId") + .HasColumnType("bigint"); + + b.Property("UsersId") + .HasColumnType("bigint"); + + b.HasKey("GroupsId", "UsersId"); + + b.HasIndex("UsersId"); + + b.ToTable("GroupUserAccount"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("YearOfBirth") + .HasColumnType("integer"); + + b.Property("languages") + .IsRequired() + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("bigint"); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", null) + .WithMany() + .HasForeignKey("GroupsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", null) + .WithMany() + .HasForeignKey("UsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221106055650_FixGroupModel.cs b/Migrations/20221106055650_FixGroupModel.cs new file mode 100644 index 0000000..391d6f3 --- /dev/null +++ b/Migrations/20221106055650_FixGroupModel.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class FixGroupModel : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Migrations/20221106061015_ConfigureManyToMany.Designer.cs b/Migrations/20221106061015_ConfigureManyToMany.Designer.cs new file mode 100644 index 0000000..79f0241 --- /dev/null +++ b/Migrations/20221106061015_ConfigureManyToMany.Designer.cs @@ -0,0 +1,213 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20221106061015_ConfigureManyToMany")] + partial class ConfigureManyToMany + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("GroupUserAccount", b => + { + b.Property("GroupsId") + .HasColumnType("bigint"); + + b.Property("UsersId") + .HasColumnType("bigint"); + + b.HasKey("GroupsId", "UsersId"); + + b.HasIndex("UsersId"); + + b.ToTable("GroupUserAccount"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("YearOfBirth") + .HasColumnType("integer"); + + b.Property("languages") + .IsRequired() + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("bigint"); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.HasKey("UserAccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupUserAccounts"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", null) + .WithMany() + .HasForeignKey("GroupsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", null) + .WithMany() + .HasForeignKey("UsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221106061015_ConfigureManyToMany.cs b/Migrations/20221106061015_ConfigureManyToMany.cs new file mode 100644 index 0000000..9300ac2 --- /dev/null +++ b/Migrations/20221106061015_ConfigureManyToMany.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class ConfigureManyToMany : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "GroupUserAccounts", + columns: table => new + { + GroupId = table.Column(type: "bigint", nullable: false), + UserAccountId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupUserAccounts", x => new { x.UserAccountId, x.GroupId }); + table.ForeignKey( + name: "FK_GroupUserAccounts_Groups_GroupId", + column: x => x.GroupId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupUserAccounts_Users_UserAccountId", + column: x => x.UserAccountId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_GroupUserAccounts_GroupId", + table: "GroupUserAccounts", + column: "GroupId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "GroupUserAccounts"); + } + } +} diff --git a/Migrations/20221106062230_AddJoinTableReferences.Designer.cs b/Migrations/20221106062230_AddJoinTableReferences.Designer.cs new file mode 100644 index 0000000..0b2d767 --- /dev/null +++ b/Migrations/20221106062230_AddJoinTableReferences.Designer.cs @@ -0,0 +1,193 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20221106062230_AddJoinTableReferences")] + partial class AddJoinTableReferences + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("YearOfBirth") + .HasColumnType("integer"); + + b.Property("languages") + .IsRequired() + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("bigint"); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.HasKey("UserAccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupUserAccounts"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", "Group") + .WithMany("Users") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", "UserAccount") + .WithMany("Groups") + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Navigation("Groups"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221106062230_AddJoinTableReferences.cs b/Migrations/20221106062230_AddJoinTableReferences.cs new file mode 100644 index 0000000..d7f1f8e --- /dev/null +++ b/Migrations/20221106062230_AddJoinTableReferences.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class AddJoinTableReferences : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "GroupUserAccount"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "GroupUserAccount", + columns: table => new + { + GroupsId = table.Column(type: "bigint", nullable: false), + UsersId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupUserAccount", x => new { x.GroupsId, x.UsersId }); + table.ForeignKey( + name: "FK_GroupUserAccount_Groups_GroupsId", + column: x => x.GroupsId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupUserAccount_Users_UsersId", + column: x => x.UsersId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_GroupUserAccount_UsersId", + table: "GroupUserAccount", + column: "UsersId"); + } + } +} diff --git a/Migrations/20221106062917_AddJoinTableId.Designer.cs b/Migrations/20221106062917_AddJoinTableId.Designer.cs new file mode 100644 index 0000000..0c6f633 --- /dev/null +++ b/Migrations/20221106062917_AddJoinTableId.Designer.cs @@ -0,0 +1,196 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20221106062917_AddJoinTableId")] + partial class AddJoinTableId + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("YearOfBirth") + .HasColumnType("integer"); + + b.Property("languages") + .IsRequired() + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("bigint"); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnType("bigint"); + + b.HasKey("UserAccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupUserAccounts"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", "Group") + .WithMany("Users") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", "UserAccount") + .WithMany("Groups") + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Navigation("Groups"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221106062917_AddJoinTableId.cs b/Migrations/20221106062917_AddJoinTableId.cs new file mode 100644 index 0000000..b585b43 --- /dev/null +++ b/Migrations/20221106062917_AddJoinTableId.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class AddJoinTableId : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Id", + table: "GroupUserAccounts", + type: "bigint", + nullable: false, + defaultValue: 0L); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Id", + table: "GroupUserAccounts"); + } + } +} diff --git a/Migrations/20221106063041_AddJoinTablePrimaryKey.Designer.cs b/Migrations/20221106063041_AddJoinTablePrimaryKey.Designer.cs new file mode 100644 index 0000000..42930be --- /dev/null +++ b/Migrations/20221106063041_AddJoinTablePrimaryKey.Designer.cs @@ -0,0 +1,196 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20221106063041_AddJoinTablePrimaryKey")] + partial class AddJoinTablePrimaryKey + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("YearOfBirth") + .HasColumnType("integer"); + + b.Property("languages") + .IsRequired() + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("bigint"); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnType("bigint"); + + b.HasKey("UserAccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupUserAccounts"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", "Group") + .WithMany("Users") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", "UserAccount") + .WithMany("Groups") + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Navigation("Groups"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221106063041_AddJoinTablePrimaryKey.cs b/Migrations/20221106063041_AddJoinTablePrimaryKey.cs new file mode 100644 index 0000000..ea5f3d7 --- /dev/null +++ b/Migrations/20221106063041_AddJoinTablePrimaryKey.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class AddJoinTablePrimaryKey : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Migrations/20221106063220_DeleteJoinTableId.Designer.cs b/Migrations/20221106063220_DeleteJoinTableId.Designer.cs new file mode 100644 index 0000000..7ca0cb0 --- /dev/null +++ b/Migrations/20221106063220_DeleteJoinTableId.Designer.cs @@ -0,0 +1,193 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20221106063220_DeleteJoinTableId")] + partial class DeleteJoinTableId + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("YearOfBirth") + .HasColumnType("integer"); + + b.Property("languages") + .IsRequired() + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("bigint"); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.HasKey("UserAccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupUserAccounts"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", "Group") + .WithMany("Users") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", "UserAccount") + .WithMany("Groups") + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Navigation("Groups"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221106063220_DeleteJoinTableId.cs b/Migrations/20221106063220_DeleteJoinTableId.cs new file mode 100644 index 0000000..20cea64 --- /dev/null +++ b/Migrations/20221106063220_DeleteJoinTableId.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class DeleteJoinTableId : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Id", + table: "GroupUserAccounts"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Id", + table: "GroupUserAccounts", + type: "bigint", + nullable: false, + defaultValue: 0L); + } + } +} diff --git a/Migrations/20221106063641_AddNullableFields.Designer.cs b/Migrations/20221106063641_AddNullableFields.Designer.cs new file mode 100644 index 0000000..c09fe61 --- /dev/null +++ b/Migrations/20221106063641_AddNullableFields.Designer.cs @@ -0,0 +1,193 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20221106063641_AddNullableFields")] + partial class AddNullableFields + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("YearOfBirth") + .HasColumnType("integer"); + + b.Property("languages") + .IsRequired() + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("bigint"); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.HasKey("UserAccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupUserAccounts"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", "Group") + .WithMany("Users") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", "UserAccount") + .WithMany("Groups") + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Navigation("Groups"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221106063641_AddNullableFields.cs b/Migrations/20221106063641_AddNullableFields.cs new file mode 100644 index 0000000..a860b2f --- /dev/null +++ b/Migrations/20221106063641_AddNullableFields.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class AddNullableFields : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Migrations/LibraryContextModelSnapshot.cs b/Migrations/LibraryContextModelSnapshot.cs index 0fa3e9b..a523712 100644 --- a/Migrations/LibraryContextModelSnapshot.cs +++ b/Migrations/LibraryContextModelSnapshot.cs @@ -31,15 +31,19 @@ namespace LibraryAPI.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Country") + .IsRequired() .HasColumnType("text"); b.Property("Name") - .HasColumnType("text"); + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); b.Property("YearOfBirth") .HasColumnType("integer"); b.Property("languages") + .IsRequired() .HasColumnType("text[]"); b.HasKey("Id"); @@ -62,16 +66,20 @@ namespace LibraryAPI.Migrations .HasColumnType("integer"); b.Property("Genres") + .IsRequired() .HasColumnType("text[]"); b.Property("ISBN") + .IsRequired() .HasColumnType("text"); b.Property("PublicationYear") .HasColumnType("integer"); b.Property("Title") - .HasColumnType("text"); + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); b.HasKey("Id"); @@ -80,6 +88,59 @@ namespace LibraryAPI.Migrations b.ToTable("Books"); }); + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.HasKey("UserAccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupUserAccounts"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + modelBuilder.Entity("LibraryAPI.Models.Book", b => { b.HasOne("LibraryAPI.Models.Author", "Author") @@ -91,10 +152,39 @@ namespace LibraryAPI.Migrations b.Navigation("Author"); }); + modelBuilder.Entity("LibraryAPI.Models.GroupUserAccount", b => + { + b.HasOne("LibraryAPI.Models.Group", "Group") + .WithMany("Users") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LibraryAPI.Models.UserAccount", "UserAccount") + .WithMany("Groups") + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("UserAccount"); + }); + modelBuilder.Entity("LibraryAPI.Models.Author", b => { b.Navigation("Books"); }); + + modelBuilder.Entity("LibraryAPI.Models.Group", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("LibraryAPI.Models.UserAccount", b => + { + b.Navigation("Groups"); + }); #pragma warning restore 612, 618 } } -- cgit v1.2.3