// using System; using DbConnect.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace DbConnect.Migrations { [DbContext(typeof(AppDbContext))] [Migration("20260506030549_InitialPostgres")] partial class InitialPostgres { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "9.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("BookCategory", b => { b.Property("BookId") .HasColumnType("integer"); b.Property("CategoryId") .HasColumnType("integer"); b.HasKey("BookId", "CategoryId") .HasName("PK__BookCate__9C7051A74E7D221D"); b.HasIndex("CategoryId"); b.ToTable("BookCategories", (string)null); }); modelBuilder.Entity("DbConnect.Entities.Book", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("integer"); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Author") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("AvailableCopies") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(1); b.Property("CoverUrl") .HasColumnType("text"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp") .HasDefaultValueSql("now()"); b.Property("Description") .HasColumnType("text"); b.Property("IsActive") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(true); b.Property("Isbn") .IsRequired() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasColumnName("ISBN"); b.Property("Status") .IsRequired() .ValueGeneratedOnAdd() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasDefaultValue("Available"); b.Property("Title") .IsRequired() .HasMaxLength(200) .HasColumnType("character varying(200)"); b.Property("TotalCopies") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(1); b.Property("UpdatedAt") .HasColumnType("timestamp"); b.HasKey("Id") .HasName("PK__Books__3214EC07AE1974C8"); b.HasIndex(new[] { "Isbn" }, "UQ__Books__447D36EA79CF66CE") .IsUnique(); b.ToTable("Books"); }); modelBuilder.Entity("DbConnect.Entities.Borrowing", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasDefaultValueSql("gen_random_uuid()"); b.Property("BookId") .HasColumnType("integer"); b.Property("BorrowDate") .ValueGeneratedOnAdd() .HasColumnType("timestamp") .HasDefaultValueSql("now()"); b.Property("DueDate") .HasColumnType("timestamp"); b.Property("FineAmount") .HasColumnType("decimal(10, 2)"); b.Property("IsFinePaid") .HasColumnType("boolean"); b.Property("ReturnDate") .HasColumnType("timestamp"); b.Property("Status") .IsRequired() .ValueGeneratedOnAdd() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasDefaultValue("Active"); b.Property("UserId") .HasColumnType("uuid"); b.HasKey("Id"); b.HasIndex("BookId"); b.HasIndex("UserId"); b.ToTable("Borrowings"); }); modelBuilder.Entity("DbConnect.Entities.Category", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("integer"); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Name") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.HasKey("Id") .HasName("PK__Categori__3214EC0751B5797D"); b.HasIndex(new[] { "Name" }, "UQ__Categori__737584F622B16D3A") .IsUnique(); b.ToTable("Categories"); }); modelBuilder.Entity("DbConnect.Entities.Membership", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("integer"); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("BorrowingDays") .HasColumnType("integer"); b.Property("DurationMonths") .HasColumnType("integer"); b.Property("MaxBooks") .HasColumnType("integer"); b.Property("Price") .HasColumnType("decimal(10, 2)"); b.Property("RewardId") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("Type") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.HasKey("Id") .HasName("PK__Membersh__3214EC07A6F5A55F"); b.HasIndex(new[] { "Type" }, "IX_Memberships_Type") .IsUnique(); b.ToTable("Memberships"); }); modelBuilder.Entity("DbConnect.Entities.Notification", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("integer"); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("ActionLink") .HasMaxLength(500) .HasColumnType("character varying(500)"); b.Property("ActionText") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp") .HasDefaultValueSql("now()"); b.Property("IsRead") .HasColumnType("boolean"); b.Property("Message") .IsRequired() .HasMaxLength(1000) .HasColumnType("character varying(1000)"); b.Property("Title") .IsRequired() .HasMaxLength(200) .HasColumnType("character varying(200)"); b.Property("Type") .IsRequired() .ValueGeneratedOnAdd() .HasMaxLength(50) .HasColumnType("character varying(50)") .HasDefaultValue("Info"); b.Property("UserId") .HasColumnType("uuid"); b.HasKey("Id"); b.HasIndex(new[] { "UserId" }, "IX_Notifications_UserId"); b.ToTable("Notifications"); }); modelBuilder.Entity("DbConnect.Entities.User", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasDefaultValueSql("gen_random_uuid()"); b.Property("Address") .HasMaxLength(255) .HasColumnType("character varying(255)"); b.Property("BanStatus") .HasColumnType("boolean"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp") .HasDefaultValueSql("now()"); b.Property("Email") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("FcmToken") .HasMaxLength(500) .HasColumnType("character varying(500)"); b.Property("FullName") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("IsActive") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(true); b.Property("PasswordHash") .IsRequired() .HasColumnType("text"); b.Property("PhoneNumber") .HasMaxLength(20) .HasColumnType("character varying(20)"); b.Property("Role") .IsRequired() .ValueGeneratedOnAdd() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasDefaultValue("User"); b.Property("StudentId") .HasMaxLength(20) .HasColumnType("character varying(20)"); b.Property("SuspensionEndDate") .HasColumnType("timestamp"); b.Property("UpdatedAt") .HasColumnType("timestamp"); b.HasKey("Id"); b.HasIndex(new[] { "Email" }, "UQ_Users_Email") .IsUnique(); b.ToTable("Users"); }); modelBuilder.Entity("DbConnect.Entities.UserSubscription", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasDefaultValueSql("gen_random_uuid()"); b.Property("ExpiryDate") .HasColumnType("timestamp"); b.Property("ExternalRedemptionId") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("IsActive") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(true); b.Property("MembershipId") .HasColumnType("integer"); b.Property("StartDate") .HasColumnType("timestamp"); b.Property("Status") .IsRequired() .ValueGeneratedOnAdd() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasDefaultValue("Active"); b.Property("UserId") .HasColumnType("uuid"); b.HasKey("Id"); b.HasIndex("MembershipId"); b.HasIndex("UserId"); b.ToTable("UserSubscriptions"); }); modelBuilder.Entity("DbConnect.Entities.WishlistItem", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("integer"); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AddedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp") .HasDefaultValueSql("now()"); b.Property("BookId") .HasColumnType("integer"); b.Property("UserId") .HasColumnType("uuid"); b.HasKey("Id"); b.HasIndex(new[] { "BookId" }, "IX_WishlistItems_BookId"); b.HasIndex(new[] { "UserId" }, "IX_WishlistItems_UserId"); b.ToTable("WishlistItems"); }); modelBuilder.Entity("BookCategory", b => { b.HasOne("DbConnect.Entities.Book", null) .WithMany() .HasForeignKey("BookId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("FK_BookCategories_Books"); b.HasOne("DbConnect.Entities.Category", null) .WithMany() .HasForeignKey("CategoryId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("FK_BookCategories_Categories"); }); modelBuilder.Entity("DbConnect.Entities.Borrowing", b => { b.HasOne("DbConnect.Entities.Book", "Book") .WithMany("Borrowings") .HasForeignKey("BookId") .IsRequired() .HasConstraintName("FK_Borrowings_Books"); b.HasOne("DbConnect.Entities.User", "User") .WithMany("Borrowings") .HasForeignKey("UserId") .IsRequired() .HasConstraintName("FK_Borrowings_Users"); b.Navigation("Book"); b.Navigation("User"); }); modelBuilder.Entity("DbConnect.Entities.Notification", b => { b.HasOne("DbConnect.Entities.User", "User") .WithMany("Notifications") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("FK_Notifications_Users"); b.Navigation("User"); }); modelBuilder.Entity("DbConnect.Entities.UserSubscription", b => { b.HasOne("DbConnect.Entities.Membership", "Membership") .WithMany("UserSubscriptions") .HasForeignKey("MembershipId") .IsRequired() .HasConstraintName("FK_UserSubscriptions_Memberships"); b.HasOne("DbConnect.Entities.User", "User") .WithMany("UserSubscriptions") .HasForeignKey("UserId") .IsRequired() .HasConstraintName("FK_UserSubscriptions_Users"); b.Navigation("Membership"); b.Navigation("User"); }); modelBuilder.Entity("DbConnect.Entities.WishlistItem", b => { b.HasOne("DbConnect.Entities.Book", "Book") .WithMany("WishlistItems") .HasForeignKey("BookId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("FK_WishlistItems_Books"); b.HasOne("DbConnect.Entities.User", "User") .WithMany("WishlistItems") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("FK_WishlistItems_Users"); b.Navigation("Book"); b.Navigation("User"); }); modelBuilder.Entity("DbConnect.Entities.Book", b => { b.Navigation("Borrowings"); b.Navigation("WishlistItems"); }); modelBuilder.Entity("DbConnect.Entities.Membership", b => { b.Navigation("UserSubscriptions"); }); modelBuilder.Entity("DbConnect.Entities.User", b => { b.Navigation("Borrowings"); b.Navigation("Notifications"); b.Navigation("UserSubscriptions"); b.Navigation("WishlistItems"); }); #pragma warning restore 612, 618 } } }