Spaces:
Sleeping
Sleeping
Yuyuqt commited on
Commit ·
ed77e1a
1
Parent(s): cb5cb0f
fix: changed to postgresql
Browse files- Backend/Backend.csproj +1 -0
- Backend/Program.cs +2 -1
- Backend/appsettings.json +2 -1
- DbConnect/Data/AppDbContext.cs +21 -21
- DbConnect/DbConnect.csproj +3 -2
- DbConnect/Migrations/20260506030549_InitialPostgres.Designer.cs +526 -0
- DbConnect/Migrations/20260506030549_InitialPostgres.cs +323 -0
- DbConnect/Migrations/AppDbContextModelSnapshot.cs +523 -0
Backend/Backend.csproj
CHANGED
|
@@ -14,6 +14,7 @@
|
|
| 14 |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
| 15 |
<PrivateAssets>all</PrivateAssets>
|
| 16 |
</PackageReference>
|
|
|
|
| 17 |
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
| 18 |
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.17.0" />
|
| 19 |
</ItemGroup>
|
|
|
|
| 14 |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
| 15 |
<PrivateAssets>all</PrivateAssets>
|
| 16 |
</PackageReference>
|
| 17 |
+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0" />
|
| 18 |
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
| 19 |
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.17.0" />
|
| 20 |
</ItemGroup>
|
Backend/Program.cs
CHANGED
|
@@ -17,6 +17,7 @@ using Backend.Features.Wishlist;
|
|
| 17 |
using FirebaseAdmin;
|
| 18 |
using Google.Apis.Auth.OAuth2;
|
| 19 |
|
|
|
|
| 20 |
var builder = WebApplication.CreateBuilder(args);
|
| 21 |
|
| 22 |
// Firebase Admin SDK Initialization
|
|
@@ -66,7 +67,7 @@ builder.Services.AddSwaggerGen(c =>
|
|
| 66 |
});
|
| 67 |
|
| 68 |
builder.Services.AddDbContext<AppDbContext>(options =>
|
| 69 |
-
options.
|
| 70 |
|
| 71 |
// Register Services
|
| 72 |
builder.Services.AddScoped<IAuthService, AuthService>();
|
|
|
|
| 17 |
using FirebaseAdmin;
|
| 18 |
using Google.Apis.Auth.OAuth2;
|
| 19 |
|
| 20 |
+
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
| 21 |
var builder = WebApplication.CreateBuilder(args);
|
| 22 |
|
| 23 |
// Firebase Admin SDK Initialization
|
|
|
|
| 67 |
});
|
| 68 |
|
| 69 |
builder.Services.AddDbContext<AppDbContext>(options =>
|
| 70 |
+
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
|
| 71 |
|
| 72 |
// Register Services
|
| 73 |
builder.Services.AddScoped<IAuthService, AuthService>();
|
Backend/appsettings.json
CHANGED
|
@@ -8,7 +8,8 @@
|
|
| 8 |
"AllowedHosts": "*",
|
| 9 |
"ConnectionStrings": {
|
| 10 |
//"MssqlConnection": "Server=DESKTOP-BP9A061;Database=LibraryManagement;User Id=sa;Password=sasa@123;TrustServerCertificate=True;"
|
| 11 |
-
"MssqlConnection": "Server=.;Database=LibraryManagement;User Id=sa;Password=sasa@123;TrustServerCertificate=True;"
|
|
|
|
| 12 |
},
|
| 13 |
"Jwt": {
|
| 14 |
"Secret": "YourSuperSecretKeyForLibraryManagementSystem_AtLeast32CharsLong",
|
|
|
|
| 8 |
"AllowedHosts": "*",
|
| 9 |
"ConnectionStrings": {
|
| 10 |
//"MssqlConnection": "Server=DESKTOP-BP9A061;Database=LibraryManagement;User Id=sa;Password=sasa@123;TrustServerCertificate=True;"
|
| 11 |
+
"MssqlConnection": "Server=.;Database=LibraryManagement;User Id=sa;Password=sasa@123;TrustServerCertificate=True;",
|
| 12 |
+
"DefaultConnection": "Host=aws-1-ap-southeast-1.pooler.supabase.com;Port=5432;Database=postgres;Username=postgres.zblltmkvarlhztnvxygx;Password=Yurina#161020;Pooling=true;"
|
| 13 |
},
|
| 14 |
"Jwt": {
|
| 15 |
"Secret": "YourSuperSecretKeyForLibraryManagementSystem_AtLeast32CharsLong",
|
DbConnect/Data/AppDbContext.cs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
using System.Collections.Generic;
|
| 3 |
using DbConnect.Entities;
|
| 4 |
using Microsoft.EntityFrameworkCore;
|
|
@@ -39,8 +39,8 @@ public partial class AppDbContext : DbContext
|
|
| 39 |
entity.Property(e => e.Author).HasMaxLength(100);
|
| 40 |
entity.Property(e => e.AvailableCopies).HasDefaultValue(1);
|
| 41 |
entity.Property(e => e.CreatedAt)
|
| 42 |
-
.HasDefaultValueSql("(
|
| 43 |
-
.HasColumnType("
|
| 44 |
entity.Property(e => e.IsActive).HasDefaultValue(true);
|
| 45 |
entity.Property(e => e.Isbn)
|
| 46 |
.HasMaxLength(20)
|
|
@@ -50,7 +50,7 @@ public partial class AppDbContext : DbContext
|
|
| 50 |
.HasDefaultValue("Available");
|
| 51 |
entity.Property(e => e.Title).HasMaxLength(200);
|
| 52 |
entity.Property(e => e.TotalCopies).HasDefaultValue(1);
|
| 53 |
-
entity.Property(e => e.UpdatedAt).HasColumnType("
|
| 54 |
|
| 55 |
entity.HasMany(d => d.Categories).WithMany(p => p.Books)
|
| 56 |
.UsingEntity<Dictionary<string, object>>(
|
|
@@ -70,13 +70,13 @@ public partial class AppDbContext : DbContext
|
|
| 70 |
|
| 71 |
modelBuilder.Entity<Borrowing>(entity =>
|
| 72 |
{
|
| 73 |
-
entity.Property(e => e.Id).HasDefaultValueSql("(
|
| 74 |
entity.Property(e => e.BorrowDate)
|
| 75 |
-
.HasDefaultValueSql("(
|
| 76 |
-
.HasColumnType("
|
| 77 |
-
entity.Property(e => e.DueDate).HasColumnType("
|
| 78 |
entity.Property(e => e.FineAmount).HasColumnType("decimal(10, 2)");
|
| 79 |
-
entity.Property(e => e.ReturnDate).HasColumnType("
|
| 80 |
entity.Property(e => e.Status)
|
| 81 |
.HasMaxLength(20)
|
| 82 |
.HasDefaultValue("Active");
|
|
@@ -119,8 +119,8 @@ public partial class AppDbContext : DbContext
|
|
| 119 |
entity.Property(e => e.ActionLink).HasMaxLength(500);
|
| 120 |
entity.Property(e => e.ActionText).HasMaxLength(100);
|
| 121 |
entity.Property(e => e.CreatedAt)
|
| 122 |
-
.HasDefaultValueSql("(
|
| 123 |
-
.HasColumnType("
|
| 124 |
entity.Property(e => e.Message).HasMaxLength(1000);
|
| 125 |
entity.Property(e => e.Title).HasMaxLength(200);
|
| 126 |
entity.Property(e => e.Type)
|
|
@@ -136,11 +136,11 @@ public partial class AppDbContext : DbContext
|
|
| 136 |
{
|
| 137 |
entity.HasIndex(e => e.Email, "UQ_Users_Email").IsUnique();
|
| 138 |
|
| 139 |
-
entity.Property(e => e.Id).HasDefaultValueSql("(
|
| 140 |
entity.Property(e => e.Address).HasMaxLength(255);
|
| 141 |
entity.Property(e => e.CreatedAt)
|
| 142 |
-
.HasDefaultValueSql("(
|
| 143 |
-
.HasColumnType("
|
| 144 |
entity.Property(e => e.Email).HasMaxLength(100);
|
| 145 |
entity.Property(e => e.FcmToken).HasMaxLength(500);
|
| 146 |
entity.Property(e => e.FullName).HasMaxLength(100);
|
|
@@ -150,17 +150,17 @@ public partial class AppDbContext : DbContext
|
|
| 150 |
.HasMaxLength(20)
|
| 151 |
.HasDefaultValue("User");
|
| 152 |
entity.Property(e => e.StudentId).HasMaxLength(20);
|
| 153 |
-
entity.Property(e => e.SuspensionEndDate).HasColumnType("
|
| 154 |
-
entity.Property(e => e.UpdatedAt).HasColumnType("
|
| 155 |
});
|
| 156 |
|
| 157 |
modelBuilder.Entity<UserSubscription>(entity =>
|
| 158 |
{
|
| 159 |
-
entity.Property(e => e.Id).HasDefaultValueSql("(
|
| 160 |
-
entity.Property(e => e.ExpiryDate).HasColumnType("
|
| 161 |
entity.Property(e => e.ExternalRedemptionId).HasMaxLength(100);
|
| 162 |
entity.Property(e => e.IsActive).HasDefaultValue(true);
|
| 163 |
-
entity.Property(e => e.StartDate).HasColumnType("
|
| 164 |
entity.Property(e => e.Status)
|
| 165 |
.HasMaxLength(20)
|
| 166 |
.HasDefaultValue("Active");
|
|
@@ -183,8 +183,8 @@ public partial class AppDbContext : DbContext
|
|
| 183 |
entity.HasIndex(e => e.UserId, "IX_WishlistItems_UserId");
|
| 184 |
|
| 185 |
entity.Property(e => e.AddedAt)
|
| 186 |
-
.HasDefaultValueSql("(
|
| 187 |
-
.HasColumnType("
|
| 188 |
|
| 189 |
entity.HasOne(d => d.Book).WithMany(p => p.WishlistItems)
|
| 190 |
.HasForeignKey(d => d.BookId)
|
|
|
|
| 1 |
+
using System;
|
| 2 |
using System.Collections.Generic;
|
| 3 |
using DbConnect.Entities;
|
| 4 |
using Microsoft.EntityFrameworkCore;
|
|
|
|
| 39 |
entity.Property(e => e.Author).HasMaxLength(100);
|
| 40 |
entity.Property(e => e.AvailableCopies).HasDefaultValue(1);
|
| 41 |
entity.Property(e => e.CreatedAt)
|
| 42 |
+
.HasDefaultValueSql("now()")
|
| 43 |
+
.HasColumnType("timestamp");
|
| 44 |
entity.Property(e => e.IsActive).HasDefaultValue(true);
|
| 45 |
entity.Property(e => e.Isbn)
|
| 46 |
.HasMaxLength(20)
|
|
|
|
| 50 |
.HasDefaultValue("Available");
|
| 51 |
entity.Property(e => e.Title).HasMaxLength(200);
|
| 52 |
entity.Property(e => e.TotalCopies).HasDefaultValue(1);
|
| 53 |
+
entity.Property(e => e.UpdatedAt).HasColumnType("timestamp");
|
| 54 |
|
| 55 |
entity.HasMany(d => d.Categories).WithMany(p => p.Books)
|
| 56 |
.UsingEntity<Dictionary<string, object>>(
|
|
|
|
| 70 |
|
| 71 |
modelBuilder.Entity<Borrowing>(entity =>
|
| 72 |
{
|
| 73 |
+
entity.Property(e => e.Id).HasDefaultValueSql("gen_random_uuid()");
|
| 74 |
entity.Property(e => e.BorrowDate)
|
| 75 |
+
.HasDefaultValueSql("now()")
|
| 76 |
+
.HasColumnType("timestamp");
|
| 77 |
+
entity.Property(e => e.DueDate).HasColumnType("timestamp");
|
| 78 |
entity.Property(e => e.FineAmount).HasColumnType("decimal(10, 2)");
|
| 79 |
+
entity.Property(e => e.ReturnDate).HasColumnType("timestamp");
|
| 80 |
entity.Property(e => e.Status)
|
| 81 |
.HasMaxLength(20)
|
| 82 |
.HasDefaultValue("Active");
|
|
|
|
| 119 |
entity.Property(e => e.ActionLink).HasMaxLength(500);
|
| 120 |
entity.Property(e => e.ActionText).HasMaxLength(100);
|
| 121 |
entity.Property(e => e.CreatedAt)
|
| 122 |
+
.HasDefaultValueSql("now()")
|
| 123 |
+
.HasColumnType("timestamp");
|
| 124 |
entity.Property(e => e.Message).HasMaxLength(1000);
|
| 125 |
entity.Property(e => e.Title).HasMaxLength(200);
|
| 126 |
entity.Property(e => e.Type)
|
|
|
|
| 136 |
{
|
| 137 |
entity.HasIndex(e => e.Email, "UQ_Users_Email").IsUnique();
|
| 138 |
|
| 139 |
+
entity.Property(e => e.Id).HasDefaultValueSql("gen_random_uuid()");
|
| 140 |
entity.Property(e => e.Address).HasMaxLength(255);
|
| 141 |
entity.Property(e => e.CreatedAt)
|
| 142 |
+
.HasDefaultValueSql("now()")
|
| 143 |
+
.HasColumnType("timestamp");
|
| 144 |
entity.Property(e => e.Email).HasMaxLength(100);
|
| 145 |
entity.Property(e => e.FcmToken).HasMaxLength(500);
|
| 146 |
entity.Property(e => e.FullName).HasMaxLength(100);
|
|
|
|
| 150 |
.HasMaxLength(20)
|
| 151 |
.HasDefaultValue("User");
|
| 152 |
entity.Property(e => e.StudentId).HasMaxLength(20);
|
| 153 |
+
entity.Property(e => e.SuspensionEndDate).HasColumnType("timestamp");
|
| 154 |
+
entity.Property(e => e.UpdatedAt).HasColumnType("timestamp");
|
| 155 |
});
|
| 156 |
|
| 157 |
modelBuilder.Entity<UserSubscription>(entity =>
|
| 158 |
{
|
| 159 |
+
entity.Property(e => e.Id).HasDefaultValueSql("gen_random_uuid()");
|
| 160 |
+
entity.Property(e => e.ExpiryDate).HasColumnType("timestamp");
|
| 161 |
entity.Property(e => e.ExternalRedemptionId).HasMaxLength(100);
|
| 162 |
entity.Property(e => e.IsActive).HasDefaultValue(true);
|
| 163 |
+
entity.Property(e => e.StartDate).HasColumnType("timestamp");
|
| 164 |
entity.Property(e => e.Status)
|
| 165 |
.HasMaxLength(20)
|
| 166 |
.HasDefaultValue("Active");
|
|
|
|
| 183 |
entity.HasIndex(e => e.UserId, "IX_WishlistItems_UserId");
|
| 184 |
|
| 185 |
entity.Property(e => e.AddedAt)
|
| 186 |
+
.HasDefaultValueSql("now()")
|
| 187 |
+
.HasColumnType("timestamp");
|
| 188 |
|
| 189 |
entity.HasOne(d => d.Book).WithMany(p => p.WishlistItems)
|
| 190 |
.HasForeignKey(d => d.BookId)
|
DbConnect/DbConnect.csproj
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
<PropertyGroup>
|
| 4 |
<TargetFramework>net8.0</TargetFramework>
|
|
@@ -12,11 +12,12 @@
|
|
| 12 |
<PrivateAssets>all</PrivateAssets>
|
| 13 |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
| 14 |
</PackageReference>
|
| 15 |
-
|
| 16 |
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
|
| 17 |
<PrivateAssets>all</PrivateAssets>
|
| 18 |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
| 19 |
</PackageReference>
|
|
|
|
| 20 |
</ItemGroup>
|
| 21 |
|
| 22 |
</Project>
|
|
|
|
| 1 |
+
<Project Sdk="Microsoft.NET.Sdk">
|
| 2 |
|
| 3 |
<PropertyGroup>
|
| 4 |
<TargetFramework>net8.0</TargetFramework>
|
|
|
|
| 12 |
<PrivateAssets>all</PrivateAssets>
|
| 13 |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
| 14 |
</PackageReference>
|
| 15 |
+
|
| 16 |
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
|
| 17 |
<PrivateAssets>all</PrivateAssets>
|
| 18 |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
| 19 |
</PackageReference>
|
| 20 |
+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0" />
|
| 21 |
</ItemGroup>
|
| 22 |
|
| 23 |
</Project>
|
DbConnect/Migrations/20260506030549_InitialPostgres.Designer.cs
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// <auto-generated />
|
| 2 |
+
using System;
|
| 3 |
+
using DbConnect.Data;
|
| 4 |
+
using Microsoft.EntityFrameworkCore;
|
| 5 |
+
using Microsoft.EntityFrameworkCore.Infrastructure;
|
| 6 |
+
using Microsoft.EntityFrameworkCore.Migrations;
|
| 7 |
+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
| 8 |
+
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
| 9 |
+
|
| 10 |
+
#nullable disable
|
| 11 |
+
|
| 12 |
+
namespace DbConnect.Migrations
|
| 13 |
+
{
|
| 14 |
+
[DbContext(typeof(AppDbContext))]
|
| 15 |
+
[Migration("20260506030549_InitialPostgres")]
|
| 16 |
+
partial class InitialPostgres
|
| 17 |
+
{
|
| 18 |
+
/// <inheritdoc />
|
| 19 |
+
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
| 20 |
+
{
|
| 21 |
+
#pragma warning disable 612, 618
|
| 22 |
+
modelBuilder
|
| 23 |
+
.HasAnnotation("ProductVersion", "9.0.0")
|
| 24 |
+
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
| 25 |
+
|
| 26 |
+
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
| 27 |
+
|
| 28 |
+
modelBuilder.Entity("BookCategory", b =>
|
| 29 |
+
{
|
| 30 |
+
b.Property<int>("BookId")
|
| 31 |
+
.HasColumnType("integer");
|
| 32 |
+
|
| 33 |
+
b.Property<int>("CategoryId")
|
| 34 |
+
.HasColumnType("integer");
|
| 35 |
+
|
| 36 |
+
b.HasKey("BookId", "CategoryId")
|
| 37 |
+
.HasName("PK__BookCate__9C7051A74E7D221D");
|
| 38 |
+
|
| 39 |
+
b.HasIndex("CategoryId");
|
| 40 |
+
|
| 41 |
+
b.ToTable("BookCategories", (string)null);
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
modelBuilder.Entity("DbConnect.Entities.Book", b =>
|
| 45 |
+
{
|
| 46 |
+
b.Property<int>("Id")
|
| 47 |
+
.ValueGeneratedOnAdd()
|
| 48 |
+
.HasColumnType("integer");
|
| 49 |
+
|
| 50 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 51 |
+
|
| 52 |
+
b.Property<string>("Author")
|
| 53 |
+
.IsRequired()
|
| 54 |
+
.HasMaxLength(100)
|
| 55 |
+
.HasColumnType("character varying(100)");
|
| 56 |
+
|
| 57 |
+
b.Property<int>("AvailableCopies")
|
| 58 |
+
.ValueGeneratedOnAdd()
|
| 59 |
+
.HasColumnType("integer")
|
| 60 |
+
.HasDefaultValue(1);
|
| 61 |
+
|
| 62 |
+
b.Property<string>("CoverUrl")
|
| 63 |
+
.HasColumnType("text");
|
| 64 |
+
|
| 65 |
+
b.Property<DateTime>("CreatedAt")
|
| 66 |
+
.ValueGeneratedOnAdd()
|
| 67 |
+
.HasColumnType("timestamp")
|
| 68 |
+
.HasDefaultValueSql("now()");
|
| 69 |
+
|
| 70 |
+
b.Property<string>("Description")
|
| 71 |
+
.HasColumnType("text");
|
| 72 |
+
|
| 73 |
+
b.Property<bool>("IsActive")
|
| 74 |
+
.ValueGeneratedOnAdd()
|
| 75 |
+
.HasColumnType("boolean")
|
| 76 |
+
.HasDefaultValue(true);
|
| 77 |
+
|
| 78 |
+
b.Property<string>("Isbn")
|
| 79 |
+
.IsRequired()
|
| 80 |
+
.HasMaxLength(20)
|
| 81 |
+
.HasColumnType("character varying(20)")
|
| 82 |
+
.HasColumnName("ISBN");
|
| 83 |
+
|
| 84 |
+
b.Property<string>("Status")
|
| 85 |
+
.IsRequired()
|
| 86 |
+
.ValueGeneratedOnAdd()
|
| 87 |
+
.HasMaxLength(20)
|
| 88 |
+
.HasColumnType("character varying(20)")
|
| 89 |
+
.HasDefaultValue("Available");
|
| 90 |
+
|
| 91 |
+
b.Property<string>("Title")
|
| 92 |
+
.IsRequired()
|
| 93 |
+
.HasMaxLength(200)
|
| 94 |
+
.HasColumnType("character varying(200)");
|
| 95 |
+
|
| 96 |
+
b.Property<int>("TotalCopies")
|
| 97 |
+
.ValueGeneratedOnAdd()
|
| 98 |
+
.HasColumnType("integer")
|
| 99 |
+
.HasDefaultValue(1);
|
| 100 |
+
|
| 101 |
+
b.Property<DateTime?>("UpdatedAt")
|
| 102 |
+
.HasColumnType("timestamp");
|
| 103 |
+
|
| 104 |
+
b.HasKey("Id")
|
| 105 |
+
.HasName("PK__Books__3214EC07AE1974C8");
|
| 106 |
+
|
| 107 |
+
b.HasIndex(new[] { "Isbn" }, "UQ__Books__447D36EA79CF66CE")
|
| 108 |
+
.IsUnique();
|
| 109 |
+
|
| 110 |
+
b.ToTable("Books");
|
| 111 |
+
});
|
| 112 |
+
|
| 113 |
+
modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
|
| 114 |
+
{
|
| 115 |
+
b.Property<Guid>("Id")
|
| 116 |
+
.ValueGeneratedOnAdd()
|
| 117 |
+
.HasColumnType("uuid")
|
| 118 |
+
.HasDefaultValueSql("gen_random_uuid()");
|
| 119 |
+
|
| 120 |
+
b.Property<int>("BookId")
|
| 121 |
+
.HasColumnType("integer");
|
| 122 |
+
|
| 123 |
+
b.Property<DateTime>("BorrowDate")
|
| 124 |
+
.ValueGeneratedOnAdd()
|
| 125 |
+
.HasColumnType("timestamp")
|
| 126 |
+
.HasDefaultValueSql("now()");
|
| 127 |
+
|
| 128 |
+
b.Property<DateTime>("DueDate")
|
| 129 |
+
.HasColumnType("timestamp");
|
| 130 |
+
|
| 131 |
+
b.Property<decimal>("FineAmount")
|
| 132 |
+
.HasColumnType("decimal(10, 2)");
|
| 133 |
+
|
| 134 |
+
b.Property<bool>("IsFinePaid")
|
| 135 |
+
.HasColumnType("boolean");
|
| 136 |
+
|
| 137 |
+
b.Property<DateTime?>("ReturnDate")
|
| 138 |
+
.HasColumnType("timestamp");
|
| 139 |
+
|
| 140 |
+
b.Property<string>("Status")
|
| 141 |
+
.IsRequired()
|
| 142 |
+
.ValueGeneratedOnAdd()
|
| 143 |
+
.HasMaxLength(20)
|
| 144 |
+
.HasColumnType("character varying(20)")
|
| 145 |
+
.HasDefaultValue("Active");
|
| 146 |
+
|
| 147 |
+
b.Property<Guid>("UserId")
|
| 148 |
+
.HasColumnType("uuid");
|
| 149 |
+
|
| 150 |
+
b.HasKey("Id");
|
| 151 |
+
|
| 152 |
+
b.HasIndex("BookId");
|
| 153 |
+
|
| 154 |
+
b.HasIndex("UserId");
|
| 155 |
+
|
| 156 |
+
b.ToTable("Borrowings");
|
| 157 |
+
});
|
| 158 |
+
|
| 159 |
+
modelBuilder.Entity("DbConnect.Entities.Category", b =>
|
| 160 |
+
{
|
| 161 |
+
b.Property<int>("Id")
|
| 162 |
+
.ValueGeneratedOnAdd()
|
| 163 |
+
.HasColumnType("integer");
|
| 164 |
+
|
| 165 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 166 |
+
|
| 167 |
+
b.Property<string>("Name")
|
| 168 |
+
.IsRequired()
|
| 169 |
+
.HasMaxLength(100)
|
| 170 |
+
.HasColumnType("character varying(100)");
|
| 171 |
+
|
| 172 |
+
b.HasKey("Id")
|
| 173 |
+
.HasName("PK__Categori__3214EC0751B5797D");
|
| 174 |
+
|
| 175 |
+
b.HasIndex(new[] { "Name" }, "UQ__Categori__737584F622B16D3A")
|
| 176 |
+
.IsUnique();
|
| 177 |
+
|
| 178 |
+
b.ToTable("Categories");
|
| 179 |
+
});
|
| 180 |
+
|
| 181 |
+
modelBuilder.Entity("DbConnect.Entities.Membership", b =>
|
| 182 |
+
{
|
| 183 |
+
b.Property<int>("Id")
|
| 184 |
+
.ValueGeneratedOnAdd()
|
| 185 |
+
.HasColumnType("integer");
|
| 186 |
+
|
| 187 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 188 |
+
|
| 189 |
+
b.Property<int>("BorrowingDays")
|
| 190 |
+
.HasColumnType("integer");
|
| 191 |
+
|
| 192 |
+
b.Property<int>("DurationMonths")
|
| 193 |
+
.HasColumnType("integer");
|
| 194 |
+
|
| 195 |
+
b.Property<int>("MaxBooks")
|
| 196 |
+
.HasColumnType("integer");
|
| 197 |
+
|
| 198 |
+
b.Property<decimal>("Price")
|
| 199 |
+
.HasColumnType("decimal(10, 2)");
|
| 200 |
+
|
| 201 |
+
b.Property<string>("RewardId")
|
| 202 |
+
.HasMaxLength(100)
|
| 203 |
+
.HasColumnType("character varying(100)");
|
| 204 |
+
|
| 205 |
+
b.Property<string>("Type")
|
| 206 |
+
.IsRequired()
|
| 207 |
+
.HasMaxLength(50)
|
| 208 |
+
.HasColumnType("character varying(50)");
|
| 209 |
+
|
| 210 |
+
b.HasKey("Id")
|
| 211 |
+
.HasName("PK__Membersh__3214EC07A6F5A55F");
|
| 212 |
+
|
| 213 |
+
b.HasIndex(new[] { "Type" }, "IX_Memberships_Type")
|
| 214 |
+
.IsUnique();
|
| 215 |
+
|
| 216 |
+
b.ToTable("Memberships");
|
| 217 |
+
});
|
| 218 |
+
|
| 219 |
+
modelBuilder.Entity("DbConnect.Entities.Notification", b =>
|
| 220 |
+
{
|
| 221 |
+
b.Property<int>("Id")
|
| 222 |
+
.ValueGeneratedOnAdd()
|
| 223 |
+
.HasColumnType("integer");
|
| 224 |
+
|
| 225 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 226 |
+
|
| 227 |
+
b.Property<string>("ActionLink")
|
| 228 |
+
.HasMaxLength(500)
|
| 229 |
+
.HasColumnType("character varying(500)");
|
| 230 |
+
|
| 231 |
+
b.Property<string>("ActionText")
|
| 232 |
+
.HasMaxLength(100)
|
| 233 |
+
.HasColumnType("character varying(100)");
|
| 234 |
+
|
| 235 |
+
b.Property<DateTime>("CreatedAt")
|
| 236 |
+
.ValueGeneratedOnAdd()
|
| 237 |
+
.HasColumnType("timestamp")
|
| 238 |
+
.HasDefaultValueSql("now()");
|
| 239 |
+
|
| 240 |
+
b.Property<bool>("IsRead")
|
| 241 |
+
.HasColumnType("boolean");
|
| 242 |
+
|
| 243 |
+
b.Property<string>("Message")
|
| 244 |
+
.IsRequired()
|
| 245 |
+
.HasMaxLength(1000)
|
| 246 |
+
.HasColumnType("character varying(1000)");
|
| 247 |
+
|
| 248 |
+
b.Property<string>("Title")
|
| 249 |
+
.IsRequired()
|
| 250 |
+
.HasMaxLength(200)
|
| 251 |
+
.HasColumnType("character varying(200)");
|
| 252 |
+
|
| 253 |
+
b.Property<string>("Type")
|
| 254 |
+
.IsRequired()
|
| 255 |
+
.ValueGeneratedOnAdd()
|
| 256 |
+
.HasMaxLength(50)
|
| 257 |
+
.HasColumnType("character varying(50)")
|
| 258 |
+
.HasDefaultValue("Info");
|
| 259 |
+
|
| 260 |
+
b.Property<Guid>("UserId")
|
| 261 |
+
.HasColumnType("uuid");
|
| 262 |
+
|
| 263 |
+
b.HasKey("Id");
|
| 264 |
+
|
| 265 |
+
b.HasIndex(new[] { "UserId" }, "IX_Notifications_UserId");
|
| 266 |
+
|
| 267 |
+
b.ToTable("Notifications");
|
| 268 |
+
});
|
| 269 |
+
|
| 270 |
+
modelBuilder.Entity("DbConnect.Entities.User", b =>
|
| 271 |
+
{
|
| 272 |
+
b.Property<Guid>("Id")
|
| 273 |
+
.ValueGeneratedOnAdd()
|
| 274 |
+
.HasColumnType("uuid")
|
| 275 |
+
.HasDefaultValueSql("gen_random_uuid()");
|
| 276 |
+
|
| 277 |
+
b.Property<string>("Address")
|
| 278 |
+
.HasMaxLength(255)
|
| 279 |
+
.HasColumnType("character varying(255)");
|
| 280 |
+
|
| 281 |
+
b.Property<bool?>("BanStatus")
|
| 282 |
+
.HasColumnType("boolean");
|
| 283 |
+
|
| 284 |
+
b.Property<DateTime>("CreatedAt")
|
| 285 |
+
.ValueGeneratedOnAdd()
|
| 286 |
+
.HasColumnType("timestamp")
|
| 287 |
+
.HasDefaultValueSql("now()");
|
| 288 |
+
|
| 289 |
+
b.Property<string>("Email")
|
| 290 |
+
.IsRequired()
|
| 291 |
+
.HasMaxLength(100)
|
| 292 |
+
.HasColumnType("character varying(100)");
|
| 293 |
+
|
| 294 |
+
b.Property<string>("FcmToken")
|
| 295 |
+
.HasMaxLength(500)
|
| 296 |
+
.HasColumnType("character varying(500)");
|
| 297 |
+
|
| 298 |
+
b.Property<string>("FullName")
|
| 299 |
+
.IsRequired()
|
| 300 |
+
.HasMaxLength(100)
|
| 301 |
+
.HasColumnType("character varying(100)");
|
| 302 |
+
|
| 303 |
+
b.Property<bool>("IsActive")
|
| 304 |
+
.ValueGeneratedOnAdd()
|
| 305 |
+
.HasColumnType("boolean")
|
| 306 |
+
.HasDefaultValue(true);
|
| 307 |
+
|
| 308 |
+
b.Property<string>("PasswordHash")
|
| 309 |
+
.IsRequired()
|
| 310 |
+
.HasColumnType("text");
|
| 311 |
+
|
| 312 |
+
b.Property<string>("PhoneNumber")
|
| 313 |
+
.HasMaxLength(20)
|
| 314 |
+
.HasColumnType("character varying(20)");
|
| 315 |
+
|
| 316 |
+
b.Property<string>("Role")
|
| 317 |
+
.IsRequired()
|
| 318 |
+
.ValueGeneratedOnAdd()
|
| 319 |
+
.HasMaxLength(20)
|
| 320 |
+
.HasColumnType("character varying(20)")
|
| 321 |
+
.HasDefaultValue("User");
|
| 322 |
+
|
| 323 |
+
b.Property<string>("StudentId")
|
| 324 |
+
.HasMaxLength(20)
|
| 325 |
+
.HasColumnType("character varying(20)");
|
| 326 |
+
|
| 327 |
+
b.Property<DateTime?>("SuspensionEndDate")
|
| 328 |
+
.HasColumnType("timestamp");
|
| 329 |
+
|
| 330 |
+
b.Property<DateTime?>("UpdatedAt")
|
| 331 |
+
.HasColumnType("timestamp");
|
| 332 |
+
|
| 333 |
+
b.HasKey("Id");
|
| 334 |
+
|
| 335 |
+
b.HasIndex(new[] { "Email" }, "UQ_Users_Email")
|
| 336 |
+
.IsUnique();
|
| 337 |
+
|
| 338 |
+
b.ToTable("Users");
|
| 339 |
+
});
|
| 340 |
+
|
| 341 |
+
modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
|
| 342 |
+
{
|
| 343 |
+
b.Property<Guid>("Id")
|
| 344 |
+
.ValueGeneratedOnAdd()
|
| 345 |
+
.HasColumnType("uuid")
|
| 346 |
+
.HasDefaultValueSql("gen_random_uuid()");
|
| 347 |
+
|
| 348 |
+
b.Property<DateTime>("ExpiryDate")
|
| 349 |
+
.HasColumnType("timestamp");
|
| 350 |
+
|
| 351 |
+
b.Property<string>("ExternalRedemptionId")
|
| 352 |
+
.HasMaxLength(100)
|
| 353 |
+
.HasColumnType("character varying(100)");
|
| 354 |
+
|
| 355 |
+
b.Property<bool>("IsActive")
|
| 356 |
+
.ValueGeneratedOnAdd()
|
| 357 |
+
.HasColumnType("boolean")
|
| 358 |
+
.HasDefaultValue(true);
|
| 359 |
+
|
| 360 |
+
b.Property<int>("MembershipId")
|
| 361 |
+
.HasColumnType("integer");
|
| 362 |
+
|
| 363 |
+
b.Property<DateTime>("StartDate")
|
| 364 |
+
.HasColumnType("timestamp");
|
| 365 |
+
|
| 366 |
+
b.Property<string>("Status")
|
| 367 |
+
.IsRequired()
|
| 368 |
+
.ValueGeneratedOnAdd()
|
| 369 |
+
.HasMaxLength(20)
|
| 370 |
+
.HasColumnType("character varying(20)")
|
| 371 |
+
.HasDefaultValue("Active");
|
| 372 |
+
|
| 373 |
+
b.Property<Guid>("UserId")
|
| 374 |
+
.HasColumnType("uuid");
|
| 375 |
+
|
| 376 |
+
b.HasKey("Id");
|
| 377 |
+
|
| 378 |
+
b.HasIndex("MembershipId");
|
| 379 |
+
|
| 380 |
+
b.HasIndex("UserId");
|
| 381 |
+
|
| 382 |
+
b.ToTable("UserSubscriptions");
|
| 383 |
+
});
|
| 384 |
+
|
| 385 |
+
modelBuilder.Entity("DbConnect.Entities.WishlistItem", b =>
|
| 386 |
+
{
|
| 387 |
+
b.Property<int>("Id")
|
| 388 |
+
.ValueGeneratedOnAdd()
|
| 389 |
+
.HasColumnType("integer");
|
| 390 |
+
|
| 391 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 392 |
+
|
| 393 |
+
b.Property<DateTime>("AddedAt")
|
| 394 |
+
.ValueGeneratedOnAdd()
|
| 395 |
+
.HasColumnType("timestamp")
|
| 396 |
+
.HasDefaultValueSql("now()");
|
| 397 |
+
|
| 398 |
+
b.Property<int>("BookId")
|
| 399 |
+
.HasColumnType("integer");
|
| 400 |
+
|
| 401 |
+
b.Property<Guid>("UserId")
|
| 402 |
+
.HasColumnType("uuid");
|
| 403 |
+
|
| 404 |
+
b.HasKey("Id");
|
| 405 |
+
|
| 406 |
+
b.HasIndex(new[] { "BookId" }, "IX_WishlistItems_BookId");
|
| 407 |
+
|
| 408 |
+
b.HasIndex(new[] { "UserId" }, "IX_WishlistItems_UserId");
|
| 409 |
+
|
| 410 |
+
b.ToTable("WishlistItems");
|
| 411 |
+
});
|
| 412 |
+
|
| 413 |
+
modelBuilder.Entity("BookCategory", b =>
|
| 414 |
+
{
|
| 415 |
+
b.HasOne("DbConnect.Entities.Book", null)
|
| 416 |
+
.WithMany()
|
| 417 |
+
.HasForeignKey("BookId")
|
| 418 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 419 |
+
.IsRequired()
|
| 420 |
+
.HasConstraintName("FK_BookCategories_Books");
|
| 421 |
+
|
| 422 |
+
b.HasOne("DbConnect.Entities.Category", null)
|
| 423 |
+
.WithMany()
|
| 424 |
+
.HasForeignKey("CategoryId")
|
| 425 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 426 |
+
.IsRequired()
|
| 427 |
+
.HasConstraintName("FK_BookCategories_Categories");
|
| 428 |
+
});
|
| 429 |
+
|
| 430 |
+
modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
|
| 431 |
+
{
|
| 432 |
+
b.HasOne("DbConnect.Entities.Book", "Book")
|
| 433 |
+
.WithMany("Borrowings")
|
| 434 |
+
.HasForeignKey("BookId")
|
| 435 |
+
.IsRequired()
|
| 436 |
+
.HasConstraintName("FK_Borrowings_Books");
|
| 437 |
+
|
| 438 |
+
b.HasOne("DbConnect.Entities.User", "User")
|
| 439 |
+
.WithMany("Borrowings")
|
| 440 |
+
.HasForeignKey("UserId")
|
| 441 |
+
.IsRequired()
|
| 442 |
+
.HasConstraintName("FK_Borrowings_Users");
|
| 443 |
+
|
| 444 |
+
b.Navigation("Book");
|
| 445 |
+
|
| 446 |
+
b.Navigation("User");
|
| 447 |
+
});
|
| 448 |
+
|
| 449 |
+
modelBuilder.Entity("DbConnect.Entities.Notification", b =>
|
| 450 |
+
{
|
| 451 |
+
b.HasOne("DbConnect.Entities.User", "User")
|
| 452 |
+
.WithMany("Notifications")
|
| 453 |
+
.HasForeignKey("UserId")
|
| 454 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 455 |
+
.IsRequired()
|
| 456 |
+
.HasConstraintName("FK_Notifications_Users");
|
| 457 |
+
|
| 458 |
+
b.Navigation("User");
|
| 459 |
+
});
|
| 460 |
+
|
| 461 |
+
modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
|
| 462 |
+
{
|
| 463 |
+
b.HasOne("DbConnect.Entities.Membership", "Membership")
|
| 464 |
+
.WithMany("UserSubscriptions")
|
| 465 |
+
.HasForeignKey("MembershipId")
|
| 466 |
+
.IsRequired()
|
| 467 |
+
.HasConstraintName("FK_UserSubscriptions_Memberships");
|
| 468 |
+
|
| 469 |
+
b.HasOne("DbConnect.Entities.User", "User")
|
| 470 |
+
.WithMany("UserSubscriptions")
|
| 471 |
+
.HasForeignKey("UserId")
|
| 472 |
+
.IsRequired()
|
| 473 |
+
.HasConstraintName("FK_UserSubscriptions_Users");
|
| 474 |
+
|
| 475 |
+
b.Navigation("Membership");
|
| 476 |
+
|
| 477 |
+
b.Navigation("User");
|
| 478 |
+
});
|
| 479 |
+
|
| 480 |
+
modelBuilder.Entity("DbConnect.Entities.WishlistItem", b =>
|
| 481 |
+
{
|
| 482 |
+
b.HasOne("DbConnect.Entities.Book", "Book")
|
| 483 |
+
.WithMany("WishlistItems")
|
| 484 |
+
.HasForeignKey("BookId")
|
| 485 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 486 |
+
.IsRequired()
|
| 487 |
+
.HasConstraintName("FK_WishlistItems_Books");
|
| 488 |
+
|
| 489 |
+
b.HasOne("DbConnect.Entities.User", "User")
|
| 490 |
+
.WithMany("WishlistItems")
|
| 491 |
+
.HasForeignKey("UserId")
|
| 492 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 493 |
+
.IsRequired()
|
| 494 |
+
.HasConstraintName("FK_WishlistItems_Users");
|
| 495 |
+
|
| 496 |
+
b.Navigation("Book");
|
| 497 |
+
|
| 498 |
+
b.Navigation("User");
|
| 499 |
+
});
|
| 500 |
+
|
| 501 |
+
modelBuilder.Entity("DbConnect.Entities.Book", b =>
|
| 502 |
+
{
|
| 503 |
+
b.Navigation("Borrowings");
|
| 504 |
+
|
| 505 |
+
b.Navigation("WishlistItems");
|
| 506 |
+
});
|
| 507 |
+
|
| 508 |
+
modelBuilder.Entity("DbConnect.Entities.Membership", b =>
|
| 509 |
+
{
|
| 510 |
+
b.Navigation("UserSubscriptions");
|
| 511 |
+
});
|
| 512 |
+
|
| 513 |
+
modelBuilder.Entity("DbConnect.Entities.User", b =>
|
| 514 |
+
{
|
| 515 |
+
b.Navigation("Borrowings");
|
| 516 |
+
|
| 517 |
+
b.Navigation("Notifications");
|
| 518 |
+
|
| 519 |
+
b.Navigation("UserSubscriptions");
|
| 520 |
+
|
| 521 |
+
b.Navigation("WishlistItems");
|
| 522 |
+
});
|
| 523 |
+
#pragma warning restore 612, 618
|
| 524 |
+
}
|
| 525 |
+
}
|
| 526 |
+
}
|
DbConnect/Migrations/20260506030549_InitialPostgres.cs
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using Microsoft.EntityFrameworkCore.Migrations;
|
| 3 |
+
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
| 4 |
+
|
| 5 |
+
#nullable disable
|
| 6 |
+
|
| 7 |
+
namespace DbConnect.Migrations
|
| 8 |
+
{
|
| 9 |
+
/// <inheritdoc />
|
| 10 |
+
public partial class InitialPostgres : Migration
|
| 11 |
+
{
|
| 12 |
+
/// <inheritdoc />
|
| 13 |
+
protected override void Up(MigrationBuilder migrationBuilder)
|
| 14 |
+
{
|
| 15 |
+
migrationBuilder.CreateTable(
|
| 16 |
+
name: "Books",
|
| 17 |
+
columns: table => new
|
| 18 |
+
{
|
| 19 |
+
Id = table.Column<int>(type: "integer", nullable: false)
|
| 20 |
+
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
| 21 |
+
Title = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
| 22 |
+
ISBN = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
| 23 |
+
Author = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
| 24 |
+
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Available"),
|
| 25 |
+
IsActive = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true),
|
| 26 |
+
CreatedAt = table.Column<DateTime>(type: "timestamp", nullable: false, defaultValueSql: "now()"),
|
| 27 |
+
Description = table.Column<string>(type: "text", nullable: true),
|
| 28 |
+
CoverUrl = table.Column<string>(type: "text", nullable: true),
|
| 29 |
+
TotalCopies = table.Column<int>(type: "integer", nullable: false, defaultValue: 1),
|
| 30 |
+
AvailableCopies = table.Column<int>(type: "integer", nullable: false, defaultValue: 1),
|
| 31 |
+
UpdatedAt = table.Column<DateTime>(type: "timestamp", nullable: true)
|
| 32 |
+
},
|
| 33 |
+
constraints: table =>
|
| 34 |
+
{
|
| 35 |
+
table.PrimaryKey("PK__Books__3214EC07AE1974C8", x => x.Id);
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
migrationBuilder.CreateTable(
|
| 39 |
+
name: "Categories",
|
| 40 |
+
columns: table => new
|
| 41 |
+
{
|
| 42 |
+
Id = table.Column<int>(type: "integer", nullable: false)
|
| 43 |
+
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
| 44 |
+
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false)
|
| 45 |
+
},
|
| 46 |
+
constraints: table =>
|
| 47 |
+
{
|
| 48 |
+
table.PrimaryKey("PK__Categori__3214EC0751B5797D", x => x.Id);
|
| 49 |
+
});
|
| 50 |
+
|
| 51 |
+
migrationBuilder.CreateTable(
|
| 52 |
+
name: "Memberships",
|
| 53 |
+
columns: table => new
|
| 54 |
+
{
|
| 55 |
+
Id = table.Column<int>(type: "integer", nullable: false)
|
| 56 |
+
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
| 57 |
+
Type = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
| 58 |
+
MaxBooks = table.Column<int>(type: "integer", nullable: false),
|
| 59 |
+
BorrowingDays = table.Column<int>(type: "integer", nullable: false),
|
| 60 |
+
Price = table.Column<decimal>(type: "numeric(10,2)", nullable: false),
|
| 61 |
+
DurationMonths = table.Column<int>(type: "integer", nullable: false),
|
| 62 |
+
RewardId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true)
|
| 63 |
+
},
|
| 64 |
+
constraints: table =>
|
| 65 |
+
{
|
| 66 |
+
table.PrimaryKey("PK__Membersh__3214EC07A6F5A55F", x => x.Id);
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
migrationBuilder.CreateTable(
|
| 70 |
+
name: "Users",
|
| 71 |
+
columns: table => new
|
| 72 |
+
{
|
| 73 |
+
Id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
| 74 |
+
FullName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
| 75 |
+
Email = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
| 76 |
+
PasswordHash = table.Column<string>(type: "text", nullable: false),
|
| 77 |
+
PhoneNumber = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
|
| 78 |
+
Role = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "User"),
|
| 79 |
+
IsActive = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true),
|
| 80 |
+
CreatedAt = table.Column<DateTime>(type: "timestamp", nullable: false, defaultValueSql: "now()"),
|
| 81 |
+
UpdatedAt = table.Column<DateTime>(type: "timestamp", nullable: true),
|
| 82 |
+
StudentId = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
|
| 83 |
+
BanStatus = table.Column<bool>(type: "boolean", nullable: true),
|
| 84 |
+
SuspensionEndDate = table.Column<DateTime>(type: "timestamp", nullable: true),
|
| 85 |
+
Address = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
| 86 |
+
FcmToken = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true)
|
| 87 |
+
},
|
| 88 |
+
constraints: table =>
|
| 89 |
+
{
|
| 90 |
+
table.PrimaryKey("PK_Users", x => x.Id);
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
migrationBuilder.CreateTable(
|
| 94 |
+
name: "BookCategories",
|
| 95 |
+
columns: table => new
|
| 96 |
+
{
|
| 97 |
+
BookId = table.Column<int>(type: "integer", nullable: false),
|
| 98 |
+
CategoryId = table.Column<int>(type: "integer", nullable: false)
|
| 99 |
+
},
|
| 100 |
+
constraints: table =>
|
| 101 |
+
{
|
| 102 |
+
table.PrimaryKey("PK__BookCate__9C7051A74E7D221D", x => new { x.BookId, x.CategoryId });
|
| 103 |
+
table.ForeignKey(
|
| 104 |
+
name: "FK_BookCategories_Books",
|
| 105 |
+
column: x => x.BookId,
|
| 106 |
+
principalTable: "Books",
|
| 107 |
+
principalColumn: "Id",
|
| 108 |
+
onDelete: ReferentialAction.Cascade);
|
| 109 |
+
table.ForeignKey(
|
| 110 |
+
name: "FK_BookCategories_Categories",
|
| 111 |
+
column: x => x.CategoryId,
|
| 112 |
+
principalTable: "Categories",
|
| 113 |
+
principalColumn: "Id",
|
| 114 |
+
onDelete: ReferentialAction.Cascade);
|
| 115 |
+
});
|
| 116 |
+
|
| 117 |
+
migrationBuilder.CreateTable(
|
| 118 |
+
name: "Borrowings",
|
| 119 |
+
columns: table => new
|
| 120 |
+
{
|
| 121 |
+
Id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
| 122 |
+
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
| 123 |
+
BookId = table.Column<int>(type: "integer", nullable: false),
|
| 124 |
+
BorrowDate = table.Column<DateTime>(type: "timestamp", nullable: false, defaultValueSql: "now()"),
|
| 125 |
+
DueDate = table.Column<DateTime>(type: "timestamp", nullable: false),
|
| 126 |
+
ReturnDate = table.Column<DateTime>(type: "timestamp", nullable: true),
|
| 127 |
+
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"),
|
| 128 |
+
FineAmount = table.Column<decimal>(type: "numeric(10,2)", nullable: false),
|
| 129 |
+
IsFinePaid = table.Column<bool>(type: "boolean", nullable: false)
|
| 130 |
+
},
|
| 131 |
+
constraints: table =>
|
| 132 |
+
{
|
| 133 |
+
table.PrimaryKey("PK_Borrowings", x => x.Id);
|
| 134 |
+
table.ForeignKey(
|
| 135 |
+
name: "FK_Borrowings_Books",
|
| 136 |
+
column: x => x.BookId,
|
| 137 |
+
principalTable: "Books",
|
| 138 |
+
principalColumn: "Id");
|
| 139 |
+
table.ForeignKey(
|
| 140 |
+
name: "FK_Borrowings_Users",
|
| 141 |
+
column: x => x.UserId,
|
| 142 |
+
principalTable: "Users",
|
| 143 |
+
principalColumn: "Id");
|
| 144 |
+
});
|
| 145 |
+
|
| 146 |
+
migrationBuilder.CreateTable(
|
| 147 |
+
name: "Notifications",
|
| 148 |
+
columns: table => new
|
| 149 |
+
{
|
| 150 |
+
Id = table.Column<int>(type: "integer", nullable: false)
|
| 151 |
+
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
| 152 |
+
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
| 153 |
+
Title = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
| 154 |
+
Message = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: false),
|
| 155 |
+
Type = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, defaultValue: "Info"),
|
| 156 |
+
ActionLink = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
| 157 |
+
ActionText = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
|
| 158 |
+
IsRead = table.Column<bool>(type: "boolean", nullable: false),
|
| 159 |
+
CreatedAt = table.Column<DateTime>(type: "timestamp", nullable: false, defaultValueSql: "now()")
|
| 160 |
+
},
|
| 161 |
+
constraints: table =>
|
| 162 |
+
{
|
| 163 |
+
table.PrimaryKey("PK_Notifications", x => x.Id);
|
| 164 |
+
table.ForeignKey(
|
| 165 |
+
name: "FK_Notifications_Users",
|
| 166 |
+
column: x => x.UserId,
|
| 167 |
+
principalTable: "Users",
|
| 168 |
+
principalColumn: "Id",
|
| 169 |
+
onDelete: ReferentialAction.Cascade);
|
| 170 |
+
});
|
| 171 |
+
|
| 172 |
+
migrationBuilder.CreateTable(
|
| 173 |
+
name: "UserSubscriptions",
|
| 174 |
+
columns: table => new
|
| 175 |
+
{
|
| 176 |
+
Id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
| 177 |
+
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
| 178 |
+
MembershipId = table.Column<int>(type: "integer", nullable: false),
|
| 179 |
+
StartDate = table.Column<DateTime>(type: "timestamp", nullable: false),
|
| 180 |
+
ExpiryDate = table.Column<DateTime>(type: "timestamp", nullable: false),
|
| 181 |
+
IsActive = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true),
|
| 182 |
+
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"),
|
| 183 |
+
ExternalRedemptionId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true)
|
| 184 |
+
},
|
| 185 |
+
constraints: table =>
|
| 186 |
+
{
|
| 187 |
+
table.PrimaryKey("PK_UserSubscriptions", x => x.Id);
|
| 188 |
+
table.ForeignKey(
|
| 189 |
+
name: "FK_UserSubscriptions_Memberships",
|
| 190 |
+
column: x => x.MembershipId,
|
| 191 |
+
principalTable: "Memberships",
|
| 192 |
+
principalColumn: "Id");
|
| 193 |
+
table.ForeignKey(
|
| 194 |
+
name: "FK_UserSubscriptions_Users",
|
| 195 |
+
column: x => x.UserId,
|
| 196 |
+
principalTable: "Users",
|
| 197 |
+
principalColumn: "Id");
|
| 198 |
+
});
|
| 199 |
+
|
| 200 |
+
migrationBuilder.CreateTable(
|
| 201 |
+
name: "WishlistItems",
|
| 202 |
+
columns: table => new
|
| 203 |
+
{
|
| 204 |
+
Id = table.Column<int>(type: "integer", nullable: false)
|
| 205 |
+
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
| 206 |
+
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
| 207 |
+
BookId = table.Column<int>(type: "integer", nullable: false),
|
| 208 |
+
AddedAt = table.Column<DateTime>(type: "timestamp", nullable: false, defaultValueSql: "now()")
|
| 209 |
+
},
|
| 210 |
+
constraints: table =>
|
| 211 |
+
{
|
| 212 |
+
table.PrimaryKey("PK_WishlistItems", x => x.Id);
|
| 213 |
+
table.ForeignKey(
|
| 214 |
+
name: "FK_WishlistItems_Books",
|
| 215 |
+
column: x => x.BookId,
|
| 216 |
+
principalTable: "Books",
|
| 217 |
+
principalColumn: "Id",
|
| 218 |
+
onDelete: ReferentialAction.Cascade);
|
| 219 |
+
table.ForeignKey(
|
| 220 |
+
name: "FK_WishlistItems_Users",
|
| 221 |
+
column: x => x.UserId,
|
| 222 |
+
principalTable: "Users",
|
| 223 |
+
principalColumn: "Id",
|
| 224 |
+
onDelete: ReferentialAction.Cascade);
|
| 225 |
+
});
|
| 226 |
+
|
| 227 |
+
migrationBuilder.CreateIndex(
|
| 228 |
+
name: "IX_BookCategories_CategoryId",
|
| 229 |
+
table: "BookCategories",
|
| 230 |
+
column: "CategoryId");
|
| 231 |
+
|
| 232 |
+
migrationBuilder.CreateIndex(
|
| 233 |
+
name: "UQ__Books__447D36EA79CF66CE",
|
| 234 |
+
table: "Books",
|
| 235 |
+
column: "ISBN",
|
| 236 |
+
unique: true);
|
| 237 |
+
|
| 238 |
+
migrationBuilder.CreateIndex(
|
| 239 |
+
name: "IX_Borrowings_BookId",
|
| 240 |
+
table: "Borrowings",
|
| 241 |
+
column: "BookId");
|
| 242 |
+
|
| 243 |
+
migrationBuilder.CreateIndex(
|
| 244 |
+
name: "IX_Borrowings_UserId",
|
| 245 |
+
table: "Borrowings",
|
| 246 |
+
column: "UserId");
|
| 247 |
+
|
| 248 |
+
migrationBuilder.CreateIndex(
|
| 249 |
+
name: "UQ__Categori__737584F622B16D3A",
|
| 250 |
+
table: "Categories",
|
| 251 |
+
column: "Name",
|
| 252 |
+
unique: true);
|
| 253 |
+
|
| 254 |
+
migrationBuilder.CreateIndex(
|
| 255 |
+
name: "IX_Memberships_Type",
|
| 256 |
+
table: "Memberships",
|
| 257 |
+
column: "Type",
|
| 258 |
+
unique: true);
|
| 259 |
+
|
| 260 |
+
migrationBuilder.CreateIndex(
|
| 261 |
+
name: "IX_Notifications_UserId",
|
| 262 |
+
table: "Notifications",
|
| 263 |
+
column: "UserId");
|
| 264 |
+
|
| 265 |
+
migrationBuilder.CreateIndex(
|
| 266 |
+
name: "UQ_Users_Email",
|
| 267 |
+
table: "Users",
|
| 268 |
+
column: "Email",
|
| 269 |
+
unique: true);
|
| 270 |
+
|
| 271 |
+
migrationBuilder.CreateIndex(
|
| 272 |
+
name: "IX_UserSubscriptions_MembershipId",
|
| 273 |
+
table: "UserSubscriptions",
|
| 274 |
+
column: "MembershipId");
|
| 275 |
+
|
| 276 |
+
migrationBuilder.CreateIndex(
|
| 277 |
+
name: "IX_UserSubscriptions_UserId",
|
| 278 |
+
table: "UserSubscriptions",
|
| 279 |
+
column: "UserId");
|
| 280 |
+
|
| 281 |
+
migrationBuilder.CreateIndex(
|
| 282 |
+
name: "IX_WishlistItems_BookId",
|
| 283 |
+
table: "WishlistItems",
|
| 284 |
+
column: "BookId");
|
| 285 |
+
|
| 286 |
+
migrationBuilder.CreateIndex(
|
| 287 |
+
name: "IX_WishlistItems_UserId",
|
| 288 |
+
table: "WishlistItems",
|
| 289 |
+
column: "UserId");
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
/// <inheritdoc />
|
| 293 |
+
protected override void Down(MigrationBuilder migrationBuilder)
|
| 294 |
+
{
|
| 295 |
+
migrationBuilder.DropTable(
|
| 296 |
+
name: "BookCategories");
|
| 297 |
+
|
| 298 |
+
migrationBuilder.DropTable(
|
| 299 |
+
name: "Borrowings");
|
| 300 |
+
|
| 301 |
+
migrationBuilder.DropTable(
|
| 302 |
+
name: "Notifications");
|
| 303 |
+
|
| 304 |
+
migrationBuilder.DropTable(
|
| 305 |
+
name: "UserSubscriptions");
|
| 306 |
+
|
| 307 |
+
migrationBuilder.DropTable(
|
| 308 |
+
name: "WishlistItems");
|
| 309 |
+
|
| 310 |
+
migrationBuilder.DropTable(
|
| 311 |
+
name: "Categories");
|
| 312 |
+
|
| 313 |
+
migrationBuilder.DropTable(
|
| 314 |
+
name: "Memberships");
|
| 315 |
+
|
| 316 |
+
migrationBuilder.DropTable(
|
| 317 |
+
name: "Books");
|
| 318 |
+
|
| 319 |
+
migrationBuilder.DropTable(
|
| 320 |
+
name: "Users");
|
| 321 |
+
}
|
| 322 |
+
}
|
| 323 |
+
}
|
DbConnect/Migrations/AppDbContextModelSnapshot.cs
ADDED
|
@@ -0,0 +1,523 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// <auto-generated />
|
| 2 |
+
using System;
|
| 3 |
+
using DbConnect.Data;
|
| 4 |
+
using Microsoft.EntityFrameworkCore;
|
| 5 |
+
using Microsoft.EntityFrameworkCore.Infrastructure;
|
| 6 |
+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
| 7 |
+
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
| 8 |
+
|
| 9 |
+
#nullable disable
|
| 10 |
+
|
| 11 |
+
namespace DbConnect.Migrations
|
| 12 |
+
{
|
| 13 |
+
[DbContext(typeof(AppDbContext))]
|
| 14 |
+
partial class AppDbContextModelSnapshot : ModelSnapshot
|
| 15 |
+
{
|
| 16 |
+
protected override void BuildModel(ModelBuilder modelBuilder)
|
| 17 |
+
{
|
| 18 |
+
#pragma warning disable 612, 618
|
| 19 |
+
modelBuilder
|
| 20 |
+
.HasAnnotation("ProductVersion", "9.0.0")
|
| 21 |
+
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
| 22 |
+
|
| 23 |
+
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
| 24 |
+
|
| 25 |
+
modelBuilder.Entity("BookCategory", b =>
|
| 26 |
+
{
|
| 27 |
+
b.Property<int>("BookId")
|
| 28 |
+
.HasColumnType("integer");
|
| 29 |
+
|
| 30 |
+
b.Property<int>("CategoryId")
|
| 31 |
+
.HasColumnType("integer");
|
| 32 |
+
|
| 33 |
+
b.HasKey("BookId", "CategoryId")
|
| 34 |
+
.HasName("PK__BookCate__9C7051A74E7D221D");
|
| 35 |
+
|
| 36 |
+
b.HasIndex("CategoryId");
|
| 37 |
+
|
| 38 |
+
b.ToTable("BookCategories", (string)null);
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
modelBuilder.Entity("DbConnect.Entities.Book", b =>
|
| 42 |
+
{
|
| 43 |
+
b.Property<int>("Id")
|
| 44 |
+
.ValueGeneratedOnAdd()
|
| 45 |
+
.HasColumnType("integer");
|
| 46 |
+
|
| 47 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 48 |
+
|
| 49 |
+
b.Property<string>("Author")
|
| 50 |
+
.IsRequired()
|
| 51 |
+
.HasMaxLength(100)
|
| 52 |
+
.HasColumnType("character varying(100)");
|
| 53 |
+
|
| 54 |
+
b.Property<int>("AvailableCopies")
|
| 55 |
+
.ValueGeneratedOnAdd()
|
| 56 |
+
.HasColumnType("integer")
|
| 57 |
+
.HasDefaultValue(1);
|
| 58 |
+
|
| 59 |
+
b.Property<string>("CoverUrl")
|
| 60 |
+
.HasColumnType("text");
|
| 61 |
+
|
| 62 |
+
b.Property<DateTime>("CreatedAt")
|
| 63 |
+
.ValueGeneratedOnAdd()
|
| 64 |
+
.HasColumnType("timestamp")
|
| 65 |
+
.HasDefaultValueSql("now()");
|
| 66 |
+
|
| 67 |
+
b.Property<string>("Description")
|
| 68 |
+
.HasColumnType("text");
|
| 69 |
+
|
| 70 |
+
b.Property<bool>("IsActive")
|
| 71 |
+
.ValueGeneratedOnAdd()
|
| 72 |
+
.HasColumnType("boolean")
|
| 73 |
+
.HasDefaultValue(true);
|
| 74 |
+
|
| 75 |
+
b.Property<string>("Isbn")
|
| 76 |
+
.IsRequired()
|
| 77 |
+
.HasMaxLength(20)
|
| 78 |
+
.HasColumnType("character varying(20)")
|
| 79 |
+
.HasColumnName("ISBN");
|
| 80 |
+
|
| 81 |
+
b.Property<string>("Status")
|
| 82 |
+
.IsRequired()
|
| 83 |
+
.ValueGeneratedOnAdd()
|
| 84 |
+
.HasMaxLength(20)
|
| 85 |
+
.HasColumnType("character varying(20)")
|
| 86 |
+
.HasDefaultValue("Available");
|
| 87 |
+
|
| 88 |
+
b.Property<string>("Title")
|
| 89 |
+
.IsRequired()
|
| 90 |
+
.HasMaxLength(200)
|
| 91 |
+
.HasColumnType("character varying(200)");
|
| 92 |
+
|
| 93 |
+
b.Property<int>("TotalCopies")
|
| 94 |
+
.ValueGeneratedOnAdd()
|
| 95 |
+
.HasColumnType("integer")
|
| 96 |
+
.HasDefaultValue(1);
|
| 97 |
+
|
| 98 |
+
b.Property<DateTime?>("UpdatedAt")
|
| 99 |
+
.HasColumnType("timestamp");
|
| 100 |
+
|
| 101 |
+
b.HasKey("Id")
|
| 102 |
+
.HasName("PK__Books__3214EC07AE1974C8");
|
| 103 |
+
|
| 104 |
+
b.HasIndex(new[] { "Isbn" }, "UQ__Books__447D36EA79CF66CE")
|
| 105 |
+
.IsUnique();
|
| 106 |
+
|
| 107 |
+
b.ToTable("Books");
|
| 108 |
+
});
|
| 109 |
+
|
| 110 |
+
modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
|
| 111 |
+
{
|
| 112 |
+
b.Property<Guid>("Id")
|
| 113 |
+
.ValueGeneratedOnAdd()
|
| 114 |
+
.HasColumnType("uuid")
|
| 115 |
+
.HasDefaultValueSql("gen_random_uuid()");
|
| 116 |
+
|
| 117 |
+
b.Property<int>("BookId")
|
| 118 |
+
.HasColumnType("integer");
|
| 119 |
+
|
| 120 |
+
b.Property<DateTime>("BorrowDate")
|
| 121 |
+
.ValueGeneratedOnAdd()
|
| 122 |
+
.HasColumnType("timestamp")
|
| 123 |
+
.HasDefaultValueSql("now()");
|
| 124 |
+
|
| 125 |
+
b.Property<DateTime>("DueDate")
|
| 126 |
+
.HasColumnType("timestamp");
|
| 127 |
+
|
| 128 |
+
b.Property<decimal>("FineAmount")
|
| 129 |
+
.HasColumnType("decimal(10, 2)");
|
| 130 |
+
|
| 131 |
+
b.Property<bool>("IsFinePaid")
|
| 132 |
+
.HasColumnType("boolean");
|
| 133 |
+
|
| 134 |
+
b.Property<DateTime?>("ReturnDate")
|
| 135 |
+
.HasColumnType("timestamp");
|
| 136 |
+
|
| 137 |
+
b.Property<string>("Status")
|
| 138 |
+
.IsRequired()
|
| 139 |
+
.ValueGeneratedOnAdd()
|
| 140 |
+
.HasMaxLength(20)
|
| 141 |
+
.HasColumnType("character varying(20)")
|
| 142 |
+
.HasDefaultValue("Active");
|
| 143 |
+
|
| 144 |
+
b.Property<Guid>("UserId")
|
| 145 |
+
.HasColumnType("uuid");
|
| 146 |
+
|
| 147 |
+
b.HasKey("Id");
|
| 148 |
+
|
| 149 |
+
b.HasIndex("BookId");
|
| 150 |
+
|
| 151 |
+
b.HasIndex("UserId");
|
| 152 |
+
|
| 153 |
+
b.ToTable("Borrowings");
|
| 154 |
+
});
|
| 155 |
+
|
| 156 |
+
modelBuilder.Entity("DbConnect.Entities.Category", b =>
|
| 157 |
+
{
|
| 158 |
+
b.Property<int>("Id")
|
| 159 |
+
.ValueGeneratedOnAdd()
|
| 160 |
+
.HasColumnType("integer");
|
| 161 |
+
|
| 162 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 163 |
+
|
| 164 |
+
b.Property<string>("Name")
|
| 165 |
+
.IsRequired()
|
| 166 |
+
.HasMaxLength(100)
|
| 167 |
+
.HasColumnType("character varying(100)");
|
| 168 |
+
|
| 169 |
+
b.HasKey("Id")
|
| 170 |
+
.HasName("PK__Categori__3214EC0751B5797D");
|
| 171 |
+
|
| 172 |
+
b.HasIndex(new[] { "Name" }, "UQ__Categori__737584F622B16D3A")
|
| 173 |
+
.IsUnique();
|
| 174 |
+
|
| 175 |
+
b.ToTable("Categories");
|
| 176 |
+
});
|
| 177 |
+
|
| 178 |
+
modelBuilder.Entity("DbConnect.Entities.Membership", b =>
|
| 179 |
+
{
|
| 180 |
+
b.Property<int>("Id")
|
| 181 |
+
.ValueGeneratedOnAdd()
|
| 182 |
+
.HasColumnType("integer");
|
| 183 |
+
|
| 184 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 185 |
+
|
| 186 |
+
b.Property<int>("BorrowingDays")
|
| 187 |
+
.HasColumnType("integer");
|
| 188 |
+
|
| 189 |
+
b.Property<int>("DurationMonths")
|
| 190 |
+
.HasColumnType("integer");
|
| 191 |
+
|
| 192 |
+
b.Property<int>("MaxBooks")
|
| 193 |
+
.HasColumnType("integer");
|
| 194 |
+
|
| 195 |
+
b.Property<decimal>("Price")
|
| 196 |
+
.HasColumnType("decimal(10, 2)");
|
| 197 |
+
|
| 198 |
+
b.Property<string>("RewardId")
|
| 199 |
+
.HasMaxLength(100)
|
| 200 |
+
.HasColumnType("character varying(100)");
|
| 201 |
+
|
| 202 |
+
b.Property<string>("Type")
|
| 203 |
+
.IsRequired()
|
| 204 |
+
.HasMaxLength(50)
|
| 205 |
+
.HasColumnType("character varying(50)");
|
| 206 |
+
|
| 207 |
+
b.HasKey("Id")
|
| 208 |
+
.HasName("PK__Membersh__3214EC07A6F5A55F");
|
| 209 |
+
|
| 210 |
+
b.HasIndex(new[] { "Type" }, "IX_Memberships_Type")
|
| 211 |
+
.IsUnique();
|
| 212 |
+
|
| 213 |
+
b.ToTable("Memberships");
|
| 214 |
+
});
|
| 215 |
+
|
| 216 |
+
modelBuilder.Entity("DbConnect.Entities.Notification", b =>
|
| 217 |
+
{
|
| 218 |
+
b.Property<int>("Id")
|
| 219 |
+
.ValueGeneratedOnAdd()
|
| 220 |
+
.HasColumnType("integer");
|
| 221 |
+
|
| 222 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 223 |
+
|
| 224 |
+
b.Property<string>("ActionLink")
|
| 225 |
+
.HasMaxLength(500)
|
| 226 |
+
.HasColumnType("character varying(500)");
|
| 227 |
+
|
| 228 |
+
b.Property<string>("ActionText")
|
| 229 |
+
.HasMaxLength(100)
|
| 230 |
+
.HasColumnType("character varying(100)");
|
| 231 |
+
|
| 232 |
+
b.Property<DateTime>("CreatedAt")
|
| 233 |
+
.ValueGeneratedOnAdd()
|
| 234 |
+
.HasColumnType("timestamp")
|
| 235 |
+
.HasDefaultValueSql("now()");
|
| 236 |
+
|
| 237 |
+
b.Property<bool>("IsRead")
|
| 238 |
+
.HasColumnType("boolean");
|
| 239 |
+
|
| 240 |
+
b.Property<string>("Message")
|
| 241 |
+
.IsRequired()
|
| 242 |
+
.HasMaxLength(1000)
|
| 243 |
+
.HasColumnType("character varying(1000)");
|
| 244 |
+
|
| 245 |
+
b.Property<string>("Title")
|
| 246 |
+
.IsRequired()
|
| 247 |
+
.HasMaxLength(200)
|
| 248 |
+
.HasColumnType("character varying(200)");
|
| 249 |
+
|
| 250 |
+
b.Property<string>("Type")
|
| 251 |
+
.IsRequired()
|
| 252 |
+
.ValueGeneratedOnAdd()
|
| 253 |
+
.HasMaxLength(50)
|
| 254 |
+
.HasColumnType("character varying(50)")
|
| 255 |
+
.HasDefaultValue("Info");
|
| 256 |
+
|
| 257 |
+
b.Property<Guid>("UserId")
|
| 258 |
+
.HasColumnType("uuid");
|
| 259 |
+
|
| 260 |
+
b.HasKey("Id");
|
| 261 |
+
|
| 262 |
+
b.HasIndex(new[] { "UserId" }, "IX_Notifications_UserId");
|
| 263 |
+
|
| 264 |
+
b.ToTable("Notifications");
|
| 265 |
+
});
|
| 266 |
+
|
| 267 |
+
modelBuilder.Entity("DbConnect.Entities.User", b =>
|
| 268 |
+
{
|
| 269 |
+
b.Property<Guid>("Id")
|
| 270 |
+
.ValueGeneratedOnAdd()
|
| 271 |
+
.HasColumnType("uuid")
|
| 272 |
+
.HasDefaultValueSql("gen_random_uuid()");
|
| 273 |
+
|
| 274 |
+
b.Property<string>("Address")
|
| 275 |
+
.HasMaxLength(255)
|
| 276 |
+
.HasColumnType("character varying(255)");
|
| 277 |
+
|
| 278 |
+
b.Property<bool?>("BanStatus")
|
| 279 |
+
.HasColumnType("boolean");
|
| 280 |
+
|
| 281 |
+
b.Property<DateTime>("CreatedAt")
|
| 282 |
+
.ValueGeneratedOnAdd()
|
| 283 |
+
.HasColumnType("timestamp")
|
| 284 |
+
.HasDefaultValueSql("now()");
|
| 285 |
+
|
| 286 |
+
b.Property<string>("Email")
|
| 287 |
+
.IsRequired()
|
| 288 |
+
.HasMaxLength(100)
|
| 289 |
+
.HasColumnType("character varying(100)");
|
| 290 |
+
|
| 291 |
+
b.Property<string>("FcmToken")
|
| 292 |
+
.HasMaxLength(500)
|
| 293 |
+
.HasColumnType("character varying(500)");
|
| 294 |
+
|
| 295 |
+
b.Property<string>("FullName")
|
| 296 |
+
.IsRequired()
|
| 297 |
+
.HasMaxLength(100)
|
| 298 |
+
.HasColumnType("character varying(100)");
|
| 299 |
+
|
| 300 |
+
b.Property<bool>("IsActive")
|
| 301 |
+
.ValueGeneratedOnAdd()
|
| 302 |
+
.HasColumnType("boolean")
|
| 303 |
+
.HasDefaultValue(true);
|
| 304 |
+
|
| 305 |
+
b.Property<string>("PasswordHash")
|
| 306 |
+
.IsRequired()
|
| 307 |
+
.HasColumnType("text");
|
| 308 |
+
|
| 309 |
+
b.Property<string>("PhoneNumber")
|
| 310 |
+
.HasMaxLength(20)
|
| 311 |
+
.HasColumnType("character varying(20)");
|
| 312 |
+
|
| 313 |
+
b.Property<string>("Role")
|
| 314 |
+
.IsRequired()
|
| 315 |
+
.ValueGeneratedOnAdd()
|
| 316 |
+
.HasMaxLength(20)
|
| 317 |
+
.HasColumnType("character varying(20)")
|
| 318 |
+
.HasDefaultValue("User");
|
| 319 |
+
|
| 320 |
+
b.Property<string>("StudentId")
|
| 321 |
+
.HasMaxLength(20)
|
| 322 |
+
.HasColumnType("character varying(20)");
|
| 323 |
+
|
| 324 |
+
b.Property<DateTime?>("SuspensionEndDate")
|
| 325 |
+
.HasColumnType("timestamp");
|
| 326 |
+
|
| 327 |
+
b.Property<DateTime?>("UpdatedAt")
|
| 328 |
+
.HasColumnType("timestamp");
|
| 329 |
+
|
| 330 |
+
b.HasKey("Id");
|
| 331 |
+
|
| 332 |
+
b.HasIndex(new[] { "Email" }, "UQ_Users_Email")
|
| 333 |
+
.IsUnique();
|
| 334 |
+
|
| 335 |
+
b.ToTable("Users");
|
| 336 |
+
});
|
| 337 |
+
|
| 338 |
+
modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
|
| 339 |
+
{
|
| 340 |
+
b.Property<Guid>("Id")
|
| 341 |
+
.ValueGeneratedOnAdd()
|
| 342 |
+
.HasColumnType("uuid")
|
| 343 |
+
.HasDefaultValueSql("gen_random_uuid()");
|
| 344 |
+
|
| 345 |
+
b.Property<DateTime>("ExpiryDate")
|
| 346 |
+
.HasColumnType("timestamp");
|
| 347 |
+
|
| 348 |
+
b.Property<string>("ExternalRedemptionId")
|
| 349 |
+
.HasMaxLength(100)
|
| 350 |
+
.HasColumnType("character varying(100)");
|
| 351 |
+
|
| 352 |
+
b.Property<bool>("IsActive")
|
| 353 |
+
.ValueGeneratedOnAdd()
|
| 354 |
+
.HasColumnType("boolean")
|
| 355 |
+
.HasDefaultValue(true);
|
| 356 |
+
|
| 357 |
+
b.Property<int>("MembershipId")
|
| 358 |
+
.HasColumnType("integer");
|
| 359 |
+
|
| 360 |
+
b.Property<DateTime>("StartDate")
|
| 361 |
+
.HasColumnType("timestamp");
|
| 362 |
+
|
| 363 |
+
b.Property<string>("Status")
|
| 364 |
+
.IsRequired()
|
| 365 |
+
.ValueGeneratedOnAdd()
|
| 366 |
+
.HasMaxLength(20)
|
| 367 |
+
.HasColumnType("character varying(20)")
|
| 368 |
+
.HasDefaultValue("Active");
|
| 369 |
+
|
| 370 |
+
b.Property<Guid>("UserId")
|
| 371 |
+
.HasColumnType("uuid");
|
| 372 |
+
|
| 373 |
+
b.HasKey("Id");
|
| 374 |
+
|
| 375 |
+
b.HasIndex("MembershipId");
|
| 376 |
+
|
| 377 |
+
b.HasIndex("UserId");
|
| 378 |
+
|
| 379 |
+
b.ToTable("UserSubscriptions");
|
| 380 |
+
});
|
| 381 |
+
|
| 382 |
+
modelBuilder.Entity("DbConnect.Entities.WishlistItem", b =>
|
| 383 |
+
{
|
| 384 |
+
b.Property<int>("Id")
|
| 385 |
+
.ValueGeneratedOnAdd()
|
| 386 |
+
.HasColumnType("integer");
|
| 387 |
+
|
| 388 |
+
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
| 389 |
+
|
| 390 |
+
b.Property<DateTime>("AddedAt")
|
| 391 |
+
.ValueGeneratedOnAdd()
|
| 392 |
+
.HasColumnType("timestamp")
|
| 393 |
+
.HasDefaultValueSql("now()");
|
| 394 |
+
|
| 395 |
+
b.Property<int>("BookId")
|
| 396 |
+
.HasColumnType("integer");
|
| 397 |
+
|
| 398 |
+
b.Property<Guid>("UserId")
|
| 399 |
+
.HasColumnType("uuid");
|
| 400 |
+
|
| 401 |
+
b.HasKey("Id");
|
| 402 |
+
|
| 403 |
+
b.HasIndex(new[] { "BookId" }, "IX_WishlistItems_BookId");
|
| 404 |
+
|
| 405 |
+
b.HasIndex(new[] { "UserId" }, "IX_WishlistItems_UserId");
|
| 406 |
+
|
| 407 |
+
b.ToTable("WishlistItems");
|
| 408 |
+
});
|
| 409 |
+
|
| 410 |
+
modelBuilder.Entity("BookCategory", b =>
|
| 411 |
+
{
|
| 412 |
+
b.HasOne("DbConnect.Entities.Book", null)
|
| 413 |
+
.WithMany()
|
| 414 |
+
.HasForeignKey("BookId")
|
| 415 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 416 |
+
.IsRequired()
|
| 417 |
+
.HasConstraintName("FK_BookCategories_Books");
|
| 418 |
+
|
| 419 |
+
b.HasOne("DbConnect.Entities.Category", null)
|
| 420 |
+
.WithMany()
|
| 421 |
+
.HasForeignKey("CategoryId")
|
| 422 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 423 |
+
.IsRequired()
|
| 424 |
+
.HasConstraintName("FK_BookCategories_Categories");
|
| 425 |
+
});
|
| 426 |
+
|
| 427 |
+
modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
|
| 428 |
+
{
|
| 429 |
+
b.HasOne("DbConnect.Entities.Book", "Book")
|
| 430 |
+
.WithMany("Borrowings")
|
| 431 |
+
.HasForeignKey("BookId")
|
| 432 |
+
.IsRequired()
|
| 433 |
+
.HasConstraintName("FK_Borrowings_Books");
|
| 434 |
+
|
| 435 |
+
b.HasOne("DbConnect.Entities.User", "User")
|
| 436 |
+
.WithMany("Borrowings")
|
| 437 |
+
.HasForeignKey("UserId")
|
| 438 |
+
.IsRequired()
|
| 439 |
+
.HasConstraintName("FK_Borrowings_Users");
|
| 440 |
+
|
| 441 |
+
b.Navigation("Book");
|
| 442 |
+
|
| 443 |
+
b.Navigation("User");
|
| 444 |
+
});
|
| 445 |
+
|
| 446 |
+
modelBuilder.Entity("DbConnect.Entities.Notification", b =>
|
| 447 |
+
{
|
| 448 |
+
b.HasOne("DbConnect.Entities.User", "User")
|
| 449 |
+
.WithMany("Notifications")
|
| 450 |
+
.HasForeignKey("UserId")
|
| 451 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 452 |
+
.IsRequired()
|
| 453 |
+
.HasConstraintName("FK_Notifications_Users");
|
| 454 |
+
|
| 455 |
+
b.Navigation("User");
|
| 456 |
+
});
|
| 457 |
+
|
| 458 |
+
modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
|
| 459 |
+
{
|
| 460 |
+
b.HasOne("DbConnect.Entities.Membership", "Membership")
|
| 461 |
+
.WithMany("UserSubscriptions")
|
| 462 |
+
.HasForeignKey("MembershipId")
|
| 463 |
+
.IsRequired()
|
| 464 |
+
.HasConstraintName("FK_UserSubscriptions_Memberships");
|
| 465 |
+
|
| 466 |
+
b.HasOne("DbConnect.Entities.User", "User")
|
| 467 |
+
.WithMany("UserSubscriptions")
|
| 468 |
+
.HasForeignKey("UserId")
|
| 469 |
+
.IsRequired()
|
| 470 |
+
.HasConstraintName("FK_UserSubscriptions_Users");
|
| 471 |
+
|
| 472 |
+
b.Navigation("Membership");
|
| 473 |
+
|
| 474 |
+
b.Navigation("User");
|
| 475 |
+
});
|
| 476 |
+
|
| 477 |
+
modelBuilder.Entity("DbConnect.Entities.WishlistItem", b =>
|
| 478 |
+
{
|
| 479 |
+
b.HasOne("DbConnect.Entities.Book", "Book")
|
| 480 |
+
.WithMany("WishlistItems")
|
| 481 |
+
.HasForeignKey("BookId")
|
| 482 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 483 |
+
.IsRequired()
|
| 484 |
+
.HasConstraintName("FK_WishlistItems_Books");
|
| 485 |
+
|
| 486 |
+
b.HasOne("DbConnect.Entities.User", "User")
|
| 487 |
+
.WithMany("WishlistItems")
|
| 488 |
+
.HasForeignKey("UserId")
|
| 489 |
+
.OnDelete(DeleteBehavior.Cascade)
|
| 490 |
+
.IsRequired()
|
| 491 |
+
.HasConstraintName("FK_WishlistItems_Users");
|
| 492 |
+
|
| 493 |
+
b.Navigation("Book");
|
| 494 |
+
|
| 495 |
+
b.Navigation("User");
|
| 496 |
+
});
|
| 497 |
+
|
| 498 |
+
modelBuilder.Entity("DbConnect.Entities.Book", b =>
|
| 499 |
+
{
|
| 500 |
+
b.Navigation("Borrowings");
|
| 501 |
+
|
| 502 |
+
b.Navigation("WishlistItems");
|
| 503 |
+
});
|
| 504 |
+
|
| 505 |
+
modelBuilder.Entity("DbConnect.Entities.Membership", b =>
|
| 506 |
+
{
|
| 507 |
+
b.Navigation("UserSubscriptions");
|
| 508 |
+
});
|
| 509 |
+
|
| 510 |
+
modelBuilder.Entity("DbConnect.Entities.User", b =>
|
| 511 |
+
{
|
| 512 |
+
b.Navigation("Borrowings");
|
| 513 |
+
|
| 514 |
+
b.Navigation("Notifications");
|
| 515 |
+
|
| 516 |
+
b.Navigation("UserSubscriptions");
|
| 517 |
+
|
| 518 |
+
b.Navigation("WishlistItems");
|
| 519 |
+
});
|
| 520 |
+
#pragma warning restore 612, 618
|
| 521 |
+
}
|
| 522 |
+
}
|
| 523 |
+
}
|