From e6d37fe4db10215ac64ad32614241870300f38d4 Mon Sep 17 00:00:00 2001 From: "Md. Abul Kalam" Date: Thu, 23 Jan 2025 22:57:29 +0600 Subject: [PATCH 1/3] Update DB migrations --- .../UpdateUser/UpdateUserCommandHadler.cs | 7 +- .../Common/SeedData/SeedData.SQL | 33 +- .../20240303163205_InitialChanges.Designer.cs | 713 --------------- .../20240303163205_InitialChanges.cs | 508 ----------- ...132753_UpdateProductImageTable.Designer.cs | 718 --------------- .../20240325132753_UpdateProductImageTable.cs | 29 - .../20240329185149_AddedCartTable.Designer.cs | 778 ---------------- .../20240329185149_AddedCartTable.cs | 85 -- .../20240331173916_UpdateTables.Designer.cs | 778 ---------------- .../Migrations/20240331173916_UpdateTables.cs | 167 ---- ...0240401075111_UpdateCartTables.Designer.cs | 778 ---------------- .../20240401075111_UpdateCartTables.cs | 35 - ...240401075932_UpdateCartTables1.Designer.cs | 779 ---------------- .../20240401075932_UpdateCartTables1.cs | 54 -- ...20240417175416_UpdateUserTable.Designer.cs | 749 ---------------- .../20240417175416_UpdateUserTable.cs | 136 --- ...lesToMakeModifiedOnNotRequired.Designer.cs | 747 ---------------- ...UpdateTablesToMakeModifiedOnNotRequired.cs | 177 ---- ...240501170224_UpdateOrdersTable.Designer.cs | 751 ---------------- .../20240501170224_UpdateOrdersTable.cs | 28 - .../20240824162540_UpdateAddress.Designer.cs | 750 ---------------- .../20240824162540_UpdateAddress.cs | 47 - ...301_addEmailColumnsToUserTable.Designer.cs | 754 ---------------- ...240930175301_addEmailColumnsToUserTable.cs | 28 - ...002140454_makeEmailNotRequired.Designer.cs | 753 ---------------- .../20241002140454_makeEmailNotRequired.cs | 36 - ..._deleteUnusedColumnFromProduct.Designer.cs | 749 ---------------- ...020135147_deleteUnusedColumnFromProduct.cs | 29 - ...71255_AddCustomerIdInUserTable.Designer.cs | 753 ---------------- ...20241201171255_AddCustomerIdInUserTable.cs | 29 - ...41202145010_UpdatePaymentTable.Designer.cs | 758 ---------------- .../20241202145010_UpdatePaymentTable.cs | 52 -- ...02154947_UpdatePaymentTableRef.Designer.cs | 756 ---------------- .../20241202154947_UpdatePaymentTableRef.cs | 56 -- ...41211115321_UpdateRatingColumn.Designer.cs | 758 ---------------- .../20241211115321_UpdateRatingColumn.cs | 70 -- ...41211135310_UpdateProductTable.Designer.cs | 776 ---------------- .../20241211135310_UpdateProductTable.cs | 83 -- .../20241212165458_UpdateDatabase.Designer.cs | 795 ----------------- .../20241212165458_UpdateDatabase.cs | 138 --- ...213084430_UpdateCartItemsTable.Designer.cs | 794 ----------------- .../20241213084430_UpdateCartItemsTable.cs | 35 - ...1219151944_AddPermissionsTable.Designer.cs | 836 ------------------ .../20241219151944_AddPermissionsTable.cs | 68 -- .../20241222122248_UpdateUsersTable.cs | 154 ---- ...250123152917_InitialDBChanges.Designer.cs} | 8 +- .../20250123152917_InitialDBChanges.cs | 716 +++++++++++++++ .../Migrations/AppDbContextModelSnapshot.cs | 4 +- 48 files changed, 743 insertions(+), 18092 deletions(-) delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs rename src/Shopizy.Infrastructure/Migrations/{20241222122248_UpdateUsersTable.Designer.cs => 20250123152917_InitialDBChanges.Designer.cs} (99%) create mode 100644 src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs diff --git a/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs b/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs index 258b2b3..a4892ff 100644 --- a/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs +++ b/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs @@ -1,16 +1,17 @@ using ErrorOr; using MediatR; +using Shopizy.Application.Common.Caching; using Shopizy.Application.Common.Interfaces.Persistence; using Shopizy.Domain.Common.CustomErrors; -using Shopizy.Domain.Orders.ValueObjects; using Shopizy.Domain.Users.ValueObjects; namespace Shopizy.Application.Users.Commands.UpdateUser; -public class UpdateUserCommandHandler(IUserRepository userRepository) +public class UpdateUserCommandHandler(IUserRepository userRepository, ICacheHelper cacheHelper) : IRequestHandler> { private readonly IUserRepository _userRepository = userRepository; + private readonly ICacheHelper _cacheHelper = cacheHelper; public async Task> Handle( UpdateUserCommand request, @@ -42,6 +43,8 @@ CancellationToken cancellationToken return CustomErrors.User.UserNotUpdated; } + await _cacheHelper.RemoveAsync($"user-{user.Id.Value}"); + return Result.Success; } } diff --git a/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL b/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL index aa3b3c8..e115164 100644 --- a/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL +++ b/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL @@ -26,18 +26,17 @@ INSERT INTO [Categories] ([id], [name], [parentId]) VALUES -INSERT INTO [Products] ([id], [name], [description], [ShortDescription], [categoryId], [sku], [stockQuantity], [unitPrice_Amount], [unitPrice_Currency], [discount], [brand], [barcode], [tags], [averageRating_Value], [averageRating_NumRatings], [CreatedOn], [Colors], [Sizes]) VALUES - ('571D3D66-18F2-4DA8-A57B-D06D4D1C9EEF', 'Black Rockstar', 'High quality black t-shirt', 'High quality black t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000000T', '10', '20', '0', '10', 'Zara', 'MC-10000000T', 't-shirt, zara, men, new', '4.8', '5', GETDATE(), 'Black,Gray,Orange,Pink', 'XS,S,M,L,XL,2XL'), - ('096A127A-65AF-4C0C-A294-2E1990136711', 'Premium Purple', 'High quality purple t-shirt', 'High quality purple t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000002T', '5', '22', '0', '10', 'ck', 'MC-10000002T', 't-shirt, ck, men, new, premium', '4.9', '7', GETDATE(), 'Black,Orange,Pink,White', 'XS,S,M,L,XL,2XL'), - ('8419FD69-61A5-4D9D-A289-1E377CC17082', 'Red Dragon', 'Premium quality red sweater', 'Premium quality red sweater', '632DFDA9-CC2E-487B-8C88-608005F124E2', 'MC-10000000S', '20', '40', '0', '10', 'h&m', 'MC-10000000S', 'sweater, h&m, men, hot, premium', '4.7', '15', GETDATE(), 'Red,Orange,Pink,White', 'XS,S,M,L,XL,2XL'), - ('CBB8A3A9-03DB-40E4-A89B-9C91D21B3934', 'Ash life', 'High quality t-shirt', 'High quality t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000004T', '15', '25', '0', '10', 'ck', 'MC-10000004T', 't-shirt, ck, men, new, premium', '4.7', '5', GETDATE(), 'Black,Gray,Pink,White', 'XS,S,M,L,XL,2XL'), - ('96A1503F-B7EA-4C12-8946-89035399F45E', 'Red Star', 'High quality t-shirt for men', 'High quality t-shirt for men', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000006T', '30', '20', '0', '10', 'Boss', 'MC-10000006T', 't-shirt, boss, men', '4.6', '10', GETDATE(), 'Red,Black,Orange', 'XS,S,M,L,XL,2XL'), - ('E02500EA-2957-4601-A051-951CB9957CBE', 'Black Stone', 'Premium quality t-shirt for women', 'Premium quality t-shirt for women', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000000T', '30', '40', '0', '10', 'Adidas', 'FC-10000000T', 't-shirt, adidas, new, premium', '4.9', '15', GETDATE(), 'Black,Gray', 'XS,S,M,L,XL,2XL'), - ('A34BA283-62A1-43C6-8FB0-748DBDE8BA7D', 'Elegant peach', 'High quality women top', 'High quality women top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000002T', '10', '20', '0', '10', 'h&m', 'FC-10000002T', 'top, h&m, new', '4.7', '15', GETDATE(), ',Orange,Pink,Peach', 'XS,S,M,L,XL,2XL'), - ('D7C96816-1656-4DBC-B709-0F626807347F', 'Pure White', 'High quality women t-shirt', 'High quality women t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000004T', '20', '20', '0', '10', 'ck', 'FC-10000004T', 't-shirt, ck, new', '4.7', '5', GETDATE(), 'White', 'XS,S,M,L,XL,2XL'), - ('DF22BA6B-A15B-4125-AF29-07E242AF6F2D', 'Natural Green', 'High quality t-shirt', 'High quality t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000006T', '20', '25', '0', '5', 'Zara', 'FC-10000006T', 't-shirt, zara', '4.6', '5', GETDATE(), 'Green', 'XS,S,M,L,XL,2XL'), - ('9EB9982F-E672-4184-8399-044277EEF754', 'New Way', 'Premium quality top', 'Premium quality top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000008T', '30', '30', '0', '10', 'Nike', 'FC-10000008T', 'top, nike, new', '4.8', '20', GETDATE(), 'Black,Gray,Orange,Pink,White', 'XS,S,M,L,XL,2XL'); - +INSERT INTO [Products] ([id], [name], [description], [ShortDescription], [categoryId], [sku], [stockQuantity], [unitPrice_Amount], [unitPrice_Currency], [discount], [brand], [barcode], [tags], [averageRating_Value], [averageRating_NumRatings], [CreatedOn], [Colors], [Sizes], [Favourites]) VALUES + ('571D3D66-18F2-4DA8-A57B-D06D4D1C9EEF', 'Black Rockstar', 'High quality black t-shirt', 'High quality black t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000000T', '10', '20', '0', '10', 'Zara', 'MC-10000000T', 't-shirt, zara, men, new', '4.8', '5', GETDATE(), 'Black,Gray,Orange,Pink', 'XS,S,M,L,XL,2XL', 0), + ('096A127A-65AF-4C0C-A294-2E1990136711', 'Premium Purple', 'High quality purple t-shirt', 'High quality purple t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000002T', '5', '22', '0', '10', 'ck', 'MC-10000002T', 't-shirt, ck, men, new, premium', '4.9', '7', GETDATE(), 'Black,Orange,Pink,White', 'XS,S,M,L,XL,2XL', 0), + ('8419FD69-61A5-4D9D-A289-1E377CC17082', 'Red Dragon', 'Premium quality red sweater', 'Premium quality red sweater', '632DFDA9-CC2E-487B-8C88-608005F124E2', 'MC-10000000S', '20', '40', '0', '10', 'h&m', 'MC-10000000S', 'sweater, h&m, men, hot, premium', '4.7', '15', GETDATE(), 'Red,Orange,Pink,White', 'XS,S,M,L,XL,2XL', 0), + ('CBB8A3A9-03DB-40E4-A89B-9C91D21B3934', 'Ash life', 'High quality t-shirt', 'High quality t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000004T', '15', '25', '0', '10', 'ck', 'MC-10000004T', 't-shirt, ck, men, new, premium', '4.7', '5', GETDATE(), 'Black,Gray,Pink,White', 'XS,S,M,L,XL,2XL', 0), + ('96A1503F-B7EA-4C12-8946-89035399F45E', 'Red Star', 'High quality t-shirt for men', 'High quality t-shirt for men', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000006T', '30', '20', '0', '10', 'Boss', 'MC-10000006T', 't-shirt, boss, men', '4.6', '10', GETDATE(), 'Red,Black,Orange', 'XS,S,M,L,XL,2XL', 0), + ('E02500EA-2957-4601-A051-951CB9957CBE', 'Black Stone', 'Premium quality t-shirt for women', 'Premium quality t-shirt for women', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000000T', '30', '40', '0', '10', 'Adidas', 'FC-10000000T', 't-shirt, adidas, new, premium', '4.9', '15', GETDATE(), 'Black,Gray', 'XS,S,M,L,XL,2XL', 0), + ('A34BA283-62A1-43C6-8FB0-748DBDE8BA7D', 'Elegant peach', 'High quality women top', 'High quality women top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000002T', '10', '20', '0', '10', 'h&m', 'FC-10000002T', 'top, h&m, new', '4.7', '15', GETDATE(), ',Orange,Pink,Peach', 'XS,S,M,L,XL,2XL', 0), + ('D7C96816-1656-4DBC-B709-0F626807347F', 'Pure White', 'High quality women t-shirt', 'High quality women t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000004T', '20', '20', '0', '10', 'ck', 'FC-10000004T', 't-shirt, ck, new', '4.7', '5', GETDATE(), 'White', 'XS,S,M,L,XL,2XL', 0), + ('DF22BA6B-A15B-4125-AF29-07E242AF6F2D', 'Natural Green', 'High quality t-shirt', 'High quality t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000006T', '20', '25', '0', '5', 'Zara', 'FC-10000006T', 't-shirt, zara', '4.6', '5', GETDATE(), 'Green', 'XS,S,M,L,XL,2XL', 0), + ('9EB9982F-E672-4184-8399-044277EEF754', 'New Way', 'Premium quality top', 'Premium quality top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000008T', '30', '30', '0', '10', 'Nike', 'FC-10000008T', 'top, nike, new', '4.8', '20', GETDATE(), 'Black,Gray,Orange,Pink,White', 'XS,S,M,L,XL,2XL', 0); INSERT INTO [ProductImages] ([id], [productId], [imageUrl], [seq], [publicId]) VALUES ('4DBB9D7F-5B09-4ECF-AEB9-B1F5F6473379', '571D3D66-18F2-4DA8-A57B-D06D4D1C9EEF', 'https://res.cloudinary.com/akazad13/image/upload/v1729420812/shopizy/mpjks43jpxo9eagempgu.jpg', '0', 'mpjks43jpxo9eagempgu'), @@ -53,11 +52,11 @@ INSERT INTO [ProductImages] ([id], [productId], [imageUrl], [seq], [publicId]) V ('A8A70F86-7987-4BB4-A344-1B2133DCC609', '096A127A-65AF-4C0C-A294-2E1990136711', 'https://res.cloudinary.com/akazad13/image/upload/v1733579506/shopizy/men2_2_d4dn3p.jpg', 1, 'men2_2_d4dn3p'); INSERT INTO ProductReviews(Id, UserId, ProductId, Rating_Value, Comment, CreatedOn) -VALUES('20AB2C8F-E880-45C3-8887-D0A0E2E0E763','E68D8E76-72A1-42ED-91D0-0ED0296D662E','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), -('C75B65D5-13D1-4FC9-A81E-19D7FB3B7784','67726B00-2647-4817-BFCB-3781EBD97E0F','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), -('41B53394-5014-45E6-9540-B7FA05782B6C','6EBA643C-D138-4D90-AA7C-6DBF935D8209','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Good T-Shirt!', GETDATE()), -('F9CA8F97-2B91-4EAD-88D7-78496A92616A','88D9AF82-BEF4-4042-8E55-B01B89F23E68','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Recommanded!', GETDATE()), -('7ED64773-2ED6-4BFB-BBA0-E267BA4A8208','E68D8E76-72A1-42ED-91D0-0ED0296D662E','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Looks good', GETDATE()); +VALUES('20AB2C8F-E880-45C3-8887-D0A0E2E0E763','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), +('C75B65D5-13D1-4FC9-A81E-19D7FB3B7784','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), +('41B53394-5014-45E6-9540-B7FA05782B6C','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Good T-Shirt!', GETDATE()), +('F9CA8F97-2B91-4EAD-88D7-78496A92616A','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Recommanded!', GETDATE()), +('7ED64773-2ED6-4BFB-BBA0-E267BA4A8208','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Looks good', GETDATE()); diff --git a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs deleted file mode 100644 index d4e580a..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs +++ /dev/null @@ -1,713 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240303163205_InitialChanges")] - partial class InitialChanges - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId") - .IsUnique(); - - b.HasIndex("OrderId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.HasIndex("ProductId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("Orders") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", "Customer") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "CustomerId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Customer"); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("ProductReviews") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs b/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs deleted file mode 100644 index b5ec666..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs +++ /dev/null @@ -1,508 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class InitialChanges : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Categories", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("PK_Categories", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "PromoCodes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Code = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: false), - Description = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - Discount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - IsPerchantage = table.Column( - type: "bit", - nullable: false, - defaultValue: true - ), - IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), - NumOfTimeUsed = table.Column(type: "int", nullable: false, defaultValue: 0), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_PromoCodes", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - FirstName = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - LastName = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - Phone = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: true), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "Products", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - Description = table.Column( - type: "nvarchar(200)", - maxLength: 200, - nullable: false - ), - CategoryId = table.Column(type: "uniqueidentifier", nullable: false), - SKU = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - StockQuantity = table.Column(type: "int", nullable: false), - UnitPrice_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - UnitPrice_Currency = table.Column(type: "int", nullable: false), - Discount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: true - ), - Brand = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - Barcode = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - Tags = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - AverageRating_Value = table.Column( - type: "float(18)", - precision: 18, - scale: 2, - nullable: false - ), - AverageRating_NumRatings = table.Column(type: "int", nullable: false), - BreadCrums = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Products", x => x.Id); - table.ForeignKey( - name: "FK_Products_Categories_CategoryId", - column: x => x.CategoryId, - principalTable: "Categories", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateTable( - name: "Customers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ProfileImageUrl = table.Column(type: "nvarchar(max)", nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - Address_Line = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - Address_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: true - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Customers", x => x.Id); - table.ForeignKey( - name: "FK_Customers_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateTable( - name: "ProductImages", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - ImageUrl = table.Column(type: "nvarchar(max)", nullable: false), - Seq = table.Column(type: "int", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_ProductImages", x => new { x.ProductId, x.Id }); - table.ForeignKey( - name: "FK_ProductImages_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false), - DeliveryCharge_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - DeliveryCharge_Currency = table.Column(type: "int", nullable: false), - OrderStatus = table.Column(type: "int", nullable: false), - PromoCode = table.Column( - type: "nvarchar(15)", - maxLength: 15, - nullable: true - ), - ShippingAddress_Line = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - ShippingAddress_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - ShippingAddress_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - ShippingAddress_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - ShippingAddress_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: false - ), - PaymentStatus = table.Column( - type: "nvarchar(20)", - maxLength: 20, - nullable: false - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Orders", x => x.Id); - table.ForeignKey( - name: "FK_Orders_Customers_CustomerId", - column: x => x.CustomerId, - principalTable: "Customers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "ProductReviews", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Rating_Value = table.Column( - type: "float(18)", - precision: 18, - scale: 2, - nullable: false - ), - Comment = table.Column( - type: "nvarchar(1000)", - maxLength: 1000, - nullable: true - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_ProductReviews", x => x.Id); - table.ForeignKey( - name: "FK_ProductReviews_Customers_CustomerId", - column: x => x.CustomerId, - principalTable: "Customers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_ProductReviews_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "OrderItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - OrderId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - PictureUrl = table.Column(type: "nvarchar(max)", nullable: true), - UnitPrice_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - UnitPrice_Currency = table.Column(type: "int", nullable: false), - Quantity = table.Column(type: "int", nullable: false), - Discount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - }, - constraints: table => - { - table.PrimaryKey("PK_OrderItems", x => new { x.Id, x.OrderId }); - table.ForeignKey( - name: "FK_OrderItems_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "Payments", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - OrderId = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false), - PaymentMethod = table.Column( - type: "nvarchar(20)", - maxLength: 20, - nullable: false - ), - TransactionId = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: true - ), - PaymentStatus = table.Column(type: "int", nullable: false), - Total_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - Total_Currency = table.Column(type: "int", nullable: false), - BillingAddress_Line = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - BillingAddress_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - BillingAddress_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - BillingAddress_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - BillingAddress_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: false - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Payments", x => x.Id); - table.ForeignKey( - name: "FK_Payments_Customers_CustomerId", - column: x => x.CustomerId, - principalTable: "Customers", - principalColumn: "Id" - ); - table.ForeignKey( - name: "FK_Payments_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_Customers_UserId", - table: "Customers", - column: "UserId", - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_OrderItems_OrderId", - table: "OrderItems", - column: "OrderId" - ); - - migrationBuilder.CreateIndex( - name: "IX_Orders_CustomerId", - table: "Orders", - column: "CustomerId" - ); - - migrationBuilder.CreateIndex( - name: "IX_Payments_CustomerId", - table: "Payments", - column: "CustomerId", - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_Payments_OrderId", - table: "Payments", - column: "OrderId", - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_ProductReviews_CustomerId", - table: "ProductReviews", - column: "CustomerId" - ); - - migrationBuilder.CreateIndex( - name: "IX_ProductReviews_ProductId", - table: "ProductReviews", - column: "ProductId" - ); - - migrationBuilder.CreateIndex( - name: "IX_Products_CategoryId", - table: "Products", - column: "CategoryId" - ); - - migrationBuilder.CreateIndex( - name: "IX_PromoCodes_Code", - table: "PromoCodes", - column: "Code" - ); - - migrationBuilder.CreateIndex(name: "IX_Users_Phone", table: "Users", column: "Phone"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "OrderItems"); - - migrationBuilder.DropTable(name: "Payments"); - - migrationBuilder.DropTable(name: "ProductImages"); - - migrationBuilder.DropTable(name: "ProductReviews"); - - migrationBuilder.DropTable(name: "PromoCodes"); - - migrationBuilder.DropTable(name: "Orders"); - - migrationBuilder.DropTable(name: "Products"); - - migrationBuilder.DropTable(name: "Customers"); - - migrationBuilder.DropTable(name: "Categories"); - - migrationBuilder.DropTable(name: "Users"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs deleted file mode 100644 index 0ba565b..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs +++ /dev/null @@ -1,718 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240325132753_UpdateProductImageTable")] - partial class UpdateProductImageTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId") - .IsUnique(); - - b.HasIndex("OrderId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.HasIndex("ProductId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("Orders") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", "Customer") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "CustomerId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Customer"); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("ProductReviews") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs b/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs deleted file mode 100644 index 4f984ac..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateProductImageTable : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "PublicId", - table: "ProductImages", - type: "nvarchar(100)", - maxLength: 100, - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "PublicId", - table: "ProductImages"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs deleted file mode 100644 index 5ac3cd8..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs +++ /dev/null @@ -1,778 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240329185149_AddedCartTable")] - partial class AddedCartTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId") - .IsUnique(); - - b.HasIndex("OrderId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.HasIndex("ProductId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("Orders") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", "Customer") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "CustomerId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Customer"); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("ProductReviews") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs b/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs deleted file mode 100644 index eb9af8d..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class AddedCartTable : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Carts", - columns: table => - new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Carts", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "LineItems", - columns: table => - new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CartId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Quantity = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LineItems", x => new { x.Id, x.CartId }); - table.ForeignKey( - name: "FK_LineItems_Carts_CartId", - column: x => x.CartId, - principalTable: "Carts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_LineItems_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_Carts_CustomerId", - table: "Carts", - column: "CustomerId" - ); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_CartId", - table: "LineItems", - column: "CartId" - ); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_ProductId", - table: "LineItems", - column: "ProductId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "LineItems"); - - migrationBuilder.DropTable(name: "Carts"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs deleted file mode 100644 index f7f624c..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs +++ /dev/null @@ -1,778 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240331173916_UpdateTables")] - partial class UpdateTables - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs b/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs deleted file mode 100644 index 53eadf5..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs +++ /dev/null @@ -1,167 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateTables : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Orders_Customers_CustomerId", - table: "Orders"); - - migrationBuilder.DropForeignKey( - name: "FK_Payments_Customers_CustomerId", - table: "Payments"); - - migrationBuilder.DropForeignKey( - name: "FK_ProductReviews_Customers_CustomerId", - table: "ProductReviews"); - - migrationBuilder.RenameColumn( - name: "CustomerId", - table: "ProductReviews", - newName: "UserId"); - - migrationBuilder.RenameIndex( - name: "IX_ProductReviews_CustomerId", - table: "ProductReviews", - newName: "IX_ProductReviews_UserId"); - - migrationBuilder.RenameColumn( - name: "CustomerId", - table: "Payments", - newName: "UserId"); - - migrationBuilder.RenameIndex( - name: "IX_Payments_CustomerId", - table: "Payments", - newName: "IX_Payments_UserId"); - - migrationBuilder.RenameColumn( - name: "CustomerId", - table: "Orders", - newName: "UserId"); - - migrationBuilder.RenameIndex( - name: "IX_Orders_CustomerId", - table: "Orders", - newName: "IX_Orders_UserId"); - - migrationBuilder.RenameColumn( - name: "CustomerId", - table: "Carts", - newName: "UserId"); - - migrationBuilder.RenameIndex( - name: "IX_Carts_CustomerId", - table: "Carts", - newName: "IX_Carts_UserId"); - - migrationBuilder.AddForeignKey( - name: "FK_Orders_Users_UserId", - table: "Orders", - column: "UserId", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Payments_Users_UserId", - table: "Payments", - column: "UserId", - principalTable: "Users", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_ProductReviews_Users_UserId", - table: "ProductReviews", - column: "UserId", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Orders_Users_UserId", - table: "Orders"); - - migrationBuilder.DropForeignKey( - name: "FK_Payments_Users_UserId", - table: "Payments"); - - migrationBuilder.DropForeignKey( - name: "FK_ProductReviews_Users_UserId", - table: "ProductReviews"); - - migrationBuilder.RenameColumn( - name: "UserId", - table: "ProductReviews", - newName: "CustomerId"); - - migrationBuilder.RenameIndex( - name: "IX_ProductReviews_UserId", - table: "ProductReviews", - newName: "IX_ProductReviews_CustomerId"); - - migrationBuilder.RenameColumn( - name: "UserId", - table: "Payments", - newName: "CustomerId"); - - migrationBuilder.RenameIndex( - name: "IX_Payments_UserId", - table: "Payments", - newName: "IX_Payments_CustomerId"); - - migrationBuilder.RenameColumn( - name: "UserId", - table: "Orders", - newName: "CustomerId"); - - migrationBuilder.RenameIndex( - name: "IX_Orders_UserId", - table: "Orders", - newName: "IX_Orders_CustomerId"); - - migrationBuilder.RenameColumn( - name: "UserId", - table: "Carts", - newName: "CustomerId"); - - migrationBuilder.RenameIndex( - name: "IX_Carts_UserId", - table: "Carts", - newName: "IX_Carts_CustomerId"); - - migrationBuilder.AddForeignKey( - name: "FK_Orders_Customers_CustomerId", - table: "Orders", - column: "CustomerId", - principalTable: "Customers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Payments_Customers_CustomerId", - table: "Payments", - column: "CustomerId", - principalTable: "Customers", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_ProductReviews_Customers_CustomerId", - table: "ProductReviews", - column: "CustomerId", - principalTable: "Customers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs deleted file mode 100644 index e2f8288..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs +++ /dev/null @@ -1,778 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240401075111_UpdateCartTables")] - partial class UpdateCartTables - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId", "ProductId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs b/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs deleted file mode 100644 index 0ccccd6..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateCartTables : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_LineItems", - table: "LineItems"); - - migrationBuilder.AddPrimaryKey( - name: "PK_LineItems", - table: "LineItems", - columns: new[] { "Id", "CartId", "ProductId" }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_LineItems", - table: "LineItems"); - - migrationBuilder.AddPrimaryKey( - name: "PK_LineItems", - table: "LineItems", - columns: new[] { "Id", "CartId" }); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs deleted file mode 100644 index 3f707c9..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs +++ /dev/null @@ -1,779 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240401075932_UpdateCartTables1")] - partial class UpdateCartTables1 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs b/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs deleted file mode 100644 index 9be292e..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateCartTables1 : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_LineItems", - table: "LineItems"); - - migrationBuilder.DropIndex( - name: "IX_LineItems_CartId", - table: "LineItems"); - - migrationBuilder.AddPrimaryKey( - name: "PK_LineItems", - table: "LineItems", - columns: new[] { "Id", "CartId" }); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_CartId_ProductId", - table: "LineItems", - columns: new[] { "CartId", "ProductId" }, - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_LineItems", - table: "LineItems"); - - migrationBuilder.DropIndex( - name: "IX_LineItems_CartId_ProductId", - table: "LineItems"); - - migrationBuilder.AddPrimaryKey( - name: "PK_LineItems", - table: "LineItems", - columns: new[] { "Id", "CartId", "ProductId" }); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_CartId", - table: "LineItems", - column: "CartId"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs deleted file mode 100644 index fa98f30..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs +++ /dev/null @@ -1,749 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240417175416_UpdateUserTable")] - partial class UpdateUserTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs b/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs deleted file mode 100644 index dbed064..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs +++ /dev/null @@ -1,136 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateUserTable : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "Customers"); - - migrationBuilder.AddColumn( - name: "Address_City", - table: "Users", - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "Address_Country", - table: "Users", - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "Address_Line", - table: "Users", - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "Address_State", - table: "Users", - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "Address_ZipCode", - table: "Users", - type: "nvarchar(10)", - maxLength: 10, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "ProfileImageUrl", - table: "Users", - type: "nvarchar(max)", - nullable: true - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn(name: "Address_City", table: "Users"); - - migrationBuilder.DropColumn(name: "Address_Country", table: "Users"); - - migrationBuilder.DropColumn(name: "Address_Line", table: "Users"); - - migrationBuilder.DropColumn(name: "Address_State", table: "Users"); - - migrationBuilder.DropColumn(name: "Address_ZipCode", table: "Users"); - - migrationBuilder.DropColumn(name: "ProfileImageUrl", table: "Users"); - - migrationBuilder.CreateTable( - name: "Customers", - columns: table => - new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - ProfileImageUrl = table.Column( - type: "nvarchar(max)", - nullable: true - ), - Address_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_Line = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - Address_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: true - ) - }, - constraints: table => - { - table.PrimaryKey("PK_Customers", x => x.Id); - table.ForeignKey( - name: "FK_Customers_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_Customers_UserId", - table: "Customers", - column: "UserId", - unique: true - ); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs deleted file mode 100644 index 7dff433..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs +++ /dev/null @@ -1,747 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240420191703_UpdateTablesToMakeModifiedOnNotRequired")] - partial class UpdateTablesToMakeModifiedOnNotRequired - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs b/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs deleted file mode 100644 index 72491c4..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs +++ /dev/null @@ -1,177 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateTablesToMakeModifiedOnNotRequired : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Users", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "PromoCodes", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Products", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "ProductReviews", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Payments", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "PaymentStatus", - table: "Orders", - type: "int", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(20)", - oldMaxLength: 20 - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Orders", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Carts", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Users", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "PromoCodes", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Products", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "ProductReviews", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Payments", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "PaymentStatus", - table: "Orders", - type: "nvarchar(20)", - maxLength: 20, - nullable: false, - oldClrType: typeof(int), - oldType: "int" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Orders", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Carts", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs deleted file mode 100644 index 57d8b84..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs +++ /dev/null @@ -1,751 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240501170224_UpdateOrdersTable")] - partial class UpdateOrdersTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs b/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs deleted file mode 100644 index 288fb65..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateOrdersTable : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CancellationReason", - table: "Orders", - type: "nvarchar(200)", - maxLength: 200, - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CancellationReason", - table: "Orders"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs deleted file mode 100644 index f8f0c37..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs +++ /dev/null @@ -1,750 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240824162540_UpdateAddress")] - partial class UpdateAddress - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs b/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs deleted file mode 100644 index 4608f50..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateAddress : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "Address_Line", - table: "Users", - newName: "Address_Street"); - - migrationBuilder.RenameColumn( - name: "BillingAddress_Line", - table: "Payments", - newName: "BillingAddress_Street"); - - migrationBuilder.RenameColumn( - name: "ShippingAddress_Line", - table: "Orders", - newName: "ShippingAddress_Street"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "Address_Street", - table: "Users", - newName: "Address_Line"); - - migrationBuilder.RenameColumn( - name: "BillingAddress_Street", - table: "Payments", - newName: "BillingAddress_Line"); - - migrationBuilder.RenameColumn( - name: "ShippingAddress_Street", - table: "Orders", - newName: "ShippingAddress_Line"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs deleted file mode 100644 index 4965186..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs +++ /dev/null @@ -1,754 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240930175301_addEmailColumnsToUserTable")] - partial class addEmailColumnsToUserTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs b/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs deleted file mode 100644 index 15ba2f2..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class addEmailColumnsToUserTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Email", - table: "Users", - type: "nvarchar(max)", - nullable: false, - defaultValue: "" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn(name: "Email", table: "Users"); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs deleted file mode 100644 index a2a020a..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs +++ /dev/null @@ -1,753 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241002140454_makeEmailNotRequired")] - partial class makeEmailNotRequired - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs b/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs deleted file mode 100644 index c77ced4..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class makeEmailNotRequired : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "nvarchar(max)", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs deleted file mode 100644 index fb56d31..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs +++ /dev/null @@ -1,749 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241020135147_deleteUnusedColumnFromProduct")] - partial class deleteUnusedColumnFromProduct - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs b/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs deleted file mode 100644 index f74a330..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class deleteUnusedColumnFromProduct : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "BreadCrums", - table: "Products"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "BreadCrums", - table: "Products", - type: "nvarchar(100)", - maxLength: 100, - nullable: true); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs deleted file mode 100644 index aafa8b9..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs +++ /dev/null @@ -1,753 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241201171255_AddCustomerIdInUserTable")] - partial class AddCustomerIdInUserTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs b/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs deleted file mode 100644 index fad4155..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class AddCustomerIdInUserTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CustomerId", - table: "Users", - type: "nvarchar(256)", - maxLength: 256, - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CustomerId", - table: "Users"); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs deleted file mode 100644 index 47ee956..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs +++ /dev/null @@ -1,758 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241202145010_UpdatePaymentTable")] - partial class UpdatePaymentTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs b/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs deleted file mode 100644 index d735f6f..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdatePaymentTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "TransactionId", - table: "Payments", - type: "nvarchar(260)", - maxLength: 260, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(50)", - oldMaxLength: 50, - oldNullable: true); - - migrationBuilder.AddColumn( - name: "PaymentMethodId", - table: "Payments", - type: "nvarchar(260)", - maxLength: 260, - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "PaymentMethodId", - table: "Payments"); - - migrationBuilder.AlterColumn( - name: "TransactionId", - table: "Payments", - type: "nvarchar(50)", - maxLength: 50, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(260)", - oldMaxLength: 260, - oldNullable: true); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs deleted file mode 100644 index e703d89..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs +++ /dev/null @@ -1,756 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241202154947_UpdatePaymentTableRef")] - partial class UpdatePaymentTableRef - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs b/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs deleted file mode 100644 index a0d48e9..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdatePaymentTableRef : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_Payments_OrderId", - table: "Payments"); - - migrationBuilder.DropIndex( - name: "IX_Payments_UserId", - table: "Payments"); - - migrationBuilder.CreateIndex( - name: "IX_Payments_OrderId", - table: "Payments", - column: "OrderId"); - - migrationBuilder.CreateIndex( - name: "IX_Payments_UserId", - table: "Payments", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_Payments_OrderId", - table: "Payments"); - - migrationBuilder.DropIndex( - name: "IX_Payments_UserId", - table: "Payments"); - - migrationBuilder.CreateIndex( - name: "IX_Payments_OrderId", - table: "Payments", - column: "OrderId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Payments_UserId", - table: "Payments", - column: "UserId", - unique: true); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs deleted file mode 100644 index a573aae..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs +++ /dev/null @@ -1,758 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241211115321_UpdateRatingColumn")] - partial class UpdateRatingColumn - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs b/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs deleted file mode 100644 index 6f31cda..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateRatingColumn : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "AverageRating_Value", - table: "Products", - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false, - oldClrType: typeof(double), - oldType: "float(18)", - oldPrecision: 18, - oldScale: 2 - ); - - migrationBuilder.AlterColumn( - name: "Rating_Value", - table: "ProductReviews", - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false, - oldClrType: typeof(double), - oldType: "float(18)", - oldPrecision: 18, - oldScale: 2 - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "AverageRating_Value", - table: "Products", - type: "float(18)", - precision: 18, - scale: 2, - nullable: false, - oldClrType: typeof(decimal), - oldType: "decimal(18,2)", - oldPrecision: 18, - oldScale: 2 - ); - - migrationBuilder.AlterColumn( - name: "Rating_Value", - table: "ProductReviews", - type: "float(18)", - precision: 18, - scale: 2, - nullable: false, - oldClrType: typeof(decimal), - oldType: "decimal(18,2)", - oldPrecision: 18, - oldScale: 2 - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs deleted file mode 100644 index ebe8da7..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs +++ /dev/null @@ -1,776 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241211135310_UpdateProductTable")] - partial class UpdateProductTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("Colors") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("Favourites") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ShortDescription") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs b/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs deleted file mode 100644 index af70866..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateProductTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Name", - table: "Products", - type: "nvarchar(50)", - maxLength: 50, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(100)", - oldMaxLength: 100 - ); - - migrationBuilder.AddColumn( - name: "Colors", - table: "Products", - type: "nvarchar(50)", - maxLength: 50, - nullable: false, - defaultValue: "" - ); - - migrationBuilder.AddColumn( - name: "Favourites", - table: "Products", - type: "int", - nullable: false, - defaultValue: 0 - ); - - migrationBuilder.AddColumn( - name: "ShortDescription", - table: "Products", - type: "nvarchar(100)", - maxLength: 100, - nullable: false, - defaultValue: "" - ); - - migrationBuilder.AddColumn( - name: "Sizes", - table: "Products", - type: "nvarchar(20)", - maxLength: 20, - nullable: false, - defaultValue: "" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn(name: "Colors", table: "Products"); - - migrationBuilder.DropColumn(name: "Favourites", table: "Products"); - - migrationBuilder.DropColumn(name: "ShortDescription", table: "Products"); - - migrationBuilder.DropColumn(name: "Sizes", table: "Products"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Products", - type: "nvarchar(100)", - maxLength: 100, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(50)", - oldMaxLength: 50 - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs deleted file mode 100644 index f078d26..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs +++ /dev/null @@ -1,795 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241212165458_UpdateDatabase")] - partial class UpdateDatabase - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("DeliveryMethod") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("Colors") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("Favourites") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ShortDescription") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.CartItem", "CartItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("CartItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("CartItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs b/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs deleted file mode 100644 index 0321948..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs +++ /dev/null @@ -1,138 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateDatabase : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "LineItems"); - - migrationBuilder.AddColumn( - name: "DeliveryMethod", - table: "Orders", - type: "int", - nullable: false, - defaultValue: 0 - ); - - migrationBuilder.AddColumn( - name: "Color", - table: "OrderItems", - type: "nvarchar(max)", - nullable: false, - defaultValue: "" - ); - - migrationBuilder.AddColumn( - name: "Size", - table: "OrderItems", - type: "nvarchar(max)", - nullable: false, - defaultValue: "" - ); - - migrationBuilder.CreateTable( - name: "CartItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CartId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Color = table.Column(type: "nvarchar(max)", nullable: false), - Size = table.Column(type: "nvarchar(max)", nullable: false), - Quantity = table.Column(type: "int", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_CartItems", x => new { x.Id, x.CartId }); - table.ForeignKey( - name: "FK_CartItems_Carts_CartId", - column: x => x.CartId, - principalTable: "Carts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_CartItems_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_CartId_ProductId", - table: "CartItems", - columns: new[] { "CartId", "ProductId" }, - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_ProductId", - table: "CartItems", - column: "ProductId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "CartItems"); - - migrationBuilder.DropColumn(name: "DeliveryMethod", table: "Orders"); - - migrationBuilder.DropColumn(name: "Color", table: "OrderItems"); - - migrationBuilder.DropColumn(name: "Size", table: "OrderItems"); - - migrationBuilder.CreateTable( - name: "LineItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CartId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Quantity = table.Column(type: "int", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_LineItems", x => new { x.Id, x.CartId }); - table.ForeignKey( - name: "FK_LineItems_Carts_CartId", - column: x => x.CartId, - principalTable: "Carts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_LineItems_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_CartId_ProductId", - table: "LineItems", - columns: new[] { "CartId", "ProductId" }, - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_ProductId", - table: "LineItems", - column: "ProductId" - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs deleted file mode 100644 index 02fea69..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs +++ /dev/null @@ -1,794 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241213084430_UpdateCartItemsTable")] - partial class UpdateCartItemsTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("DeliveryMethod") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("Colors") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("Favourites") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ShortDescription") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.CartItem", "CartItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("CartItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("CartItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs b/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs deleted file mode 100644 index e85f58b..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateCartItemsTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex(name: "IX_CartItems_CartId_ProductId", table: "CartItems"); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_CartId", - table: "CartItems", - column: "CartId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex(name: "IX_CartItems_CartId", table: "CartItems"); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_CartId_ProductId", - table: "CartItems", - columns: new[] { "CartId", "ProductId" }, - unique: true - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs deleted file mode 100644 index a19ad3e..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs +++ /dev/null @@ -1,836 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241219151944_AddPermissionsTable")] - partial class AddPermissionsTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("DeliveryMethod") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Permissions.Permission", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Permissions", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("Colors") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("Favourites") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ShortDescription") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.CartItem", "CartItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("CartItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("CartItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsMany("Shopizy.Domain.Permissions.ValueObjects.PermissionId", "PermissionIds", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasColumnType("uniqueidentifier") - .HasColumnName("PermissionId"); - - b1.HasKey("Id"); - - b1.HasIndex("UserId"); - - b1.ToTable("UserPermissionIds", (string)null); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - - b.Navigation("PermissionIds"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs b/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs deleted file mode 100644 index b0b313c..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class AddPermissionsTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Permissions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - }, - constraints: table => - { - table.PrimaryKey("PK_Permissions", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "UserPermissionIds", - columns: table => new - { - Id = table - .Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PermissionId = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_UserPermissionIds", x => x.Id); - table.ForeignKey( - name: "FK_UserPermissionIds_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_UserPermissionIds_UserId", - table: "UserPermissionIds", - column: "UserId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "Permissions"); - - migrationBuilder.DropTable(name: "UserPermissionIds"); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs b/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs deleted file mode 100644 index 102e761..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateUsersTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey(name: "FK_Orders_Users_UserId", table: "Orders"); - - migrationBuilder.DropIndex(name: "IX_Users_Phone", table: "Users"); - - migrationBuilder.DropIndex(name: "IX_Orders_UserId", table: "Orders"); - - migrationBuilder.AlterColumn( - name: "Phone", - table: "Users", - type: "nvarchar(15)", - maxLength: 15, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(15)", - oldMaxLength: 15 - ); - - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "nvarchar(50)", - maxLength: 50, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true - ); - - migrationBuilder.CreateTable( - name: "OrderIds", - columns: table => new - { - Id = table - .Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - OrderId = table.Column(type: "uniqueidentifier", nullable: false), - UseId = table.Column(type: "uniqueidentifier", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_OrderIds", x => x.Id); - table.ForeignKey( - name: "FK_OrderIds_Users_UseId", - column: x => x.UseId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "ProductReviewIds", - columns: table => new - { - Id = table - .Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ProductReviewId = table.Column(type: "uniqueidentifier", nullable: false), - UseId = table.Column(type: "uniqueidentifier", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_ProductReviewIds", x => x.Id); - table.ForeignKey( - name: "FK_ProductReviewIds_Users_UseId", - column: x => x.UseId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex(name: "IX_Users_Email", table: "Users", column: "Email"); - - migrationBuilder.CreateIndex( - name: "IX_OrderIds_UseId", - table: "OrderIds", - column: "UseId" - ); - - migrationBuilder.CreateIndex( - name: "IX_ProductReviewIds_UseId", - table: "ProductReviewIds", - column: "UseId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "OrderIds"); - - migrationBuilder.DropTable(name: "ProductReviewIds"); - - migrationBuilder.DropIndex(name: "IX_Users_Email", table: "Users"); - - migrationBuilder.AlterColumn( - name: "Phone", - table: "Users", - type: "nvarchar(15)", - maxLength: 15, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(15)", - oldMaxLength: 15, - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(50)", - oldMaxLength: 50 - ); - - migrationBuilder.CreateIndex(name: "IX_Users_Phone", table: "Users", column: "Phone"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_UserId", - table: "Orders", - column: "UserId" - ); - - migrationBuilder.AddForeignKey( - name: "FK_Orders_Users_UserId", - table: "Orders", - column: "UserId", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.Designer.cs similarity index 99% rename from src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.Designer.cs rename to src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.Designer.cs index 63ae69c..582d33d 100644 --- a/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.Designer.cs +++ b/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.Designer.cs @@ -9,18 +9,18 @@ #nullable disable -namespace shopizy.Infrastructure.Migrations +namespace Shopizy.Infrastructure.Migrations { [DbContext(typeof(AppDbContext))] - [Migration("20241222122248_UpdateUsersTable")] - partial class UpdateUsersTable + [Migration("20250123152917_InitialDBChanges")] + partial class InitialDBChanges { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs b/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs new file mode 100644 index 0000000..cf69b69 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs @@ -0,0 +1,716 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Shopizy.Infrastructure.Migrations +{ + /// + public partial class InitialDBChanges : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Carts", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Carts", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Categories", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Categories", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + DeliveryMethod = table.Column(type: "int", nullable: false), + DeliveryCharge_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + DeliveryCharge_Currency = table.Column(type: "int", nullable: false), + OrderStatus = table.Column(type: "int", nullable: false), + CancellationReason = table.Column( + type: "nvarchar(200)", + maxLength: 200, + nullable: true + ), + PromoCode = table.Column( + type: "nvarchar(15)", + maxLength: 15, + nullable: true + ), + ShippingAddress_Street = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + ShippingAddress_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + ShippingAddress_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + ShippingAddress_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + ShippingAddress_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: false + ), + PaymentStatus = table.Column(type: "int", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Permissions", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + }, + constraints: table => + { + table.PrimaryKey("PK_Permissions", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "PromoCodes", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Code = table.Column( + type: "nvarchar(15)", + maxLength: 15, + nullable: false + ), + Description = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: true + ), + Discount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + IsPerchantage = table.Column( + type: "bit", + nullable: false, + defaultValue: true + ), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + NumOfTimeUsed = table.Column( + type: "int", + nullable: false, + defaultValue: 0 + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_PromoCodes", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + FirstName = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + LastName = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + Email = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + ProfileImageUrl = table.Column(type: "nvarchar(max)", nullable: true), + Phone = table.Column( + type: "nvarchar(15)", + maxLength: 15, + nullable: true + ), + Password = table.Column(type: "nvarchar(max)", nullable: true), + CustomerId = table.Column( + type: "nvarchar(256)", + maxLength: 256, + nullable: true + ), + Address_Street = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: true + ), + Address_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: true + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + ShortDescription = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + Description = table.Column( + type: "nvarchar(200)", + maxLength: 200, + nullable: false + ), + CategoryId = table.Column(type: "uniqueidentifier", nullable: false), + SKU = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + StockQuantity = table.Column(type: "int", nullable: false), + UnitPrice_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + UnitPrice_Currency = table.Column(type: "int", nullable: false), + Discount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: true + ), + Brand = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: true + ), + Colors = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + Sizes = table.Column( + type: "nvarchar(20)", + maxLength: 20, + nullable: false + ), + Favourites = table.Column(type: "int", nullable: false), + Barcode = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: true + ), + Tags = table.Column( + type: "nvarchar(200)", + maxLength: 200, + nullable: true + ), + AverageRating_Value = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + AverageRating_NumRatings = table.Column(type: "int", nullable: false), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + table.ForeignKey( + name: "FK_Products_Categories_CategoryId", + column: x => x.CategoryId, + principalTable: "Categories", + principalColumn: "Id" + ); + } + ); + + migrationBuilder.CreateTable( + name: "OrderItems", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + OrderId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + PictureUrl = table.Column(type: "nvarchar(max)", nullable: true), + UnitPrice_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + UnitPrice_Currency = table.Column(type: "int", nullable: false), + Color = table.Column(type: "nvarchar(max)", nullable: false), + Size = table.Column(type: "nvarchar(max)", nullable: false), + Quantity = table.Column(type: "int", nullable: false), + Discount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + }, + constraints: table => + { + table.PrimaryKey("PK_OrderItems", x => new { x.Id, x.OrderId }); + table.ForeignKey( + name: "FK_OrderItems_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "OrderIds", + columns: table => new + { + Id = table + .Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OrderId = table.Column(type: "uniqueidentifier", nullable: false), + UseId = table.Column(type: "uniqueidentifier", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_OrderIds", x => x.Id); + table.ForeignKey( + name: "FK_OrderIds_Users_UseId", + column: x => x.UseId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "Payments", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + OrderId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + PaymentMethod = table.Column( + type: "nvarchar(20)", + maxLength: 20, + nullable: false + ), + PaymentMethodId = table.Column( + type: "nvarchar(260)", + maxLength: 260, + nullable: false + ), + TransactionId = table.Column( + type: "nvarchar(260)", + maxLength: 260, + nullable: true + ), + PaymentStatus = table.Column(type: "int", nullable: false), + Total_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + Total_Currency = table.Column(type: "int", nullable: false), + BillingAddress_Street = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + BillingAddress_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + BillingAddress_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + BillingAddress_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + BillingAddress_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: false + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Payments", x => x.Id); + table.ForeignKey( + name: "FK_Payments_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id" + ); + table.ForeignKey( + name: "FK_Payments_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id" + ); + } + ); + + migrationBuilder.CreateTable( + name: "ProductReviewIds", + columns: table => new + { + Id = table + .Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductReviewId = table.Column(type: "uniqueidentifier", nullable: false), + UseId = table.Column(type: "uniqueidentifier", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_ProductReviewIds", x => x.Id); + table.ForeignKey( + name: "FK_ProductReviewIds_Users_UseId", + column: x => x.UseId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "UserPermissionIds", + columns: table => new + { + Id = table + .Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PermissionId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_UserPermissionIds", x => x.Id); + table.ForeignKey( + name: "FK_UserPermissionIds_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "CartItems", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CartId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + Color = table.Column(type: "nvarchar(max)", nullable: false), + Size = table.Column(type: "nvarchar(max)", nullable: false), + Quantity = table.Column(type: "int", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_CartItems", x => new { x.Id, x.CartId }); + table.ForeignKey( + name: "FK_CartItems_Carts_CartId", + column: x => x.CartId, + principalTable: "Carts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + table.ForeignKey( + name: "FK_CartItems_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "ProductImages", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + ImageUrl = table.Column(type: "nvarchar(max)", nullable: false), + Seq = table.Column(type: "int", nullable: false), + PublicId = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + }, + constraints: table => + { + table.PrimaryKey("PK_ProductImages", x => new { x.ProductId, x.Id }); + table.ForeignKey( + name: "FK_ProductImages_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "ProductReviews", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + Rating_Value = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + Comment = table.Column( + type: "nvarchar(1000)", + maxLength: 1000, + nullable: true + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_ProductReviews", x => x.Id); + table.ForeignKey( + name: "FK_ProductReviews_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + table.ForeignKey( + name: "FK_ProductReviews_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_CartId", + table: "CartItems", + column: "CartId" + ); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_ProductId", + table: "CartItems", + column: "ProductId" + ); + + migrationBuilder.CreateIndex(name: "IX_Carts_UserId", table: "Carts", column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderIds_UseId", + table: "OrderIds", + column: "UseId" + ); + + migrationBuilder.CreateIndex( + name: "IX_OrderItems_OrderId", + table: "OrderItems", + column: "OrderId" + ); + + migrationBuilder.CreateIndex( + name: "IX_Payments_OrderId", + table: "Payments", + column: "OrderId" + ); + + migrationBuilder.CreateIndex( + name: "IX_Payments_UserId", + table: "Payments", + column: "UserId" + ); + + migrationBuilder.CreateIndex( + name: "IX_ProductReviewIds_UseId", + table: "ProductReviewIds", + column: "UseId" + ); + + migrationBuilder.CreateIndex( + name: "IX_ProductReviews_ProductId", + table: "ProductReviews", + column: "ProductId" + ); + + migrationBuilder.CreateIndex( + name: "IX_ProductReviews_UserId", + table: "ProductReviews", + column: "UserId" + ); + + migrationBuilder.CreateIndex( + name: "IX_Products_CategoryId", + table: "Products", + column: "CategoryId" + ); + + migrationBuilder.CreateIndex( + name: "IX_PromoCodes_Code", + table: "PromoCodes", + column: "Code" + ); + + migrationBuilder.CreateIndex( + name: "IX_UserPermissionIds_UserId", + table: "UserPermissionIds", + column: "UserId" + ); + + migrationBuilder.CreateIndex(name: "IX_Users_Email", table: "Users", column: "Email"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable(name: "CartItems"); + + migrationBuilder.DropTable(name: "OrderIds"); + + migrationBuilder.DropTable(name: "OrderItems"); + + migrationBuilder.DropTable(name: "Payments"); + + migrationBuilder.DropTable(name: "Permissions"); + + migrationBuilder.DropTable(name: "ProductImages"); + + migrationBuilder.DropTable(name: "ProductReviewIds"); + + migrationBuilder.DropTable(name: "ProductReviews"); + + migrationBuilder.DropTable(name: "PromoCodes"); + + migrationBuilder.DropTable(name: "UserPermissionIds"); + + migrationBuilder.DropTable(name: "Carts"); + + migrationBuilder.DropTable(name: "Orders"); + + migrationBuilder.DropTable(name: "Products"); + + migrationBuilder.DropTable(name: "Users"); + + migrationBuilder.DropTable(name: "Categories"); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs b/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs index 61c5c52..04cbe33 100644 --- a/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs +++ b/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs @@ -8,7 +8,7 @@ #nullable disable -namespace shopizy.Infrastructure.Migrations +namespace Shopizy.Infrastructure.Migrations { [DbContext(typeof(AppDbContext))] partial class AppDbContextModelSnapshot : ModelSnapshot @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); From c4c7a516c0e1e71313971703c6d682d939162007 Mon Sep 17 00:00:00 2001 From: "Md. Abul Kalam" Date: Thu, 23 Jan 2025 22:57:45 +0600 Subject: [PATCH 2/3] Revert "Update DB migrations" This reverts commit e6d37fe4db10215ac64ad32614241870300f38d4. --- .../UpdateUser/UpdateUserCommandHadler.cs | 7 +- .../Common/SeedData/SeedData.SQL | 33 +- .../20240303163205_InitialChanges.Designer.cs | 713 +++++++++++++++ .../20240303163205_InitialChanges.cs | 508 +++++++++++ ...132753_UpdateProductImageTable.Designer.cs | 718 +++++++++++++++ .../20240325132753_UpdateProductImageTable.cs | 29 + .../20240329185149_AddedCartTable.Designer.cs | 778 ++++++++++++++++ .../20240329185149_AddedCartTable.cs | 85 ++ .../20240331173916_UpdateTables.Designer.cs | 778 ++++++++++++++++ .../Migrations/20240331173916_UpdateTables.cs | 167 ++++ ...0240401075111_UpdateCartTables.Designer.cs | 778 ++++++++++++++++ .../20240401075111_UpdateCartTables.cs | 35 + ...240401075932_UpdateCartTables1.Designer.cs | 779 ++++++++++++++++ .../20240401075932_UpdateCartTables1.cs | 54 ++ ...20240417175416_UpdateUserTable.Designer.cs | 749 ++++++++++++++++ .../20240417175416_UpdateUserTable.cs | 136 +++ ...lesToMakeModifiedOnNotRequired.Designer.cs | 747 ++++++++++++++++ ...UpdateTablesToMakeModifiedOnNotRequired.cs | 177 ++++ ...240501170224_UpdateOrdersTable.Designer.cs | 751 ++++++++++++++++ .../20240501170224_UpdateOrdersTable.cs | 28 + .../20240824162540_UpdateAddress.Designer.cs | 750 ++++++++++++++++ .../20240824162540_UpdateAddress.cs | 47 + ...301_addEmailColumnsToUserTable.Designer.cs | 754 ++++++++++++++++ ...240930175301_addEmailColumnsToUserTable.cs | 28 + ...002140454_makeEmailNotRequired.Designer.cs | 753 ++++++++++++++++ .../20241002140454_makeEmailNotRequired.cs | 36 + ..._deleteUnusedColumnFromProduct.Designer.cs | 749 ++++++++++++++++ ...020135147_deleteUnusedColumnFromProduct.cs | 29 + ...71255_AddCustomerIdInUserTable.Designer.cs | 753 ++++++++++++++++ ...20241201171255_AddCustomerIdInUserTable.cs | 29 + ...41202145010_UpdatePaymentTable.Designer.cs | 758 ++++++++++++++++ .../20241202145010_UpdatePaymentTable.cs | 52 ++ ...02154947_UpdatePaymentTableRef.Designer.cs | 756 ++++++++++++++++ .../20241202154947_UpdatePaymentTableRef.cs | 56 ++ ...41211115321_UpdateRatingColumn.Designer.cs | 758 ++++++++++++++++ .../20241211115321_UpdateRatingColumn.cs | 70 ++ ...41211135310_UpdateProductTable.Designer.cs | 776 ++++++++++++++++ .../20241211135310_UpdateProductTable.cs | 83 ++ .../20241212165458_UpdateDatabase.Designer.cs | 795 +++++++++++++++++ .../20241212165458_UpdateDatabase.cs | 138 +++ ...213084430_UpdateCartItemsTable.Designer.cs | 794 +++++++++++++++++ .../20241213084430_UpdateCartItemsTable.cs | 35 + ...1219151944_AddPermissionsTable.Designer.cs | 836 ++++++++++++++++++ .../20241219151944_AddPermissionsTable.cs | 68 ++ ...241222122248_UpdateUsersTable.Designer.cs} | 8 +- .../20241222122248_UpdateUsersTable.cs | 154 ++++ .../20250123152917_InitialDBChanges.cs | 716 --------------- .../Migrations/AppDbContextModelSnapshot.cs | 4 +- 48 files changed, 18092 insertions(+), 743 deletions(-) create mode 100644 src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs create mode 100644 src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs rename src/Shopizy.Infrastructure/Migrations/{20250123152917_InitialDBChanges.Designer.cs => 20241222122248_UpdateUsersTable.Designer.cs} (99%) create mode 100644 src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs diff --git a/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs b/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs index a4892ff..258b2b3 100644 --- a/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs +++ b/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs @@ -1,17 +1,16 @@ using ErrorOr; using MediatR; -using Shopizy.Application.Common.Caching; using Shopizy.Application.Common.Interfaces.Persistence; using Shopizy.Domain.Common.CustomErrors; +using Shopizy.Domain.Orders.ValueObjects; using Shopizy.Domain.Users.ValueObjects; namespace Shopizy.Application.Users.Commands.UpdateUser; -public class UpdateUserCommandHandler(IUserRepository userRepository, ICacheHelper cacheHelper) +public class UpdateUserCommandHandler(IUserRepository userRepository) : IRequestHandler> { private readonly IUserRepository _userRepository = userRepository; - private readonly ICacheHelper _cacheHelper = cacheHelper; public async Task> Handle( UpdateUserCommand request, @@ -43,8 +42,6 @@ CancellationToken cancellationToken return CustomErrors.User.UserNotUpdated; } - await _cacheHelper.RemoveAsync($"user-{user.Id.Value}"); - return Result.Success; } } diff --git a/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL b/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL index e115164..aa3b3c8 100644 --- a/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL +++ b/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL @@ -26,17 +26,18 @@ INSERT INTO [Categories] ([id], [name], [parentId]) VALUES -INSERT INTO [Products] ([id], [name], [description], [ShortDescription], [categoryId], [sku], [stockQuantity], [unitPrice_Amount], [unitPrice_Currency], [discount], [brand], [barcode], [tags], [averageRating_Value], [averageRating_NumRatings], [CreatedOn], [Colors], [Sizes], [Favourites]) VALUES - ('571D3D66-18F2-4DA8-A57B-D06D4D1C9EEF', 'Black Rockstar', 'High quality black t-shirt', 'High quality black t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000000T', '10', '20', '0', '10', 'Zara', 'MC-10000000T', 't-shirt, zara, men, new', '4.8', '5', GETDATE(), 'Black,Gray,Orange,Pink', 'XS,S,M,L,XL,2XL', 0), - ('096A127A-65AF-4C0C-A294-2E1990136711', 'Premium Purple', 'High quality purple t-shirt', 'High quality purple t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000002T', '5', '22', '0', '10', 'ck', 'MC-10000002T', 't-shirt, ck, men, new, premium', '4.9', '7', GETDATE(), 'Black,Orange,Pink,White', 'XS,S,M,L,XL,2XL', 0), - ('8419FD69-61A5-4D9D-A289-1E377CC17082', 'Red Dragon', 'Premium quality red sweater', 'Premium quality red sweater', '632DFDA9-CC2E-487B-8C88-608005F124E2', 'MC-10000000S', '20', '40', '0', '10', 'h&m', 'MC-10000000S', 'sweater, h&m, men, hot, premium', '4.7', '15', GETDATE(), 'Red,Orange,Pink,White', 'XS,S,M,L,XL,2XL', 0), - ('CBB8A3A9-03DB-40E4-A89B-9C91D21B3934', 'Ash life', 'High quality t-shirt', 'High quality t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000004T', '15', '25', '0', '10', 'ck', 'MC-10000004T', 't-shirt, ck, men, new, premium', '4.7', '5', GETDATE(), 'Black,Gray,Pink,White', 'XS,S,M,L,XL,2XL', 0), - ('96A1503F-B7EA-4C12-8946-89035399F45E', 'Red Star', 'High quality t-shirt for men', 'High quality t-shirt for men', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000006T', '30', '20', '0', '10', 'Boss', 'MC-10000006T', 't-shirt, boss, men', '4.6', '10', GETDATE(), 'Red,Black,Orange', 'XS,S,M,L,XL,2XL', 0), - ('E02500EA-2957-4601-A051-951CB9957CBE', 'Black Stone', 'Premium quality t-shirt for women', 'Premium quality t-shirt for women', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000000T', '30', '40', '0', '10', 'Adidas', 'FC-10000000T', 't-shirt, adidas, new, premium', '4.9', '15', GETDATE(), 'Black,Gray', 'XS,S,M,L,XL,2XL', 0), - ('A34BA283-62A1-43C6-8FB0-748DBDE8BA7D', 'Elegant peach', 'High quality women top', 'High quality women top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000002T', '10', '20', '0', '10', 'h&m', 'FC-10000002T', 'top, h&m, new', '4.7', '15', GETDATE(), ',Orange,Pink,Peach', 'XS,S,M,L,XL,2XL', 0), - ('D7C96816-1656-4DBC-B709-0F626807347F', 'Pure White', 'High quality women t-shirt', 'High quality women t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000004T', '20', '20', '0', '10', 'ck', 'FC-10000004T', 't-shirt, ck, new', '4.7', '5', GETDATE(), 'White', 'XS,S,M,L,XL,2XL', 0), - ('DF22BA6B-A15B-4125-AF29-07E242AF6F2D', 'Natural Green', 'High quality t-shirt', 'High quality t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000006T', '20', '25', '0', '5', 'Zara', 'FC-10000006T', 't-shirt, zara', '4.6', '5', GETDATE(), 'Green', 'XS,S,M,L,XL,2XL', 0), - ('9EB9982F-E672-4184-8399-044277EEF754', 'New Way', 'Premium quality top', 'Premium quality top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000008T', '30', '30', '0', '10', 'Nike', 'FC-10000008T', 'top, nike, new', '4.8', '20', GETDATE(), 'Black,Gray,Orange,Pink,White', 'XS,S,M,L,XL,2XL', 0); +INSERT INTO [Products] ([id], [name], [description], [ShortDescription], [categoryId], [sku], [stockQuantity], [unitPrice_Amount], [unitPrice_Currency], [discount], [brand], [barcode], [tags], [averageRating_Value], [averageRating_NumRatings], [CreatedOn], [Colors], [Sizes]) VALUES + ('571D3D66-18F2-4DA8-A57B-D06D4D1C9EEF', 'Black Rockstar', 'High quality black t-shirt', 'High quality black t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000000T', '10', '20', '0', '10', 'Zara', 'MC-10000000T', 't-shirt, zara, men, new', '4.8', '5', GETDATE(), 'Black,Gray,Orange,Pink', 'XS,S,M,L,XL,2XL'), + ('096A127A-65AF-4C0C-A294-2E1990136711', 'Premium Purple', 'High quality purple t-shirt', 'High quality purple t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000002T', '5', '22', '0', '10', 'ck', 'MC-10000002T', 't-shirt, ck, men, new, premium', '4.9', '7', GETDATE(), 'Black,Orange,Pink,White', 'XS,S,M,L,XL,2XL'), + ('8419FD69-61A5-4D9D-A289-1E377CC17082', 'Red Dragon', 'Premium quality red sweater', 'Premium quality red sweater', '632DFDA9-CC2E-487B-8C88-608005F124E2', 'MC-10000000S', '20', '40', '0', '10', 'h&m', 'MC-10000000S', 'sweater, h&m, men, hot, premium', '4.7', '15', GETDATE(), 'Red,Orange,Pink,White', 'XS,S,M,L,XL,2XL'), + ('CBB8A3A9-03DB-40E4-A89B-9C91D21B3934', 'Ash life', 'High quality t-shirt', 'High quality t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000004T', '15', '25', '0', '10', 'ck', 'MC-10000004T', 't-shirt, ck, men, new, premium', '4.7', '5', GETDATE(), 'Black,Gray,Pink,White', 'XS,S,M,L,XL,2XL'), + ('96A1503F-B7EA-4C12-8946-89035399F45E', 'Red Star', 'High quality t-shirt for men', 'High quality t-shirt for men', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000006T', '30', '20', '0', '10', 'Boss', 'MC-10000006T', 't-shirt, boss, men', '4.6', '10', GETDATE(), 'Red,Black,Orange', 'XS,S,M,L,XL,2XL'), + ('E02500EA-2957-4601-A051-951CB9957CBE', 'Black Stone', 'Premium quality t-shirt for women', 'Premium quality t-shirt for women', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000000T', '30', '40', '0', '10', 'Adidas', 'FC-10000000T', 't-shirt, adidas, new, premium', '4.9', '15', GETDATE(), 'Black,Gray', 'XS,S,M,L,XL,2XL'), + ('A34BA283-62A1-43C6-8FB0-748DBDE8BA7D', 'Elegant peach', 'High quality women top', 'High quality women top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000002T', '10', '20', '0', '10', 'h&m', 'FC-10000002T', 'top, h&m, new', '4.7', '15', GETDATE(), ',Orange,Pink,Peach', 'XS,S,M,L,XL,2XL'), + ('D7C96816-1656-4DBC-B709-0F626807347F', 'Pure White', 'High quality women t-shirt', 'High quality women t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000004T', '20', '20', '0', '10', 'ck', 'FC-10000004T', 't-shirt, ck, new', '4.7', '5', GETDATE(), 'White', 'XS,S,M,L,XL,2XL'), + ('DF22BA6B-A15B-4125-AF29-07E242AF6F2D', 'Natural Green', 'High quality t-shirt', 'High quality t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000006T', '20', '25', '0', '5', 'Zara', 'FC-10000006T', 't-shirt, zara', '4.6', '5', GETDATE(), 'Green', 'XS,S,M,L,XL,2XL'), + ('9EB9982F-E672-4184-8399-044277EEF754', 'New Way', 'Premium quality top', 'Premium quality top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000008T', '30', '30', '0', '10', 'Nike', 'FC-10000008T', 'top, nike, new', '4.8', '20', GETDATE(), 'Black,Gray,Orange,Pink,White', 'XS,S,M,L,XL,2XL'); + INSERT INTO [ProductImages] ([id], [productId], [imageUrl], [seq], [publicId]) VALUES ('4DBB9D7F-5B09-4ECF-AEB9-B1F5F6473379', '571D3D66-18F2-4DA8-A57B-D06D4D1C9EEF', 'https://res.cloudinary.com/akazad13/image/upload/v1729420812/shopizy/mpjks43jpxo9eagempgu.jpg', '0', 'mpjks43jpxo9eagempgu'), @@ -52,11 +53,11 @@ INSERT INTO [ProductImages] ([id], [productId], [imageUrl], [seq], [publicId]) V ('A8A70F86-7987-4BB4-A344-1B2133DCC609', '096A127A-65AF-4C0C-A294-2E1990136711', 'https://res.cloudinary.com/akazad13/image/upload/v1733579506/shopizy/men2_2_d4dn3p.jpg', 1, 'men2_2_d4dn3p'); INSERT INTO ProductReviews(Id, UserId, ProductId, Rating_Value, Comment, CreatedOn) -VALUES('20AB2C8F-E880-45C3-8887-D0A0E2E0E763','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), -('C75B65D5-13D1-4FC9-A81E-19D7FB3B7784','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), -('41B53394-5014-45E6-9540-B7FA05782B6C','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Good T-Shirt!', GETDATE()), -('F9CA8F97-2B91-4EAD-88D7-78496A92616A','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Recommanded!', GETDATE()), -('7ED64773-2ED6-4BFB-BBA0-E267BA4A8208','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Looks good', GETDATE()); +VALUES('20AB2C8F-E880-45C3-8887-D0A0E2E0E763','E68D8E76-72A1-42ED-91D0-0ED0296D662E','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), +('C75B65D5-13D1-4FC9-A81E-19D7FB3B7784','67726B00-2647-4817-BFCB-3781EBD97E0F','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), +('41B53394-5014-45E6-9540-B7FA05782B6C','6EBA643C-D138-4D90-AA7C-6DBF935D8209','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Good T-Shirt!', GETDATE()), +('F9CA8F97-2B91-4EAD-88D7-78496A92616A','88D9AF82-BEF4-4042-8E55-B01B89F23E68','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Recommanded!', GETDATE()), +('7ED64773-2ED6-4BFB-BBA0-E267BA4A8208','E68D8E76-72A1-42ED-91D0-0ED0296D662E','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Looks good', GETDATE()); diff --git a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs new file mode 100644 index 0000000..d4e580a --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs @@ -0,0 +1,713 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240303163205_InitialChanges")] + partial class InitialChanges + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId") + .IsUnique(); + + b.HasIndex("OrderId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("ProductId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("CustomerId"); + + b1.ToTable("Customers"); + + b1.WithOwner() + .HasForeignKey("CustomerId"); + }); + + b.Navigation("Address") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Customers.Customer", null) + .WithMany("Orders") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Customers.Customer", "Customer") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "CustomerId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Customer"); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Customers.Customer", null) + .WithMany("ProductReviews") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs b/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs new file mode 100644 index 0000000..b5ec666 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs @@ -0,0 +1,508 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class InitialChanges : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Categories", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Categories", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "PromoCodes", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Code = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: false), + Description = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: true + ), + Discount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + IsPerchantage = table.Column( + type: "bit", + nullable: false, + defaultValue: true + ), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + NumOfTimeUsed = table.Column(type: "int", nullable: false, defaultValue: 0), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_PromoCodes", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + FirstName = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + LastName = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + Phone = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: true), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + Description = table.Column( + type: "nvarchar(200)", + maxLength: 200, + nullable: false + ), + CategoryId = table.Column(type: "uniqueidentifier", nullable: false), + SKU = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + StockQuantity = table.Column(type: "int", nullable: false), + UnitPrice_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + UnitPrice_Currency = table.Column(type: "int", nullable: false), + Discount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: true + ), + Brand = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + Barcode = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + Tags = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + AverageRating_Value = table.Column( + type: "float(18)", + precision: 18, + scale: 2, + nullable: false + ), + AverageRating_NumRatings = table.Column(type: "int", nullable: false), + BreadCrums = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: true + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + table.ForeignKey( + name: "FK_Products_Categories_CategoryId", + column: x => x.CategoryId, + principalTable: "Categories", + principalColumn: "Id" + ); + } + ); + + migrationBuilder.CreateTable( + name: "Customers", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ProfileImageUrl = table.Column(type: "nvarchar(max)", nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + Address_Line = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: true + ), + Address_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: true + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_Customers", x => x.Id); + table.ForeignKey( + name: "FK_Customers_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id" + ); + } + ); + + migrationBuilder.CreateTable( + name: "ProductImages", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + ImageUrl = table.Column(type: "nvarchar(max)", nullable: false), + Seq = table.Column(type: "int", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_ProductImages", x => new { x.ProductId, x.Id }); + table.ForeignKey( + name: "FK_ProductImages_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CustomerId = table.Column(type: "uniqueidentifier", nullable: false), + DeliveryCharge_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + DeliveryCharge_Currency = table.Column(type: "int", nullable: false), + OrderStatus = table.Column(type: "int", nullable: false), + PromoCode = table.Column( + type: "nvarchar(15)", + maxLength: 15, + nullable: true + ), + ShippingAddress_Line = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + ShippingAddress_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + ShippingAddress_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + ShippingAddress_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + ShippingAddress_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: false + ), + PaymentStatus = table.Column( + type: "nvarchar(20)", + maxLength: 20, + nullable: false + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Customers_CustomerId", + column: x => x.CustomerId, + principalTable: "Customers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "ProductReviews", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CustomerId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + Rating_Value = table.Column( + type: "float(18)", + precision: 18, + scale: 2, + nullable: false + ), + Comment = table.Column( + type: "nvarchar(1000)", + maxLength: 1000, + nullable: true + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_ProductReviews", x => x.Id); + table.ForeignKey( + name: "FK_ProductReviews_Customers_CustomerId", + column: x => x.CustomerId, + principalTable: "Customers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + table.ForeignKey( + name: "FK_ProductReviews_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "OrderItems", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + OrderId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + PictureUrl = table.Column(type: "nvarchar(max)", nullable: true), + UnitPrice_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + UnitPrice_Currency = table.Column(type: "int", nullable: false), + Quantity = table.Column(type: "int", nullable: false), + Discount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + }, + constraints: table => + { + table.PrimaryKey("PK_OrderItems", x => new { x.Id, x.OrderId }); + table.ForeignKey( + name: "FK_OrderItems_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "Payments", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + OrderId = table.Column(type: "uniqueidentifier", nullable: false), + CustomerId = table.Column(type: "uniqueidentifier", nullable: false), + PaymentMethod = table.Column( + type: "nvarchar(20)", + maxLength: 20, + nullable: false + ), + TransactionId = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: true + ), + PaymentStatus = table.Column(type: "int", nullable: false), + Total_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + Total_Currency = table.Column(type: "int", nullable: false), + BillingAddress_Line = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + BillingAddress_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + BillingAddress_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + BillingAddress_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + BillingAddress_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: false + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_Payments", x => x.Id); + table.ForeignKey( + name: "FK_Payments_Customers_CustomerId", + column: x => x.CustomerId, + principalTable: "Customers", + principalColumn: "Id" + ); + table.ForeignKey( + name: "FK_Payments_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id" + ); + } + ); + + migrationBuilder.CreateIndex( + name: "IX_Customers_UserId", + table: "Customers", + column: "UserId", + unique: true + ); + + migrationBuilder.CreateIndex( + name: "IX_OrderItems_OrderId", + table: "OrderItems", + column: "OrderId" + ); + + migrationBuilder.CreateIndex( + name: "IX_Orders_CustomerId", + table: "Orders", + column: "CustomerId" + ); + + migrationBuilder.CreateIndex( + name: "IX_Payments_CustomerId", + table: "Payments", + column: "CustomerId", + unique: true + ); + + migrationBuilder.CreateIndex( + name: "IX_Payments_OrderId", + table: "Payments", + column: "OrderId", + unique: true + ); + + migrationBuilder.CreateIndex( + name: "IX_ProductReviews_CustomerId", + table: "ProductReviews", + column: "CustomerId" + ); + + migrationBuilder.CreateIndex( + name: "IX_ProductReviews_ProductId", + table: "ProductReviews", + column: "ProductId" + ); + + migrationBuilder.CreateIndex( + name: "IX_Products_CategoryId", + table: "Products", + column: "CategoryId" + ); + + migrationBuilder.CreateIndex( + name: "IX_PromoCodes_Code", + table: "PromoCodes", + column: "Code" + ); + + migrationBuilder.CreateIndex(name: "IX_Users_Phone", table: "Users", column: "Phone"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable(name: "OrderItems"); + + migrationBuilder.DropTable(name: "Payments"); + + migrationBuilder.DropTable(name: "ProductImages"); + + migrationBuilder.DropTable(name: "ProductReviews"); + + migrationBuilder.DropTable(name: "PromoCodes"); + + migrationBuilder.DropTable(name: "Orders"); + + migrationBuilder.DropTable(name: "Products"); + + migrationBuilder.DropTable(name: "Customers"); + + migrationBuilder.DropTable(name: "Categories"); + + migrationBuilder.DropTable(name: "Users"); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs new file mode 100644 index 0000000..0ba565b --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs @@ -0,0 +1,718 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240325132753_UpdateProductImageTable")] + partial class UpdateProductImageTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId") + .IsUnique(); + + b.HasIndex("OrderId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("ProductId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("CustomerId"); + + b1.ToTable("Customers"); + + b1.WithOwner() + .HasForeignKey("CustomerId"); + }); + + b.Navigation("Address") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Customers.Customer", null) + .WithMany("Orders") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Customers.Customer", "Customer") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "CustomerId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Customer"); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Customers.Customer", null) + .WithMany("ProductReviews") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs b/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs new file mode 100644 index 0000000..4f984ac --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class UpdateProductImageTable : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "PublicId", + table: "ProductImages", + type: "nvarchar(100)", + maxLength: 100, + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "PublicId", + table: "ProductImages"); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs new file mode 100644 index 0000000..5ac3cd8 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs @@ -0,0 +1,778 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240329185149_AddedCartTable")] + partial class AddedCartTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId") + .IsUnique(); + + b.HasIndex("OrderId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("ProductId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("CartId"); + + b1.HasIndex("ProductId"); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("CustomerId"); + + b1.ToTable("Customers"); + + b1.WithOwner() + .HasForeignKey("CustomerId"); + }); + + b.Navigation("Address") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Customers.Customer", null) + .WithMany("Orders") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Customers.Customer", "Customer") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "CustomerId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Customer"); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Customers.Customer", null) + .WithMany("ProductReviews") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs b/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs new file mode 100644 index 0000000..eb9af8d --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs @@ -0,0 +1,85 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class AddedCartTable : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Carts", + columns: table => + new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CustomerId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Carts", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "LineItems", + columns: table => + new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CartId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + Quantity = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_LineItems", x => new { x.Id, x.CartId }); + table.ForeignKey( + name: "FK_LineItems_Carts_CartId", + column: x => x.CartId, + principalTable: "Carts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + table.ForeignKey( + name: "FK_LineItems_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateIndex( + name: "IX_Carts_CustomerId", + table: "Carts", + column: "CustomerId" + ); + + migrationBuilder.CreateIndex( + name: "IX_LineItems_CartId", + table: "LineItems", + column: "CartId" + ); + + migrationBuilder.CreateIndex( + name: "IX_LineItems_ProductId", + table: "LineItems", + column: "ProductId" + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable(name: "LineItems"); + + migrationBuilder.DropTable(name: "Carts"); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs new file mode 100644 index 0000000..f7f624c --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs @@ -0,0 +1,778 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240331173916_UpdateTables")] + partial class UpdateTables + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("CartId"); + + b1.HasIndex("ProductId"); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("CustomerId"); + + b1.ToTable("Customers"); + + b1.WithOwner() + .HasForeignKey("CustomerId"); + }); + + b.Navigation("Address") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs b/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs new file mode 100644 index 0000000..53eadf5 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs @@ -0,0 +1,167 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class UpdateTables : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Customers_CustomerId", + table: "Orders"); + + migrationBuilder.DropForeignKey( + name: "FK_Payments_Customers_CustomerId", + table: "Payments"); + + migrationBuilder.DropForeignKey( + name: "FK_ProductReviews_Customers_CustomerId", + table: "ProductReviews"); + + migrationBuilder.RenameColumn( + name: "CustomerId", + table: "ProductReviews", + newName: "UserId"); + + migrationBuilder.RenameIndex( + name: "IX_ProductReviews_CustomerId", + table: "ProductReviews", + newName: "IX_ProductReviews_UserId"); + + migrationBuilder.RenameColumn( + name: "CustomerId", + table: "Payments", + newName: "UserId"); + + migrationBuilder.RenameIndex( + name: "IX_Payments_CustomerId", + table: "Payments", + newName: "IX_Payments_UserId"); + + migrationBuilder.RenameColumn( + name: "CustomerId", + table: "Orders", + newName: "UserId"); + + migrationBuilder.RenameIndex( + name: "IX_Orders_CustomerId", + table: "Orders", + newName: "IX_Orders_UserId"); + + migrationBuilder.RenameColumn( + name: "CustomerId", + table: "Carts", + newName: "UserId"); + + migrationBuilder.RenameIndex( + name: "IX_Carts_CustomerId", + table: "Carts", + newName: "IX_Carts_UserId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Users_UserId", + table: "Orders", + column: "UserId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Payments_Users_UserId", + table: "Payments", + column: "UserId", + principalTable: "Users", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_ProductReviews_Users_UserId", + table: "ProductReviews", + column: "UserId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Users_UserId", + table: "Orders"); + + migrationBuilder.DropForeignKey( + name: "FK_Payments_Users_UserId", + table: "Payments"); + + migrationBuilder.DropForeignKey( + name: "FK_ProductReviews_Users_UserId", + table: "ProductReviews"); + + migrationBuilder.RenameColumn( + name: "UserId", + table: "ProductReviews", + newName: "CustomerId"); + + migrationBuilder.RenameIndex( + name: "IX_ProductReviews_UserId", + table: "ProductReviews", + newName: "IX_ProductReviews_CustomerId"); + + migrationBuilder.RenameColumn( + name: "UserId", + table: "Payments", + newName: "CustomerId"); + + migrationBuilder.RenameIndex( + name: "IX_Payments_UserId", + table: "Payments", + newName: "IX_Payments_CustomerId"); + + migrationBuilder.RenameColumn( + name: "UserId", + table: "Orders", + newName: "CustomerId"); + + migrationBuilder.RenameIndex( + name: "IX_Orders_UserId", + table: "Orders", + newName: "IX_Orders_CustomerId"); + + migrationBuilder.RenameColumn( + name: "UserId", + table: "Carts", + newName: "CustomerId"); + + migrationBuilder.RenameIndex( + name: "IX_Carts_UserId", + table: "Carts", + newName: "IX_Carts_CustomerId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Customers_CustomerId", + table: "Orders", + column: "CustomerId", + principalTable: "Customers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Payments_Customers_CustomerId", + table: "Payments", + column: "CustomerId", + principalTable: "Customers", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_ProductReviews_Customers_CustomerId", + table: "ProductReviews", + column: "CustomerId", + principalTable: "Customers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs new file mode 100644 index 0000000..e2f8288 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs @@ -0,0 +1,778 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240401075111_UpdateCartTables")] + partial class UpdateCartTables + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId", "ProductId"); + + b1.HasIndex("CartId"); + + b1.HasIndex("ProductId"); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("CustomerId"); + + b1.ToTable("Customers"); + + b1.WithOwner() + .HasForeignKey("CustomerId"); + }); + + b.Navigation("Address") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs b/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs new file mode 100644 index 0000000..0ccccd6 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class UpdateCartTables : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_LineItems", + table: "LineItems"); + + migrationBuilder.AddPrimaryKey( + name: "PK_LineItems", + table: "LineItems", + columns: new[] { "Id", "CartId", "ProductId" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_LineItems", + table: "LineItems"); + + migrationBuilder.AddPrimaryKey( + name: "PK_LineItems", + table: "LineItems", + columns: new[] { "Id", "CartId" }); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs new file mode 100644 index 0000000..3f707c9 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs @@ -0,0 +1,779 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240401075932_UpdateCartTables1")] + partial class UpdateCartTables1 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => + { + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("CustomerId"); + + b1.ToTable("Customers"); + + b1.WithOwner() + .HasForeignKey("CustomerId"); + }); + + b.Navigation("Address") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs b/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs new file mode 100644 index 0000000..9be292e --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs @@ -0,0 +1,54 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class UpdateCartTables1 : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_LineItems", + table: "LineItems"); + + migrationBuilder.DropIndex( + name: "IX_LineItems_CartId", + table: "LineItems"); + + migrationBuilder.AddPrimaryKey( + name: "PK_LineItems", + table: "LineItems", + columns: new[] { "Id", "CartId" }); + + migrationBuilder.CreateIndex( + name: "IX_LineItems_CartId_ProductId", + table: "LineItems", + columns: new[] { "CartId", "ProductId" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_LineItems", + table: "LineItems"); + + migrationBuilder.DropIndex( + name: "IX_LineItems_CartId_ProductId", + table: "LineItems"); + + migrationBuilder.AddPrimaryKey( + name: "PK_LineItems", + table: "LineItems", + columns: new[] { "Id", "CartId", "ProductId" }); + + migrationBuilder.CreateIndex( + name: "IX_LineItems_CartId", + table: "LineItems", + column: "CartId"); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs new file mode 100644 index 0000000..fa98f30 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs @@ -0,0 +1,749 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240417175416_UpdateUserTable")] + partial class UpdateUserTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs b/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs new file mode 100644 index 0000000..dbed064 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs @@ -0,0 +1,136 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class UpdateUserTable : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable(name: "Customers"); + + migrationBuilder.AddColumn( + name: "Address_City", + table: "Users", + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ); + + migrationBuilder.AddColumn( + name: "Address_Country", + table: "Users", + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ); + + migrationBuilder.AddColumn( + name: "Address_Line", + table: "Users", + type: "nvarchar(100)", + maxLength: 100, + nullable: true + ); + + migrationBuilder.AddColumn( + name: "Address_State", + table: "Users", + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ); + + migrationBuilder.AddColumn( + name: "Address_ZipCode", + table: "Users", + type: "nvarchar(10)", + maxLength: 10, + nullable: true + ); + + migrationBuilder.AddColumn( + name: "ProfileImageUrl", + table: "Users", + type: "nvarchar(max)", + nullable: true + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn(name: "Address_City", table: "Users"); + + migrationBuilder.DropColumn(name: "Address_Country", table: "Users"); + + migrationBuilder.DropColumn(name: "Address_Line", table: "Users"); + + migrationBuilder.DropColumn(name: "Address_State", table: "Users"); + + migrationBuilder.DropColumn(name: "Address_ZipCode", table: "Users"); + + migrationBuilder.DropColumn(name: "ProfileImageUrl", table: "Users"); + + migrationBuilder.CreateTable( + name: "Customers", + columns: table => + new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: false), + ProfileImageUrl = table.Column( + type: "nvarchar(max)", + nullable: true + ), + Address_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_Line = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: true + ), + Address_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: true + ) + }, + constraints: table => + { + table.PrimaryKey("PK_Customers", x => x.Id); + table.ForeignKey( + name: "FK_Customers_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id" + ); + } + ); + + migrationBuilder.CreateIndex( + name: "IX_Customers_UserId", + table: "Customers", + column: "UserId", + unique: true + ); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs new file mode 100644 index 0000000..7dff433 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs @@ -0,0 +1,747 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240420191703_UpdateTablesToMakeModifiedOnNotRequired")] + partial class UpdateTablesToMakeModifiedOnNotRequired + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs b/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs new file mode 100644 index 0000000..72491c4 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs @@ -0,0 +1,177 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class UpdateTablesToMakeModifiedOnNotRequired : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Users", + type: "smalldatetime", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "smalldatetime" + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "PromoCodes", + type: "smalldatetime", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "smalldatetime" + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Products", + type: "smalldatetime", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "smalldatetime" + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "ProductReviews", + type: "smalldatetime", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "smalldatetime" + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Payments", + type: "smalldatetime", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "smalldatetime" + ); + + migrationBuilder.AlterColumn( + name: "PaymentStatus", + table: "Orders", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(20)", + oldMaxLength: 20 + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Orders", + type: "smalldatetime", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "smalldatetime" + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Carts", + type: "smalldatetime", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "smalldatetime" + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Users", + type: "smalldatetime", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "smalldatetime", + oldNullable: true + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "PromoCodes", + type: "smalldatetime", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "smalldatetime", + oldNullable: true + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Products", + type: "smalldatetime", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "smalldatetime", + oldNullable: true + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "ProductReviews", + type: "smalldatetime", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "smalldatetime", + oldNullable: true + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Payments", + type: "smalldatetime", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "smalldatetime", + oldNullable: true + ); + + migrationBuilder.AlterColumn( + name: "PaymentStatus", + table: "Orders", + type: "nvarchar(20)", + maxLength: 20, + nullable: false, + oldClrType: typeof(int), + oldType: "int" + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Orders", + type: "smalldatetime", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "smalldatetime", + oldNullable: true + ); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "Carts", + type: "smalldatetime", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "smalldatetime", + oldNullable: true + ); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs new file mode 100644 index 0000000..57d8b84 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs @@ -0,0 +1,751 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240501170224_UpdateOrdersTable")] + partial class UpdateOrdersTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Line") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs b/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs new file mode 100644 index 0000000..288fb65 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class UpdateOrdersTable : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CancellationReason", + table: "Orders", + type: "nvarchar(200)", + maxLength: 200, + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CancellationReason", + table: "Orders"); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs new file mode 100644 index 0000000..f8f0c37 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs @@ -0,0 +1,750 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240824162540_UpdateAddress")] + partial class UpdateAddress + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs b/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs new file mode 100644 index 0000000..4608f50 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations; + +/// +public partial class UpdateAddress : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Address_Line", + table: "Users", + newName: "Address_Street"); + + migrationBuilder.RenameColumn( + name: "BillingAddress_Line", + table: "Payments", + newName: "BillingAddress_Street"); + + migrationBuilder.RenameColumn( + name: "ShippingAddress_Line", + table: "Orders", + newName: "ShippingAddress_Street"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Address_Street", + table: "Users", + newName: "Address_Line"); + + migrationBuilder.RenameColumn( + name: "BillingAddress_Street", + table: "Payments", + newName: "BillingAddress_Line"); + + migrationBuilder.RenameColumn( + name: "ShippingAddress_Street", + table: "Orders", + newName: "ShippingAddress_Line"); + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs new file mode 100644 index 0000000..4965186 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs @@ -0,0 +1,754 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240930175301_addEmailColumnsToUserTable")] + partial class addEmailColumnsToUserTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs b/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs new file mode 100644 index 0000000..15ba2f2 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class addEmailColumnsToUserTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Email", + table: "Users", + type: "nvarchar(max)", + nullable: false, + defaultValue: "" + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn(name: "Email", table: "Users"); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs new file mode 100644 index 0000000..a2a020a --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs @@ -0,0 +1,753 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241002140454_makeEmailNotRequired")] + partial class makeEmailNotRequired + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BreadCrums") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs b/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs new file mode 100644 index 0000000..c77ced4 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class makeEmailNotRequired : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Email", + table: "Users", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Email", + table: "Users", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs new file mode 100644 index 0000000..fb56d31 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs @@ -0,0 +1,749 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241020135147_deleteUnusedColumnFromProduct")] + partial class deleteUnusedColumnFromProduct + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs b/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs new file mode 100644 index 0000000..f74a330 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class deleteUnusedColumnFromProduct : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "BreadCrums", + table: "Products"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "BreadCrums", + table: "Products", + type: "nvarchar(100)", + maxLength: 100, + nullable: true); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs new file mode 100644 index 0000000..aafa8b9 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs @@ -0,0 +1,753 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241201171255_AddCustomerIdInUserTable")] + partial class AddCustomerIdInUserTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs b/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs new file mode 100644 index 0000000..fad4155 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class AddCustomerIdInUserTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CustomerId", + table: "Users", + type: "nvarchar(256)", + maxLength: 256, + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CustomerId", + table: "Users"); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs new file mode 100644 index 0000000..47ee956 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs @@ -0,0 +1,758 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241202145010_UpdatePaymentTable")] + partial class UpdatePaymentTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentMethodId") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithOne() + .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs b/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs new file mode 100644 index 0000000..d735f6f --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class UpdatePaymentTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "TransactionId", + table: "Payments", + type: "nvarchar(260)", + maxLength: 260, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50, + oldNullable: true); + + migrationBuilder.AddColumn( + name: "PaymentMethodId", + table: "Payments", + type: "nvarchar(260)", + maxLength: 260, + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "PaymentMethodId", + table: "Payments"); + + migrationBuilder.AlterColumn( + name: "TransactionId", + table: "Payments", + type: "nvarchar(50)", + maxLength: 50, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(260)", + oldMaxLength: 260, + oldNullable: true); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs new file mode 100644 index 0000000..e703d89 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs @@ -0,0 +1,756 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241202154947_UpdatePaymentTableRef")] + partial class UpdatePaymentTableRef + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentMethodId") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("float(18)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs b/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs new file mode 100644 index 0000000..a0d48e9 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs @@ -0,0 +1,56 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class UpdatePaymentTableRef : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Payments_OrderId", + table: "Payments"); + + migrationBuilder.DropIndex( + name: "IX_Payments_UserId", + table: "Payments"); + + migrationBuilder.CreateIndex( + name: "IX_Payments_OrderId", + table: "Payments", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_Payments_UserId", + table: "Payments", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Payments_OrderId", + table: "Payments"); + + migrationBuilder.DropIndex( + name: "IX_Payments_UserId", + table: "Payments"); + + migrationBuilder.CreateIndex( + name: "IX_Payments_OrderId", + table: "Payments", + column: "OrderId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Payments_UserId", + table: "Payments", + column: "UserId", + unique: true); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs new file mode 100644 index 0000000..a573aae --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs @@ -0,0 +1,758 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241211115321_UpdateRatingColumn")] + partial class UpdateRatingColumn + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentMethodId") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs b/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs new file mode 100644 index 0000000..6f31cda --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs @@ -0,0 +1,70 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class UpdateRatingColumn : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "AverageRating_Value", + table: "Products", + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(double), + oldType: "float(18)", + oldPrecision: 18, + oldScale: 2 + ); + + migrationBuilder.AlterColumn( + name: "Rating_Value", + table: "ProductReviews", + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(double), + oldType: "float(18)", + oldPrecision: 18, + oldScale: 2 + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "AverageRating_Value", + table: "Products", + type: "float(18)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "decimal(18,2)", + oldPrecision: 18, + oldScale: 2 + ); + + migrationBuilder.AlterColumn( + name: "Rating_Value", + table: "ProductReviews", + type: "float(18)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "decimal(18,2)", + oldPrecision: 18, + oldScale: 2 + ); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs new file mode 100644 index 0000000..ebe8da7 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs @@ -0,0 +1,776 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241211135310_UpdateProductTable")] + partial class UpdateProductTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentMethodId") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("Colors") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("Favourites") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ShortDescription") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Sizes") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("LineItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("LineItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs b/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs new file mode 100644 index 0000000..af70866 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs @@ -0,0 +1,83 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class UpdateProductTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Name", + table: "Products", + type: "nvarchar(50)", + maxLength: 50, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(100)", + oldMaxLength: 100 + ); + + migrationBuilder.AddColumn( + name: "Colors", + table: "Products", + type: "nvarchar(50)", + maxLength: 50, + nullable: false, + defaultValue: "" + ); + + migrationBuilder.AddColumn( + name: "Favourites", + table: "Products", + type: "int", + nullable: false, + defaultValue: 0 + ); + + migrationBuilder.AddColumn( + name: "ShortDescription", + table: "Products", + type: "nvarchar(100)", + maxLength: 100, + nullable: false, + defaultValue: "" + ); + + migrationBuilder.AddColumn( + name: "Sizes", + table: "Products", + type: "nvarchar(20)", + maxLength: 20, + nullable: false, + defaultValue: "" + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn(name: "Colors", table: "Products"); + + migrationBuilder.DropColumn(name: "Favourites", table: "Products"); + + migrationBuilder.DropColumn(name: "ShortDescription", table: "Products"); + + migrationBuilder.DropColumn(name: "Sizes", table: "Products"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Products", + type: "nvarchar(100)", + maxLength: 100, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50 + ); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs new file mode 100644 index 0000000..f078d26 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs @@ -0,0 +1,795 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241212165458_UpdateDatabase")] + partial class UpdateDatabase + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("DeliveryMethod") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentMethodId") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("Colors") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("Favourites") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ShortDescription") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Sizes") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.CartItem", "CartItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Color") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.Property("Size") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("ProductId"); + + b1.HasIndex("CartId", "ProductId") + .IsUnique(); + + b1.ToTable("CartItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("CartItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Color") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.Property("Size") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs b/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs new file mode 100644 index 0000000..0321948 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs @@ -0,0 +1,138 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class UpdateDatabase : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable(name: "LineItems"); + + migrationBuilder.AddColumn( + name: "DeliveryMethod", + table: "Orders", + type: "int", + nullable: false, + defaultValue: 0 + ); + + migrationBuilder.AddColumn( + name: "Color", + table: "OrderItems", + type: "nvarchar(max)", + nullable: false, + defaultValue: "" + ); + + migrationBuilder.AddColumn( + name: "Size", + table: "OrderItems", + type: "nvarchar(max)", + nullable: false, + defaultValue: "" + ); + + migrationBuilder.CreateTable( + name: "CartItems", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CartId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + Color = table.Column(type: "nvarchar(max)", nullable: false), + Size = table.Column(type: "nvarchar(max)", nullable: false), + Quantity = table.Column(type: "int", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_CartItems", x => new { x.Id, x.CartId }); + table.ForeignKey( + name: "FK_CartItems_Carts_CartId", + column: x => x.CartId, + principalTable: "Carts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + table.ForeignKey( + name: "FK_CartItems_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_CartId_ProductId", + table: "CartItems", + columns: new[] { "CartId", "ProductId" }, + unique: true + ); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_ProductId", + table: "CartItems", + column: "ProductId" + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable(name: "CartItems"); + + migrationBuilder.DropColumn(name: "DeliveryMethod", table: "Orders"); + + migrationBuilder.DropColumn(name: "Color", table: "OrderItems"); + + migrationBuilder.DropColumn(name: "Size", table: "OrderItems"); + + migrationBuilder.CreateTable( + name: "LineItems", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CartId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + Quantity = table.Column(type: "int", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_LineItems", x => new { x.Id, x.CartId }); + table.ForeignKey( + name: "FK_LineItems_Carts_CartId", + column: x => x.CartId, + principalTable: "Carts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + table.ForeignKey( + name: "FK_LineItems_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateIndex( + name: "IX_LineItems_CartId_ProductId", + table: "LineItems", + columns: new[] { "CartId", "ProductId" }, + unique: true + ); + + migrationBuilder.CreateIndex( + name: "IX_LineItems_ProductId", + table: "LineItems", + column: "ProductId" + ); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs new file mode 100644 index 0000000..02fea69 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs @@ -0,0 +1,794 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241213084430_UpdateCartItemsTable")] + partial class UpdateCartItemsTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("DeliveryMethod") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentMethodId") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("Colors") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("Favourites") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ShortDescription") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Sizes") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.CartItem", "CartItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Color") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.Property("Size") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("CartId"); + + b1.HasIndex("ProductId"); + + b1.ToTable("CartItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("CartItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Color") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.Property("Size") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs b/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs new file mode 100644 index 0000000..e85f58b --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class UpdateCartItemsTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex(name: "IX_CartItems_CartId_ProductId", table: "CartItems"); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_CartId", + table: "CartItems", + column: "CartId" + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex(name: "IX_CartItems_CartId", table: "CartItems"); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_CartId_ProductId", + table: "CartItems", + columns: new[] { "CartId", "ProductId" }, + unique: true + ); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs new file mode 100644 index 0000000..a19ad3e --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs @@ -0,0 +1,836 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Shopizy.Infrastructure.Common.Persistence; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241219151944_AddPermissionsTable")] + partial class AddPermissionsTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Carts", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CancellationReason") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("DeliveryMethod") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("PromoCode") + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PaymentMethodId") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasMaxLength(260) + .HasColumnType("nvarchar(260)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Permissions.Permission", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Permissions", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("ProductReviews", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Brand") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("Colors") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("Favourites") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ShortDescription") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Sizes") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("StockQuantity") + .HasColumnType("int"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsPerchantage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("NumOfTimeUsed") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.ToTable("PromoCodes", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOn") + .HasColumnType("smalldatetime"); + + b.Property("CustomerId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedOn") + .HasColumnType("smalldatetime"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("ProfileImageUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Phone"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => + { + b.OwnsMany("Shopizy.Domain.Carts.Entities.CartItem", "CartItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CartId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Color") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.Property("Size") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id", "CartId"); + + b1.HasIndex("CartId"); + + b1.HasIndex("ProductId"); + + b1.ToTable("CartItems", (string)null); + + b1.WithOwner() + .HasForeignKey("CartId"); + + b1.HasOne("Shopizy.Domain.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.Navigation("Product"); + }); + + b.Navigation("CartItems"); + }); + + modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => + { + b.HasOne("Shopizy.Domain.Users.User", null) + .WithMany("Orders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Color") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("Discount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("PictureUrl") + .HasColumnType("nvarchar(max)"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.Property("Size") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id", "OrderId"); + + b1.HasIndex("OrderId"); + + b1.ToTable("OrderItems", (string)null); + + b1.WithOwner() + .HasForeignKey("OrderId"); + + b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => + { + b2.Property("OrderItemId") + .HasColumnType("uniqueidentifier"); + + b2.Property("OrderItemOrderId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b2.Property("Currency") + .HasColumnType("int"); + + b2.HasKey("OrderItemId", "OrderItemOrderId"); + + b2.ToTable("OrderItems"); + + b2.WithOwner() + .HasForeignKey("OrderItemId", "OrderItemOrderId"); + }); + + b1.Navigation("UnitPrice") + .IsRequired(); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => + { + b1.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("DeliveryCharge") + .IsRequired(); + + b.Navigation("OrderItems"); + + b.Navigation("ShippingAddress") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => + { + b.HasOne("Shopizy.Domain.Orders.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => + { + b1.Property("PaymentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("PaymentId"); + + b1.ToTable("Payments"); + + b1.WithOwner() + .HasForeignKey("PaymentId"); + }); + + b.Navigation("BillingAddress") + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Total") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => + { + b.HasOne("Shopizy.Domain.Products.Product", null) + .WithMany("ProductReviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Shopizy.Domain.Users.User", "User") + .WithMany("ProductReviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => + { + b1.Property("ProductReviewId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductReviewId"); + + b1.ToTable("ProductReviews"); + + b1.WithOwner() + .HasForeignKey("ProductReviewId"); + }); + + b.Navigation("Rating") + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.HasOne("Shopizy.Domain.Categories.Category", null) + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("NumRatings") + .HasColumnType("int"); + + b1.Property("Value") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("PublicId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("Seq") + .HasColumnType("int"); + + b1.HasKey("ProductId", "Id"); + + b1.ToTable("ProductImages", (string)null); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => + { + b1.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b1.Property("Currency") + .HasColumnType("int"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("AverageRating") + .IsRequired(); + + b.Navigation("ProductImages"); + + b.Navigation("UnitPrice") + .IsRequired(); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.OwnsMany("Shopizy.Domain.Permissions.ValueObjects.PermissionId", "PermissionIds", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Value") + .HasColumnType("uniqueidentifier") + .HasColumnName("PermissionId"); + + b1.HasKey("Id"); + + b1.HasIndex("UserId"); + + b1.ToTable("UserPermissionIds", (string)null); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => + { + b1.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b1.Property("City") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Country") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b1.Property("Street") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("Address"); + + b.Navigation("PermissionIds"); + }); + + modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Shopizy.Domain.Products.Product", b => + { + b.Navigation("ProductReviews"); + }); + + modelBuilder.Entity("Shopizy.Domain.Users.User", b => + { + b.Navigation("Orders"); + + b.Navigation("ProductReviews"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs b/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs new file mode 100644 index 0000000..b0b313c --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs @@ -0,0 +1,68 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class AddPermissionsTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Permissions", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + }, + constraints: table => + { + table.PrimaryKey("PK_Permissions", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "UserPermissionIds", + columns: table => new + { + Id = table + .Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PermissionId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_UserPermissionIds", x => x.Id); + table.ForeignKey( + name: "FK_UserPermissionIds_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateIndex( + name: "IX_UserPermissionIds_UserId", + table: "UserPermissionIds", + column: "UserId" + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable(name: "Permissions"); + + migrationBuilder.DropTable(name: "UserPermissionIds"); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.Designer.cs similarity index 99% rename from src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.Designer.cs rename to src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.Designer.cs index 582d33d..63ae69c 100644 --- a/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.Designer.cs +++ b/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.Designer.cs @@ -9,18 +9,18 @@ #nullable disable -namespace Shopizy.Infrastructure.Migrations +namespace shopizy.Infrastructure.Migrations { [DbContext(typeof(AppDbContext))] - [Migration("20250123152917_InitialDBChanges")] - partial class InitialDBChanges + [Migration("20241222122248_UpdateUsersTable")] + partial class UpdateUsersTable { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.12") + .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs b/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs new file mode 100644 index 0000000..102e761 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs @@ -0,0 +1,154 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace shopizy.Infrastructure.Migrations +{ + /// + public partial class UpdateUsersTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey(name: "FK_Orders_Users_UserId", table: "Orders"); + + migrationBuilder.DropIndex(name: "IX_Users_Phone", table: "Users"); + + migrationBuilder.DropIndex(name: "IX_Orders_UserId", table: "Orders"); + + migrationBuilder.AlterColumn( + name: "Phone", + table: "Users", + type: "nvarchar(15)", + maxLength: 15, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(15)", + oldMaxLength: 15 + ); + + migrationBuilder.AlterColumn( + name: "Email", + table: "Users", + type: "nvarchar(50)", + maxLength: 50, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true + ); + + migrationBuilder.CreateTable( + name: "OrderIds", + columns: table => new + { + Id = table + .Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OrderId = table.Column(type: "uniqueidentifier", nullable: false), + UseId = table.Column(type: "uniqueidentifier", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_OrderIds", x => x.Id); + table.ForeignKey( + name: "FK_OrderIds_Users_UseId", + column: x => x.UseId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "ProductReviewIds", + columns: table => new + { + Id = table + .Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductReviewId = table.Column(type: "uniqueidentifier", nullable: false), + UseId = table.Column(type: "uniqueidentifier", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_ProductReviewIds", x => x.Id); + table.ForeignKey( + name: "FK_ProductReviewIds_Users_UseId", + column: x => x.UseId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateIndex(name: "IX_Users_Email", table: "Users", column: "Email"); + + migrationBuilder.CreateIndex( + name: "IX_OrderIds_UseId", + table: "OrderIds", + column: "UseId" + ); + + migrationBuilder.CreateIndex( + name: "IX_ProductReviewIds_UseId", + table: "ProductReviewIds", + column: "UseId" + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable(name: "OrderIds"); + + migrationBuilder.DropTable(name: "ProductReviewIds"); + + migrationBuilder.DropIndex(name: "IX_Users_Email", table: "Users"); + + migrationBuilder.AlterColumn( + name: "Phone", + table: "Users", + type: "nvarchar(15)", + maxLength: 15, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(15)", + oldMaxLength: 15, + oldNullable: true + ); + + migrationBuilder.AlterColumn( + name: "Email", + table: "Users", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50 + ); + + migrationBuilder.CreateIndex(name: "IX_Users_Phone", table: "Users", column: "Phone"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_UserId", + table: "Orders", + column: "UserId" + ); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Users_UserId", + table: "Orders", + column: "UserId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs b/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs deleted file mode 100644 index cf69b69..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs +++ /dev/null @@ -1,716 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Shopizy.Infrastructure.Migrations -{ - /// - public partial class InitialDBChanges : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Carts", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("PK_Carts", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "Categories", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("PK_Categories", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - DeliveryMethod = table.Column(type: "int", nullable: false), - DeliveryCharge_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - DeliveryCharge_Currency = table.Column(type: "int", nullable: false), - OrderStatus = table.Column(type: "int", nullable: false), - CancellationReason = table.Column( - type: "nvarchar(200)", - maxLength: 200, - nullable: true - ), - PromoCode = table.Column( - type: "nvarchar(15)", - maxLength: 15, - nullable: true - ), - ShippingAddress_Street = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - ShippingAddress_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - ShippingAddress_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - ShippingAddress_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - ShippingAddress_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: false - ), - PaymentStatus = table.Column(type: "int", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: true), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Orders", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "Permissions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - }, - constraints: table => - { - table.PrimaryKey("PK_Permissions", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "PromoCodes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Code = table.Column( - type: "nvarchar(15)", - maxLength: 15, - nullable: false - ), - Description = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - Discount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - IsPerchantage = table.Column( - type: "bit", - nullable: false, - defaultValue: true - ), - IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), - NumOfTimeUsed = table.Column( - type: "int", - nullable: false, - defaultValue: 0 - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("PK_PromoCodes", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - FirstName = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - LastName = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - Email = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - ProfileImageUrl = table.Column(type: "nvarchar(max)", nullable: true), - Phone = table.Column( - type: "nvarchar(15)", - maxLength: 15, - nullable: true - ), - Password = table.Column(type: "nvarchar(max)", nullable: true), - CustomerId = table.Column( - type: "nvarchar(256)", - maxLength: 256, - nullable: true - ), - Address_Street = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - Address_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: true - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "Products", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - ShortDescription = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - Description = table.Column( - type: "nvarchar(200)", - maxLength: 200, - nullable: false - ), - CategoryId = table.Column(type: "uniqueidentifier", nullable: false), - SKU = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - StockQuantity = table.Column(type: "int", nullable: false), - UnitPrice_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - UnitPrice_Currency = table.Column(type: "int", nullable: false), - Discount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: true - ), - Brand = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: true - ), - Colors = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - Sizes = table.Column( - type: "nvarchar(20)", - maxLength: 20, - nullable: false - ), - Favourites = table.Column(type: "int", nullable: false), - Barcode = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: true - ), - Tags = table.Column( - type: "nvarchar(200)", - maxLength: 200, - nullable: true - ), - AverageRating_Value = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - AverageRating_NumRatings = table.Column(type: "int", nullable: false), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("PK_Products", x => x.Id); - table.ForeignKey( - name: "FK_Products_Categories_CategoryId", - column: x => x.CategoryId, - principalTable: "Categories", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateTable( - name: "OrderItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - OrderId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - PictureUrl = table.Column(type: "nvarchar(max)", nullable: true), - UnitPrice_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - UnitPrice_Currency = table.Column(type: "int", nullable: false), - Color = table.Column(type: "nvarchar(max)", nullable: false), - Size = table.Column(type: "nvarchar(max)", nullable: false), - Quantity = table.Column(type: "int", nullable: false), - Discount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - }, - constraints: table => - { - table.PrimaryKey("PK_OrderItems", x => new { x.Id, x.OrderId }); - table.ForeignKey( - name: "FK_OrderItems_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "OrderIds", - columns: table => new - { - Id = table - .Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - OrderId = table.Column(type: "uniqueidentifier", nullable: false), - UseId = table.Column(type: "uniqueidentifier", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_OrderIds", x => x.Id); - table.ForeignKey( - name: "FK_OrderIds_Users_UseId", - column: x => x.UseId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "Payments", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - OrderId = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - PaymentMethod = table.Column( - type: "nvarchar(20)", - maxLength: 20, - nullable: false - ), - PaymentMethodId = table.Column( - type: "nvarchar(260)", - maxLength: 260, - nullable: false - ), - TransactionId = table.Column( - type: "nvarchar(260)", - maxLength: 260, - nullable: true - ), - PaymentStatus = table.Column(type: "int", nullable: false), - Total_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - Total_Currency = table.Column(type: "int", nullable: false), - BillingAddress_Street = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - BillingAddress_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - BillingAddress_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - BillingAddress_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - BillingAddress_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: false - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("PK_Payments", x => x.Id); - table.ForeignKey( - name: "FK_Payments_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id" - ); - table.ForeignKey( - name: "FK_Payments_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateTable( - name: "ProductReviewIds", - columns: table => new - { - Id = table - .Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ProductReviewId = table.Column(type: "uniqueidentifier", nullable: false), - UseId = table.Column(type: "uniqueidentifier", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_ProductReviewIds", x => x.Id); - table.ForeignKey( - name: "FK_ProductReviewIds_Users_UseId", - column: x => x.UseId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "UserPermissionIds", - columns: table => new - { - Id = table - .Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PermissionId = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_UserPermissionIds", x => x.Id); - table.ForeignKey( - name: "FK_UserPermissionIds_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "CartItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CartId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Color = table.Column(type: "nvarchar(max)", nullable: false), - Size = table.Column(type: "nvarchar(max)", nullable: false), - Quantity = table.Column(type: "int", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_CartItems", x => new { x.Id, x.CartId }); - table.ForeignKey( - name: "FK_CartItems_Carts_CartId", - column: x => x.CartId, - principalTable: "Carts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_CartItems_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "ProductImages", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - ImageUrl = table.Column(type: "nvarchar(max)", nullable: false), - Seq = table.Column(type: "int", nullable: false), - PublicId = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - }, - constraints: table => - { - table.PrimaryKey("PK_ProductImages", x => new { x.ProductId, x.Id }); - table.ForeignKey( - name: "FK_ProductImages_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "ProductReviews", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Rating_Value = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - Comment = table.Column( - type: "nvarchar(1000)", - maxLength: 1000, - nullable: true - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("PK_ProductReviews", x => x.Id); - table.ForeignKey( - name: "FK_ProductReviews_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_ProductReviews_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_CartId", - table: "CartItems", - column: "CartId" - ); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_ProductId", - table: "CartItems", - column: "ProductId" - ); - - migrationBuilder.CreateIndex(name: "IX_Carts_UserId", table: "Carts", column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_OrderIds_UseId", - table: "OrderIds", - column: "UseId" - ); - - migrationBuilder.CreateIndex( - name: "IX_OrderItems_OrderId", - table: "OrderItems", - column: "OrderId" - ); - - migrationBuilder.CreateIndex( - name: "IX_Payments_OrderId", - table: "Payments", - column: "OrderId" - ); - - migrationBuilder.CreateIndex( - name: "IX_Payments_UserId", - table: "Payments", - column: "UserId" - ); - - migrationBuilder.CreateIndex( - name: "IX_ProductReviewIds_UseId", - table: "ProductReviewIds", - column: "UseId" - ); - - migrationBuilder.CreateIndex( - name: "IX_ProductReviews_ProductId", - table: "ProductReviews", - column: "ProductId" - ); - - migrationBuilder.CreateIndex( - name: "IX_ProductReviews_UserId", - table: "ProductReviews", - column: "UserId" - ); - - migrationBuilder.CreateIndex( - name: "IX_Products_CategoryId", - table: "Products", - column: "CategoryId" - ); - - migrationBuilder.CreateIndex( - name: "IX_PromoCodes_Code", - table: "PromoCodes", - column: "Code" - ); - - migrationBuilder.CreateIndex( - name: "IX_UserPermissionIds_UserId", - table: "UserPermissionIds", - column: "UserId" - ); - - migrationBuilder.CreateIndex(name: "IX_Users_Email", table: "Users", column: "Email"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "CartItems"); - - migrationBuilder.DropTable(name: "OrderIds"); - - migrationBuilder.DropTable(name: "OrderItems"); - - migrationBuilder.DropTable(name: "Payments"); - - migrationBuilder.DropTable(name: "Permissions"); - - migrationBuilder.DropTable(name: "ProductImages"); - - migrationBuilder.DropTable(name: "ProductReviewIds"); - - migrationBuilder.DropTable(name: "ProductReviews"); - - migrationBuilder.DropTable(name: "PromoCodes"); - - migrationBuilder.DropTable(name: "UserPermissionIds"); - - migrationBuilder.DropTable(name: "Carts"); - - migrationBuilder.DropTable(name: "Orders"); - - migrationBuilder.DropTable(name: "Products"); - - migrationBuilder.DropTable(name: "Users"); - - migrationBuilder.DropTable(name: "Categories"); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs b/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs index 04cbe33..61c5c52 100644 --- a/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs +++ b/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs @@ -8,7 +8,7 @@ #nullable disable -namespace Shopizy.Infrastructure.Migrations +namespace shopizy.Infrastructure.Migrations { [DbContext(typeof(AppDbContext))] partial class AppDbContextModelSnapshot : ModelSnapshot @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.12") + .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); From 4afa587905d877b71b846606bf5159aad2c1e40f Mon Sep 17 00:00:00 2001 From: "Md. Abul Kalam" Date: Thu, 23 Jan 2025 22:58:14 +0600 Subject: [PATCH 3/3] Reapply "Update DB migrations" This reverts commit c4c7a516c0e1e71313971703c6d682d939162007. --- .../UpdateUser/UpdateUserCommandHadler.cs | 7 +- .../Common/SeedData/SeedData.SQL | 33 +- .../20240303163205_InitialChanges.Designer.cs | 713 --------------- .../20240303163205_InitialChanges.cs | 508 ----------- ...132753_UpdateProductImageTable.Designer.cs | 718 --------------- .../20240325132753_UpdateProductImageTable.cs | 29 - .../20240329185149_AddedCartTable.Designer.cs | 778 ---------------- .../20240329185149_AddedCartTable.cs | 85 -- .../20240331173916_UpdateTables.Designer.cs | 778 ---------------- .../Migrations/20240331173916_UpdateTables.cs | 167 ---- ...0240401075111_UpdateCartTables.Designer.cs | 778 ---------------- .../20240401075111_UpdateCartTables.cs | 35 - ...240401075932_UpdateCartTables1.Designer.cs | 779 ---------------- .../20240401075932_UpdateCartTables1.cs | 54 -- ...20240417175416_UpdateUserTable.Designer.cs | 749 ---------------- .../20240417175416_UpdateUserTable.cs | 136 --- ...lesToMakeModifiedOnNotRequired.Designer.cs | 747 ---------------- ...UpdateTablesToMakeModifiedOnNotRequired.cs | 177 ---- ...240501170224_UpdateOrdersTable.Designer.cs | 751 ---------------- .../20240501170224_UpdateOrdersTable.cs | 28 - .../20240824162540_UpdateAddress.Designer.cs | 750 ---------------- .../20240824162540_UpdateAddress.cs | 47 - ...301_addEmailColumnsToUserTable.Designer.cs | 754 ---------------- ...240930175301_addEmailColumnsToUserTable.cs | 28 - ...002140454_makeEmailNotRequired.Designer.cs | 753 ---------------- .../20241002140454_makeEmailNotRequired.cs | 36 - ..._deleteUnusedColumnFromProduct.Designer.cs | 749 ---------------- ...020135147_deleteUnusedColumnFromProduct.cs | 29 - ...71255_AddCustomerIdInUserTable.Designer.cs | 753 ---------------- ...20241201171255_AddCustomerIdInUserTable.cs | 29 - ...41202145010_UpdatePaymentTable.Designer.cs | 758 ---------------- .../20241202145010_UpdatePaymentTable.cs | 52 -- ...02154947_UpdatePaymentTableRef.Designer.cs | 756 ---------------- .../20241202154947_UpdatePaymentTableRef.cs | 56 -- ...41211115321_UpdateRatingColumn.Designer.cs | 758 ---------------- .../20241211115321_UpdateRatingColumn.cs | 70 -- ...41211135310_UpdateProductTable.Designer.cs | 776 ---------------- .../20241211135310_UpdateProductTable.cs | 83 -- .../20241212165458_UpdateDatabase.Designer.cs | 795 ----------------- .../20241212165458_UpdateDatabase.cs | 138 --- ...213084430_UpdateCartItemsTable.Designer.cs | 794 ----------------- .../20241213084430_UpdateCartItemsTable.cs | 35 - ...1219151944_AddPermissionsTable.Designer.cs | 836 ------------------ .../20241219151944_AddPermissionsTable.cs | 68 -- .../20241222122248_UpdateUsersTable.cs | 154 ---- ...250123152917_InitialDBChanges.Designer.cs} | 8 +- .../20250123152917_InitialDBChanges.cs | 716 +++++++++++++++ .../Migrations/AppDbContextModelSnapshot.cs | 4 +- 48 files changed, 743 insertions(+), 18092 deletions(-) delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs delete mode 100644 src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs rename src/Shopizy.Infrastructure/Migrations/{20241222122248_UpdateUsersTable.Designer.cs => 20250123152917_InitialDBChanges.Designer.cs} (99%) create mode 100644 src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs diff --git a/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs b/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs index 258b2b3..a4892ff 100644 --- a/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs +++ b/src/Shopizy.Application/Users/Commands/UpdateUser/UpdateUserCommandHadler.cs @@ -1,16 +1,17 @@ using ErrorOr; using MediatR; +using Shopizy.Application.Common.Caching; using Shopizy.Application.Common.Interfaces.Persistence; using Shopizy.Domain.Common.CustomErrors; -using Shopizy.Domain.Orders.ValueObjects; using Shopizy.Domain.Users.ValueObjects; namespace Shopizy.Application.Users.Commands.UpdateUser; -public class UpdateUserCommandHandler(IUserRepository userRepository) +public class UpdateUserCommandHandler(IUserRepository userRepository, ICacheHelper cacheHelper) : IRequestHandler> { private readonly IUserRepository _userRepository = userRepository; + private readonly ICacheHelper _cacheHelper = cacheHelper; public async Task> Handle( UpdateUserCommand request, @@ -42,6 +43,8 @@ CancellationToken cancellationToken return CustomErrors.User.UserNotUpdated; } + await _cacheHelper.RemoveAsync($"user-{user.Id.Value}"); + return Result.Success; } } diff --git a/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL b/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL index aa3b3c8..e115164 100644 --- a/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL +++ b/src/Shopizy.Infrastructure/Common/SeedData/SeedData.SQL @@ -26,18 +26,17 @@ INSERT INTO [Categories] ([id], [name], [parentId]) VALUES -INSERT INTO [Products] ([id], [name], [description], [ShortDescription], [categoryId], [sku], [stockQuantity], [unitPrice_Amount], [unitPrice_Currency], [discount], [brand], [barcode], [tags], [averageRating_Value], [averageRating_NumRatings], [CreatedOn], [Colors], [Sizes]) VALUES - ('571D3D66-18F2-4DA8-A57B-D06D4D1C9EEF', 'Black Rockstar', 'High quality black t-shirt', 'High quality black t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000000T', '10', '20', '0', '10', 'Zara', 'MC-10000000T', 't-shirt, zara, men, new', '4.8', '5', GETDATE(), 'Black,Gray,Orange,Pink', 'XS,S,M,L,XL,2XL'), - ('096A127A-65AF-4C0C-A294-2E1990136711', 'Premium Purple', 'High quality purple t-shirt', 'High quality purple t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000002T', '5', '22', '0', '10', 'ck', 'MC-10000002T', 't-shirt, ck, men, new, premium', '4.9', '7', GETDATE(), 'Black,Orange,Pink,White', 'XS,S,M,L,XL,2XL'), - ('8419FD69-61A5-4D9D-A289-1E377CC17082', 'Red Dragon', 'Premium quality red sweater', 'Premium quality red sweater', '632DFDA9-CC2E-487B-8C88-608005F124E2', 'MC-10000000S', '20', '40', '0', '10', 'h&m', 'MC-10000000S', 'sweater, h&m, men, hot, premium', '4.7', '15', GETDATE(), 'Red,Orange,Pink,White', 'XS,S,M,L,XL,2XL'), - ('CBB8A3A9-03DB-40E4-A89B-9C91D21B3934', 'Ash life', 'High quality t-shirt', 'High quality t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000004T', '15', '25', '0', '10', 'ck', 'MC-10000004T', 't-shirt, ck, men, new, premium', '4.7', '5', GETDATE(), 'Black,Gray,Pink,White', 'XS,S,M,L,XL,2XL'), - ('96A1503F-B7EA-4C12-8946-89035399F45E', 'Red Star', 'High quality t-shirt for men', 'High quality t-shirt for men', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000006T', '30', '20', '0', '10', 'Boss', 'MC-10000006T', 't-shirt, boss, men', '4.6', '10', GETDATE(), 'Red,Black,Orange', 'XS,S,M,L,XL,2XL'), - ('E02500EA-2957-4601-A051-951CB9957CBE', 'Black Stone', 'Premium quality t-shirt for women', 'Premium quality t-shirt for women', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000000T', '30', '40', '0', '10', 'Adidas', 'FC-10000000T', 't-shirt, adidas, new, premium', '4.9', '15', GETDATE(), 'Black,Gray', 'XS,S,M,L,XL,2XL'), - ('A34BA283-62A1-43C6-8FB0-748DBDE8BA7D', 'Elegant peach', 'High quality women top', 'High quality women top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000002T', '10', '20', '0', '10', 'h&m', 'FC-10000002T', 'top, h&m, new', '4.7', '15', GETDATE(), ',Orange,Pink,Peach', 'XS,S,M,L,XL,2XL'), - ('D7C96816-1656-4DBC-B709-0F626807347F', 'Pure White', 'High quality women t-shirt', 'High quality women t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000004T', '20', '20', '0', '10', 'ck', 'FC-10000004T', 't-shirt, ck, new', '4.7', '5', GETDATE(), 'White', 'XS,S,M,L,XL,2XL'), - ('DF22BA6B-A15B-4125-AF29-07E242AF6F2D', 'Natural Green', 'High quality t-shirt', 'High quality t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000006T', '20', '25', '0', '5', 'Zara', 'FC-10000006T', 't-shirt, zara', '4.6', '5', GETDATE(), 'Green', 'XS,S,M,L,XL,2XL'), - ('9EB9982F-E672-4184-8399-044277EEF754', 'New Way', 'Premium quality top', 'Premium quality top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000008T', '30', '30', '0', '10', 'Nike', 'FC-10000008T', 'top, nike, new', '4.8', '20', GETDATE(), 'Black,Gray,Orange,Pink,White', 'XS,S,M,L,XL,2XL'); - +INSERT INTO [Products] ([id], [name], [description], [ShortDescription], [categoryId], [sku], [stockQuantity], [unitPrice_Amount], [unitPrice_Currency], [discount], [brand], [barcode], [tags], [averageRating_Value], [averageRating_NumRatings], [CreatedOn], [Colors], [Sizes], [Favourites]) VALUES + ('571D3D66-18F2-4DA8-A57B-D06D4D1C9EEF', 'Black Rockstar', 'High quality black t-shirt', 'High quality black t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000000T', '10', '20', '0', '10', 'Zara', 'MC-10000000T', 't-shirt, zara, men, new', '4.8', '5', GETDATE(), 'Black,Gray,Orange,Pink', 'XS,S,M,L,XL,2XL', 0), + ('096A127A-65AF-4C0C-A294-2E1990136711', 'Premium Purple', 'High quality purple t-shirt', 'High quality purple t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000002T', '5', '22', '0', '10', 'ck', 'MC-10000002T', 't-shirt, ck, men, new, premium', '4.9', '7', GETDATE(), 'Black,Orange,Pink,White', 'XS,S,M,L,XL,2XL', 0), + ('8419FD69-61A5-4D9D-A289-1E377CC17082', 'Red Dragon', 'Premium quality red sweater', 'Premium quality red sweater', '632DFDA9-CC2E-487B-8C88-608005F124E2', 'MC-10000000S', '20', '40', '0', '10', 'h&m', 'MC-10000000S', 'sweater, h&m, men, hot, premium', '4.7', '15', GETDATE(), 'Red,Orange,Pink,White', 'XS,S,M,L,XL,2XL', 0), + ('CBB8A3A9-03DB-40E4-A89B-9C91D21B3934', 'Ash life', 'High quality t-shirt', 'High quality t-shirt', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000004T', '15', '25', '0', '10', 'ck', 'MC-10000004T', 't-shirt, ck, men, new, premium', '4.7', '5', GETDATE(), 'Black,Gray,Pink,White', 'XS,S,M,L,XL,2XL', 0), + ('96A1503F-B7EA-4C12-8946-89035399F45E', 'Red Star', 'High quality t-shirt for men', 'High quality t-shirt for men', '106F4F94-5E70-4340-B23E-462AF5FC7BFC', 'MC-10000006T', '30', '20', '0', '10', 'Boss', 'MC-10000006T', 't-shirt, boss, men', '4.6', '10', GETDATE(), 'Red,Black,Orange', 'XS,S,M,L,XL,2XL', 0), + ('E02500EA-2957-4601-A051-951CB9957CBE', 'Black Stone', 'Premium quality t-shirt for women', 'Premium quality t-shirt for women', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000000T', '30', '40', '0', '10', 'Adidas', 'FC-10000000T', 't-shirt, adidas, new, premium', '4.9', '15', GETDATE(), 'Black,Gray', 'XS,S,M,L,XL,2XL', 0), + ('A34BA283-62A1-43C6-8FB0-748DBDE8BA7D', 'Elegant peach', 'High quality women top', 'High quality women top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000002T', '10', '20', '0', '10', 'h&m', 'FC-10000002T', 'top, h&m, new', '4.7', '15', GETDATE(), ',Orange,Pink,Peach', 'XS,S,M,L,XL,2XL', 0), + ('D7C96816-1656-4DBC-B709-0F626807347F', 'Pure White', 'High quality women t-shirt', 'High quality women t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000004T', '20', '20', '0', '10', 'ck', 'FC-10000004T', 't-shirt, ck, new', '4.7', '5', GETDATE(), 'White', 'XS,S,M,L,XL,2XL', 0), + ('DF22BA6B-A15B-4125-AF29-07E242AF6F2D', 'Natural Green', 'High quality t-shirt', 'High quality t-shirt', 'A805A418-2D53-4430-9968-D031C4F39FD4', 'FC-10000006T', '20', '25', '0', '5', 'Zara', 'FC-10000006T', 't-shirt, zara', '4.6', '5', GETDATE(), 'Green', 'XS,S,M,L,XL,2XL', 0), + ('9EB9982F-E672-4184-8399-044277EEF754', 'New Way', 'Premium quality top', 'Premium quality top', 'BA5FE17F-8977-4034-BEC3-227AA99502CC', 'FC-10000008T', '30', '30', '0', '10', 'Nike', 'FC-10000008T', 'top, nike, new', '4.8', '20', GETDATE(), 'Black,Gray,Orange,Pink,White', 'XS,S,M,L,XL,2XL', 0); INSERT INTO [ProductImages] ([id], [productId], [imageUrl], [seq], [publicId]) VALUES ('4DBB9D7F-5B09-4ECF-AEB9-B1F5F6473379', '571D3D66-18F2-4DA8-A57B-D06D4D1C9EEF', 'https://res.cloudinary.com/akazad13/image/upload/v1729420812/shopizy/mpjks43jpxo9eagempgu.jpg', '0', 'mpjks43jpxo9eagempgu'), @@ -53,11 +52,11 @@ INSERT INTO [ProductImages] ([id], [productId], [imageUrl], [seq], [publicId]) V ('A8A70F86-7987-4BB4-A344-1B2133DCC609', '096A127A-65AF-4C0C-A294-2E1990136711', 'https://res.cloudinary.com/akazad13/image/upload/v1733579506/shopizy/men2_2_d4dn3p.jpg', 1, 'men2_2_d4dn3p'); INSERT INTO ProductReviews(Id, UserId, ProductId, Rating_Value, Comment, CreatedOn) -VALUES('20AB2C8F-E880-45C3-8887-D0A0E2E0E763','E68D8E76-72A1-42ED-91D0-0ED0296D662E','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), -('C75B65D5-13D1-4FC9-A81E-19D7FB3B7784','67726B00-2647-4817-BFCB-3781EBD97E0F','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), -('41B53394-5014-45E6-9540-B7FA05782B6C','6EBA643C-D138-4D90-AA7C-6DBF935D8209','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Good T-Shirt!', GETDATE()), -('F9CA8F97-2B91-4EAD-88D7-78496A92616A','88D9AF82-BEF4-4042-8E55-B01B89F23E68','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Recommanded!', GETDATE()), -('7ED64773-2ED6-4BFB-BBA0-E267BA4A8208','E68D8E76-72A1-42ED-91D0-0ED0296D662E','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Looks good', GETDATE()); +VALUES('20AB2C8F-E880-45C3-8887-D0A0E2E0E763','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), +('C75B65D5-13D1-4FC9-A81E-19D7FB3B7784','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Looks Awesome!', GETDATE()), +('41B53394-5014-45E6-9540-B7FA05782B6C','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Good T-Shirt!', GETDATE()), +('F9CA8F97-2B91-4EAD-88D7-78496A92616A','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',5, 'Recommanded!', GETDATE()), +('7ED64773-2ED6-4BFB-BBA0-E267BA4A8208','E66D52FD-E2CE-4ABD-BBFB-C25CEE190E3D','DF22BA6B-A15B-4125-AF29-07E242AF6F2D',4, 'Looks good', GETDATE()); diff --git a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs deleted file mode 100644 index d4e580a..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.Designer.cs +++ /dev/null @@ -1,713 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240303163205_InitialChanges")] - partial class InitialChanges - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId") - .IsUnique(); - - b.HasIndex("OrderId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.HasIndex("ProductId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("Orders") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", "Customer") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "CustomerId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Customer"); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("ProductReviews") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs b/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs deleted file mode 100644 index b5ec666..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240303163205_InitialChanges.cs +++ /dev/null @@ -1,508 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class InitialChanges : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Categories", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("PK_Categories", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "PromoCodes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Code = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: false), - Description = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - Discount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - IsPerchantage = table.Column( - type: "bit", - nullable: false, - defaultValue: true - ), - IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), - NumOfTimeUsed = table.Column(type: "int", nullable: false, defaultValue: 0), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_PromoCodes", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - FirstName = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - LastName = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - Phone = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: true), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "Products", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - Description = table.Column( - type: "nvarchar(200)", - maxLength: 200, - nullable: false - ), - CategoryId = table.Column(type: "uniqueidentifier", nullable: false), - SKU = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - StockQuantity = table.Column(type: "int", nullable: false), - UnitPrice_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - UnitPrice_Currency = table.Column(type: "int", nullable: false), - Discount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: true - ), - Brand = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - Barcode = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - Tags = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - AverageRating_Value = table.Column( - type: "float(18)", - precision: 18, - scale: 2, - nullable: false - ), - AverageRating_NumRatings = table.Column(type: "int", nullable: false), - BreadCrums = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Products", x => x.Id); - table.ForeignKey( - name: "FK_Products_Categories_CategoryId", - column: x => x.CategoryId, - principalTable: "Categories", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateTable( - name: "Customers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ProfileImageUrl = table.Column(type: "nvarchar(max)", nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - Address_Line = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - Address_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: true - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Customers", x => x.Id); - table.ForeignKey( - name: "FK_Customers_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateTable( - name: "ProductImages", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - ImageUrl = table.Column(type: "nvarchar(max)", nullable: false), - Seq = table.Column(type: "int", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_ProductImages", x => new { x.ProductId, x.Id }); - table.ForeignKey( - name: "FK_ProductImages_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false), - DeliveryCharge_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - DeliveryCharge_Currency = table.Column(type: "int", nullable: false), - OrderStatus = table.Column(type: "int", nullable: false), - PromoCode = table.Column( - type: "nvarchar(15)", - maxLength: 15, - nullable: true - ), - ShippingAddress_Line = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - ShippingAddress_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - ShippingAddress_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - ShippingAddress_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - ShippingAddress_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: false - ), - PaymentStatus = table.Column( - type: "nvarchar(20)", - maxLength: 20, - nullable: false - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Orders", x => x.Id); - table.ForeignKey( - name: "FK_Orders_Customers_CustomerId", - column: x => x.CustomerId, - principalTable: "Customers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "ProductReviews", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Rating_Value = table.Column( - type: "float(18)", - precision: 18, - scale: 2, - nullable: false - ), - Comment = table.Column( - type: "nvarchar(1000)", - maxLength: 1000, - nullable: true - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_ProductReviews", x => x.Id); - table.ForeignKey( - name: "FK_ProductReviews_Customers_CustomerId", - column: x => x.CustomerId, - principalTable: "Customers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_ProductReviews_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "OrderItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - OrderId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - PictureUrl = table.Column(type: "nvarchar(max)", nullable: true), - UnitPrice_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - UnitPrice_Currency = table.Column(type: "int", nullable: false), - Quantity = table.Column(type: "int", nullable: false), - Discount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - }, - constraints: table => - { - table.PrimaryKey("PK_OrderItems", x => new { x.Id, x.OrderId }); - table.ForeignKey( - name: "FK_OrderItems_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "Payments", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - OrderId = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false), - PaymentMethod = table.Column( - type: "nvarchar(20)", - maxLength: 20, - nullable: false - ), - TransactionId = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: true - ), - PaymentStatus = table.Column(type: "int", nullable: false), - Total_Amount = table.Column( - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false - ), - Total_Currency = table.Column(type: "int", nullable: false), - BillingAddress_Line = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: false - ), - BillingAddress_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - BillingAddress_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - BillingAddress_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: false - ), - BillingAddress_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: false - ), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_Payments", x => x.Id); - table.ForeignKey( - name: "FK_Payments_Customers_CustomerId", - column: x => x.CustomerId, - principalTable: "Customers", - principalColumn: "Id" - ); - table.ForeignKey( - name: "FK_Payments_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_Customers_UserId", - table: "Customers", - column: "UserId", - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_OrderItems_OrderId", - table: "OrderItems", - column: "OrderId" - ); - - migrationBuilder.CreateIndex( - name: "IX_Orders_CustomerId", - table: "Orders", - column: "CustomerId" - ); - - migrationBuilder.CreateIndex( - name: "IX_Payments_CustomerId", - table: "Payments", - column: "CustomerId", - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_Payments_OrderId", - table: "Payments", - column: "OrderId", - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_ProductReviews_CustomerId", - table: "ProductReviews", - column: "CustomerId" - ); - - migrationBuilder.CreateIndex( - name: "IX_ProductReviews_ProductId", - table: "ProductReviews", - column: "ProductId" - ); - - migrationBuilder.CreateIndex( - name: "IX_Products_CategoryId", - table: "Products", - column: "CategoryId" - ); - - migrationBuilder.CreateIndex( - name: "IX_PromoCodes_Code", - table: "PromoCodes", - column: "Code" - ); - - migrationBuilder.CreateIndex(name: "IX_Users_Phone", table: "Users", column: "Phone"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "OrderItems"); - - migrationBuilder.DropTable(name: "Payments"); - - migrationBuilder.DropTable(name: "ProductImages"); - - migrationBuilder.DropTable(name: "ProductReviews"); - - migrationBuilder.DropTable(name: "PromoCodes"); - - migrationBuilder.DropTable(name: "Orders"); - - migrationBuilder.DropTable(name: "Products"); - - migrationBuilder.DropTable(name: "Customers"); - - migrationBuilder.DropTable(name: "Categories"); - - migrationBuilder.DropTable(name: "Users"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs deleted file mode 100644 index 0ba565b..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.Designer.cs +++ /dev/null @@ -1,718 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240325132753_UpdateProductImageTable")] - partial class UpdateProductImageTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId") - .IsUnique(); - - b.HasIndex("OrderId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.HasIndex("ProductId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("Orders") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", "Customer") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "CustomerId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Customer"); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("ProductReviews") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs b/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs deleted file mode 100644 index 4f984ac..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240325132753_UpdateProductImageTable.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateProductImageTable : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "PublicId", - table: "ProductImages", - type: "nvarchar(100)", - maxLength: 100, - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "PublicId", - table: "ProductImages"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs deleted file mode 100644 index 5ac3cd8..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.Designer.cs +++ /dev/null @@ -1,778 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240329185149_AddedCartTable")] - partial class AddedCartTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId") - .IsUnique(); - - b.HasIndex("OrderId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.HasIndex("ProductId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("Orders") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", "Customer") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "CustomerId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Customer"); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Customers.Customer", null) - .WithMany("ProductReviews") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs b/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs deleted file mode 100644 index eb9af8d..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240329185149_AddedCartTable.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class AddedCartTable : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Carts", - columns: table => - new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Carts", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "LineItems", - columns: table => - new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CartId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Quantity = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LineItems", x => new { x.Id, x.CartId }); - table.ForeignKey( - name: "FK_LineItems_Carts_CartId", - column: x => x.CartId, - principalTable: "Carts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_LineItems_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_Carts_CustomerId", - table: "Carts", - column: "CustomerId" - ); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_CartId", - table: "LineItems", - column: "CartId" - ); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_ProductId", - table: "LineItems", - column: "ProductId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "LineItems"); - - migrationBuilder.DropTable(name: "Carts"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs deleted file mode 100644 index f7f624c..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.Designer.cs +++ /dev/null @@ -1,778 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240331173916_UpdateTables")] - partial class UpdateTables - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs b/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs deleted file mode 100644 index 53eadf5..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240331173916_UpdateTables.cs +++ /dev/null @@ -1,167 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateTables : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Orders_Customers_CustomerId", - table: "Orders"); - - migrationBuilder.DropForeignKey( - name: "FK_Payments_Customers_CustomerId", - table: "Payments"); - - migrationBuilder.DropForeignKey( - name: "FK_ProductReviews_Customers_CustomerId", - table: "ProductReviews"); - - migrationBuilder.RenameColumn( - name: "CustomerId", - table: "ProductReviews", - newName: "UserId"); - - migrationBuilder.RenameIndex( - name: "IX_ProductReviews_CustomerId", - table: "ProductReviews", - newName: "IX_ProductReviews_UserId"); - - migrationBuilder.RenameColumn( - name: "CustomerId", - table: "Payments", - newName: "UserId"); - - migrationBuilder.RenameIndex( - name: "IX_Payments_CustomerId", - table: "Payments", - newName: "IX_Payments_UserId"); - - migrationBuilder.RenameColumn( - name: "CustomerId", - table: "Orders", - newName: "UserId"); - - migrationBuilder.RenameIndex( - name: "IX_Orders_CustomerId", - table: "Orders", - newName: "IX_Orders_UserId"); - - migrationBuilder.RenameColumn( - name: "CustomerId", - table: "Carts", - newName: "UserId"); - - migrationBuilder.RenameIndex( - name: "IX_Carts_CustomerId", - table: "Carts", - newName: "IX_Carts_UserId"); - - migrationBuilder.AddForeignKey( - name: "FK_Orders_Users_UserId", - table: "Orders", - column: "UserId", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Payments_Users_UserId", - table: "Payments", - column: "UserId", - principalTable: "Users", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_ProductReviews_Users_UserId", - table: "ProductReviews", - column: "UserId", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Orders_Users_UserId", - table: "Orders"); - - migrationBuilder.DropForeignKey( - name: "FK_Payments_Users_UserId", - table: "Payments"); - - migrationBuilder.DropForeignKey( - name: "FK_ProductReviews_Users_UserId", - table: "ProductReviews"); - - migrationBuilder.RenameColumn( - name: "UserId", - table: "ProductReviews", - newName: "CustomerId"); - - migrationBuilder.RenameIndex( - name: "IX_ProductReviews_UserId", - table: "ProductReviews", - newName: "IX_ProductReviews_CustomerId"); - - migrationBuilder.RenameColumn( - name: "UserId", - table: "Payments", - newName: "CustomerId"); - - migrationBuilder.RenameIndex( - name: "IX_Payments_UserId", - table: "Payments", - newName: "IX_Payments_CustomerId"); - - migrationBuilder.RenameColumn( - name: "UserId", - table: "Orders", - newName: "CustomerId"); - - migrationBuilder.RenameIndex( - name: "IX_Orders_UserId", - table: "Orders", - newName: "IX_Orders_CustomerId"); - - migrationBuilder.RenameColumn( - name: "UserId", - table: "Carts", - newName: "CustomerId"); - - migrationBuilder.RenameIndex( - name: "IX_Carts_UserId", - table: "Carts", - newName: "IX_Carts_CustomerId"); - - migrationBuilder.AddForeignKey( - name: "FK_Orders_Customers_CustomerId", - table: "Orders", - column: "CustomerId", - principalTable: "Customers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Payments_Customers_CustomerId", - table: "Payments", - column: "CustomerId", - principalTable: "Customers", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_ProductReviews_Customers_CustomerId", - table: "ProductReviews", - column: "CustomerId", - principalTable: "Customers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs deleted file mode 100644 index e2f8288..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.Designer.cs +++ /dev/null @@ -1,778 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240401075111_UpdateCartTables")] - partial class UpdateCartTables - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId", "ProductId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs b/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs deleted file mode 100644 index 0ccccd6..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240401075111_UpdateCartTables.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateCartTables : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_LineItems", - table: "LineItems"); - - migrationBuilder.AddPrimaryKey( - name: "PK_LineItems", - table: "LineItems", - columns: new[] { "Id", "CartId", "ProductId" }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_LineItems", - table: "LineItems"); - - migrationBuilder.AddPrimaryKey( - name: "PK_LineItems", - table: "LineItems", - columns: new[] { "Id", "CartId" }); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs deleted file mode 100644 index 3f707c9..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.Designer.cs +++ /dev/null @@ -1,779 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240401075932_UpdateCartTables1")] - partial class UpdateCartTables1 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Customers", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Customers.Customer", b => - { - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Customers.Customer", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("CustomerId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("CustomerId"); - - b1.ToTable("Customers"); - - b1.WithOwner() - .HasForeignKey("CustomerId"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs b/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs deleted file mode 100644 index 9be292e..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240401075932_UpdateCartTables1.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateCartTables1 : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_LineItems", - table: "LineItems"); - - migrationBuilder.DropIndex( - name: "IX_LineItems_CartId", - table: "LineItems"); - - migrationBuilder.AddPrimaryKey( - name: "PK_LineItems", - table: "LineItems", - columns: new[] { "Id", "CartId" }); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_CartId_ProductId", - table: "LineItems", - columns: new[] { "CartId", "ProductId" }, - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_LineItems", - table: "LineItems"); - - migrationBuilder.DropIndex( - name: "IX_LineItems_CartId_ProductId", - table: "LineItems"); - - migrationBuilder.AddPrimaryKey( - name: "PK_LineItems", - table: "LineItems", - columns: new[] { "Id", "CartId", "ProductId" }); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_CartId", - table: "LineItems", - column: "CartId"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs deleted file mode 100644 index fa98f30..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.Designer.cs +++ /dev/null @@ -1,749 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240417175416_UpdateUserTable")] - partial class UpdateUserTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs b/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs deleted file mode 100644 index dbed064..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240417175416_UpdateUserTable.cs +++ /dev/null @@ -1,136 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateUserTable : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "Customers"); - - migrationBuilder.AddColumn( - name: "Address_City", - table: "Users", - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "Address_Country", - table: "Users", - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "Address_Line", - table: "Users", - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "Address_State", - table: "Users", - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "Address_ZipCode", - table: "Users", - type: "nvarchar(10)", - maxLength: 10, - nullable: true - ); - - migrationBuilder.AddColumn( - name: "ProfileImageUrl", - table: "Users", - type: "nvarchar(max)", - nullable: true - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn(name: "Address_City", table: "Users"); - - migrationBuilder.DropColumn(name: "Address_Country", table: "Users"); - - migrationBuilder.DropColumn(name: "Address_Line", table: "Users"); - - migrationBuilder.DropColumn(name: "Address_State", table: "Users"); - - migrationBuilder.DropColumn(name: "Address_ZipCode", table: "Users"); - - migrationBuilder.DropColumn(name: "ProfileImageUrl", table: "Users"); - - migrationBuilder.CreateTable( - name: "Customers", - columns: table => - new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - CreatedOn = table.Column(type: "smalldatetime", nullable: false), - ModifiedOn = table.Column(type: "smalldatetime", nullable: false), - ProfileImageUrl = table.Column( - type: "nvarchar(max)", - nullable: true - ), - Address_City = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_Country = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_Line = table.Column( - type: "nvarchar(100)", - maxLength: 100, - nullable: true - ), - Address_State = table.Column( - type: "nvarchar(30)", - maxLength: 30, - nullable: true - ), - Address_ZipCode = table.Column( - type: "nvarchar(10)", - maxLength: 10, - nullable: true - ) - }, - constraints: table => - { - table.PrimaryKey("PK_Customers", x => x.Id); - table.ForeignKey( - name: "FK_Customers_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id" - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_Customers_UserId", - table: "Customers", - column: "UserId", - unique: true - ); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs deleted file mode 100644 index 7dff433..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.Designer.cs +++ /dev/null @@ -1,747 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240420191703_UpdateTablesToMakeModifiedOnNotRequired")] - partial class UpdateTablesToMakeModifiedOnNotRequired - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs b/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs deleted file mode 100644 index 72491c4..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240420191703_UpdateTablesToMakeModifiedOnNotRequired.cs +++ /dev/null @@ -1,177 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateTablesToMakeModifiedOnNotRequired : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Users", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "PromoCodes", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Products", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "ProductReviews", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Payments", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "PaymentStatus", - table: "Orders", - type: "int", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(20)", - oldMaxLength: 20 - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Orders", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Carts", - type: "smalldatetime", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "smalldatetime" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Users", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "PromoCodes", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Products", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "ProductReviews", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Payments", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "PaymentStatus", - table: "Orders", - type: "nvarchar(20)", - maxLength: 20, - nullable: false, - oldClrType: typeof(int), - oldType: "int" - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Orders", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "ModifiedOn", - table: "Carts", - type: "smalldatetime", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - oldClrType: typeof(DateTime), - oldType: "smalldatetime", - oldNullable: true - ); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs deleted file mode 100644 index 57d8b84..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.Designer.cs +++ /dev/null @@ -1,751 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240501170224_UpdateOrdersTable")] - partial class UpdateOrdersTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Line") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs b/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs deleted file mode 100644 index 288fb65..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240501170224_UpdateOrdersTable.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateOrdersTable : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CancellationReason", - table: "Orders", - type: "nvarchar(200)", - maxLength: 200, - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CancellationReason", - table: "Orders"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs deleted file mode 100644 index f8f0c37..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.Designer.cs +++ /dev/null @@ -1,750 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240824162540_UpdateAddress")] - partial class UpdateAddress - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs b/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs deleted file mode 100644 index 4608f50..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240824162540_UpdateAddress.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations; - -/// -public partial class UpdateAddress : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "Address_Line", - table: "Users", - newName: "Address_Street"); - - migrationBuilder.RenameColumn( - name: "BillingAddress_Line", - table: "Payments", - newName: "BillingAddress_Street"); - - migrationBuilder.RenameColumn( - name: "ShippingAddress_Line", - table: "Orders", - newName: "ShippingAddress_Street"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "Address_Street", - table: "Users", - newName: "Address_Line"); - - migrationBuilder.RenameColumn( - name: "BillingAddress_Street", - table: "Payments", - newName: "BillingAddress_Line"); - - migrationBuilder.RenameColumn( - name: "ShippingAddress_Street", - table: "Orders", - newName: "ShippingAddress_Line"); - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs deleted file mode 100644 index 4965186..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.Designer.cs +++ /dev/null @@ -1,754 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20240930175301_addEmailColumnsToUserTable")] - partial class addEmailColumnsToUserTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs b/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs deleted file mode 100644 index 15ba2f2..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20240930175301_addEmailColumnsToUserTable.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class addEmailColumnsToUserTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Email", - table: "Users", - type: "nvarchar(max)", - nullable: false, - defaultValue: "" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn(name: "Email", table: "Users"); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs deleted file mode 100644 index a2a020a..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.Designer.cs +++ /dev/null @@ -1,753 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241002140454_makeEmailNotRequired")] - partial class makeEmailNotRequired - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("BreadCrums") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs b/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs deleted file mode 100644 index c77ced4..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241002140454_makeEmailNotRequired.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class makeEmailNotRequired : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "nvarchar(max)", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs deleted file mode 100644 index fb56d31..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.Designer.cs +++ /dev/null @@ -1,749 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241020135147_deleteUnusedColumnFromProduct")] - partial class deleteUnusedColumnFromProduct - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs b/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs deleted file mode 100644 index f74a330..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241020135147_deleteUnusedColumnFromProduct.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class deleteUnusedColumnFromProduct : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "BreadCrums", - table: "Products"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "BreadCrums", - table: "Products", - type: "nvarchar(100)", - maxLength: 100, - nullable: true); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs deleted file mode 100644 index aafa8b9..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.Designer.cs +++ /dev/null @@ -1,753 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241201171255_AddCustomerIdInUserTable")] - partial class AddCustomerIdInUserTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs b/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs deleted file mode 100644 index fad4155..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241201171255_AddCustomerIdInUserTable.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class AddCustomerIdInUserTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CustomerId", - table: "Users", - type: "nvarchar(256)", - maxLength: 256, - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CustomerId", - table: "Users"); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs deleted file mode 100644 index 47ee956..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.Designer.cs +++ /dev/null @@ -1,758 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241202145010_UpdatePaymentTable")] - partial class UpdatePaymentTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId") - .IsUnique(); - - b.HasIndex("UserId") - .IsUnique(); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithOne() - .HasForeignKey("Shopizy.Domain.Payments.Payment", "UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs b/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs deleted file mode 100644 index d735f6f..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241202145010_UpdatePaymentTable.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdatePaymentTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "TransactionId", - table: "Payments", - type: "nvarchar(260)", - maxLength: 260, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(50)", - oldMaxLength: 50, - oldNullable: true); - - migrationBuilder.AddColumn( - name: "PaymentMethodId", - table: "Payments", - type: "nvarchar(260)", - maxLength: 260, - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "PaymentMethodId", - table: "Payments"); - - migrationBuilder.AlterColumn( - name: "TransactionId", - table: "Payments", - type: "nvarchar(50)", - maxLength: 50, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(260)", - oldMaxLength: 260, - oldNullable: true); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs deleted file mode 100644 index e703d89..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.Designer.cs +++ /dev/null @@ -1,756 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241202154947_UpdatePaymentTableRef")] - partial class UpdatePaymentTableRef - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("float(18)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs b/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs deleted file mode 100644 index a0d48e9..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241202154947_UpdatePaymentTableRef.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdatePaymentTableRef : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_Payments_OrderId", - table: "Payments"); - - migrationBuilder.DropIndex( - name: "IX_Payments_UserId", - table: "Payments"); - - migrationBuilder.CreateIndex( - name: "IX_Payments_OrderId", - table: "Payments", - column: "OrderId"); - - migrationBuilder.CreateIndex( - name: "IX_Payments_UserId", - table: "Payments", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_Payments_OrderId", - table: "Payments"); - - migrationBuilder.DropIndex( - name: "IX_Payments_UserId", - table: "Payments"); - - migrationBuilder.CreateIndex( - name: "IX_Payments_OrderId", - table: "Payments", - column: "OrderId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Payments_UserId", - table: "Payments", - column: "UserId", - unique: true); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs deleted file mode 100644 index a573aae..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.Designer.cs +++ /dev/null @@ -1,758 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241211115321_UpdateRatingColumn")] - partial class UpdateRatingColumn - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs b/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs deleted file mode 100644 index 6f31cda..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241211115321_UpdateRatingColumn.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateRatingColumn : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "AverageRating_Value", - table: "Products", - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false, - oldClrType: typeof(double), - oldType: "float(18)", - oldPrecision: 18, - oldScale: 2 - ); - - migrationBuilder.AlterColumn( - name: "Rating_Value", - table: "ProductReviews", - type: "decimal(18,2)", - precision: 18, - scale: 2, - nullable: false, - oldClrType: typeof(double), - oldType: "float(18)", - oldPrecision: 18, - oldScale: 2 - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "AverageRating_Value", - table: "Products", - type: "float(18)", - precision: 18, - scale: 2, - nullable: false, - oldClrType: typeof(decimal), - oldType: "decimal(18,2)", - oldPrecision: 18, - oldScale: 2 - ); - - migrationBuilder.AlterColumn( - name: "Rating_Value", - table: "ProductReviews", - type: "float(18)", - precision: 18, - scale: 2, - nullable: false, - oldClrType: typeof(decimal), - oldType: "decimal(18,2)", - oldPrecision: 18, - oldScale: 2 - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs deleted file mode 100644 index ebe8da7..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.Designer.cs +++ /dev/null @@ -1,776 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241211135310_UpdateProductTable")] - partial class UpdateProductTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("Colors") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("Favourites") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ShortDescription") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.LineItem", "LineItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("LineItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("LineItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs b/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs deleted file mode 100644 index af70866..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241211135310_UpdateProductTable.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateProductTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Name", - table: "Products", - type: "nvarchar(50)", - maxLength: 50, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(100)", - oldMaxLength: 100 - ); - - migrationBuilder.AddColumn( - name: "Colors", - table: "Products", - type: "nvarchar(50)", - maxLength: 50, - nullable: false, - defaultValue: "" - ); - - migrationBuilder.AddColumn( - name: "Favourites", - table: "Products", - type: "int", - nullable: false, - defaultValue: 0 - ); - - migrationBuilder.AddColumn( - name: "ShortDescription", - table: "Products", - type: "nvarchar(100)", - maxLength: 100, - nullable: false, - defaultValue: "" - ); - - migrationBuilder.AddColumn( - name: "Sizes", - table: "Products", - type: "nvarchar(20)", - maxLength: 20, - nullable: false, - defaultValue: "" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn(name: "Colors", table: "Products"); - - migrationBuilder.DropColumn(name: "Favourites", table: "Products"); - - migrationBuilder.DropColumn(name: "ShortDescription", table: "Products"); - - migrationBuilder.DropColumn(name: "Sizes", table: "Products"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Products", - type: "nvarchar(100)", - maxLength: 100, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(50)", - oldMaxLength: 50 - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs deleted file mode 100644 index f078d26..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.Designer.cs +++ /dev/null @@ -1,795 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241212165458_UpdateDatabase")] - partial class UpdateDatabase - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("DeliveryMethod") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("Colors") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("Favourites") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ShortDescription") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.CartItem", "CartItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("ProductId"); - - b1.HasIndex("CartId", "ProductId") - .IsUnique(); - - b1.ToTable("CartItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("CartItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs b/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs deleted file mode 100644 index 0321948..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241212165458_UpdateDatabase.cs +++ /dev/null @@ -1,138 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateDatabase : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "LineItems"); - - migrationBuilder.AddColumn( - name: "DeliveryMethod", - table: "Orders", - type: "int", - nullable: false, - defaultValue: 0 - ); - - migrationBuilder.AddColumn( - name: "Color", - table: "OrderItems", - type: "nvarchar(max)", - nullable: false, - defaultValue: "" - ); - - migrationBuilder.AddColumn( - name: "Size", - table: "OrderItems", - type: "nvarchar(max)", - nullable: false, - defaultValue: "" - ); - - migrationBuilder.CreateTable( - name: "CartItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CartId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Color = table.Column(type: "nvarchar(max)", nullable: false), - Size = table.Column(type: "nvarchar(max)", nullable: false), - Quantity = table.Column(type: "int", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_CartItems", x => new { x.Id, x.CartId }); - table.ForeignKey( - name: "FK_CartItems_Carts_CartId", - column: x => x.CartId, - principalTable: "Carts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_CartItems_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_CartId_ProductId", - table: "CartItems", - columns: new[] { "CartId", "ProductId" }, - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_ProductId", - table: "CartItems", - column: "ProductId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "CartItems"); - - migrationBuilder.DropColumn(name: "DeliveryMethod", table: "Orders"); - - migrationBuilder.DropColumn(name: "Color", table: "OrderItems"); - - migrationBuilder.DropColumn(name: "Size", table: "OrderItems"); - - migrationBuilder.CreateTable( - name: "LineItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CartId = table.Column(type: "uniqueidentifier", nullable: false), - ProductId = table.Column(type: "uniqueidentifier", nullable: false), - Quantity = table.Column(type: "int", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_LineItems", x => new { x.Id, x.CartId }); - table.ForeignKey( - name: "FK_LineItems_Carts_CartId", - column: x => x.CartId, - principalTable: "Carts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "FK_LineItems_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_CartId_ProductId", - table: "LineItems", - columns: new[] { "CartId", "ProductId" }, - unique: true - ); - - migrationBuilder.CreateIndex( - name: "IX_LineItems_ProductId", - table: "LineItems", - column: "ProductId" - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs deleted file mode 100644 index 02fea69..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.Designer.cs +++ /dev/null @@ -1,794 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241213084430_UpdateCartItemsTable")] - partial class UpdateCartItemsTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("DeliveryMethod") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("Colors") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("Favourites") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ShortDescription") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.CartItem", "CartItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("CartItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("CartItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs b/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs deleted file mode 100644 index e85f58b..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241213084430_UpdateCartItemsTable.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateCartItemsTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex(name: "IX_CartItems_CartId_ProductId", table: "CartItems"); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_CartId", - table: "CartItems", - column: "CartId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex(name: "IX_CartItems_CartId", table: "CartItems"); - - migrationBuilder.CreateIndex( - name: "IX_CartItems_CartId_ProductId", - table: "CartItems", - columns: new[] { "CartId", "ProductId" }, - unique: true - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs deleted file mode 100644 index a19ad3e..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.Designer.cs +++ /dev/null @@ -1,836 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Shopizy.Infrastructure.Common.Persistence; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20241219151944_AddPermissionsTable")] - partial class AddPermissionsTable - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Carts", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("Categories", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CancellationReason") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("DeliveryMethod") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("PromoCode") - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Orders", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b.Property("PaymentMethod") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PaymentMethodId") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("PaymentStatus") - .HasColumnType("int"); - - b.Property("TransactionId") - .HasMaxLength(260) - .HasColumnType("nvarchar(260)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("UserId"); - - b.ToTable("Payments", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Permissions.Permission", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Permissions", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.HasIndex("UserId"); - - b.ToTable("ProductReviews", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Barcode") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Brand") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("Colors") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("Favourites") - .HasColumnType("int"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("SKU") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ShortDescription") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("StockQuantity") - .HasColumnType("int"); - - b.Property("Tags") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Products", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.PromoCodes.PromoCode", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("IsActive") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("IsPerchantage") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(true); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("NumOfTimeUsed") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValue(0); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.ToTable("PromoCodes", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedOn") - .HasColumnType("smalldatetime"); - - b.Property("CustomerId") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedOn") - .HasColumnType("smalldatetime"); - - b.Property("Password") - .HasColumnType("nvarchar(max)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("nvarchar(15)"); - - b.Property("ProfileImageUrl") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("Phone"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("Shopizy.Domain.Carts.Cart", b => - { - b.OwnsMany("Shopizy.Domain.Carts.Entities.CartItem", "CartItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("CartId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "CartId"); - - b1.HasIndex("CartId"); - - b1.HasIndex("ProductId"); - - b1.ToTable("CartItems", (string)null); - - b1.WithOwner() - .HasForeignKey("CartId"); - - b1.HasOne("Shopizy.Domain.Products.Product", "Product") - .WithMany() - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.Navigation("Product"); - }); - - b.Navigation("CartItems"); - }); - - modelBuilder.Entity("Shopizy.Domain.Orders.Order", b => - { - b.HasOne("Shopizy.Domain.Users.User", null) - .WithMany("Orders") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Shopizy.Domain.Orders.Entities.OrderItem", "OrderItems", b1 => - { - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Color") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Discount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("PictureUrl") - .HasColumnType("nvarchar(max)"); - - b1.Property("Quantity") - .HasColumnType("int"); - - b1.Property("Size") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id", "OrderId"); - - b1.HasIndex("OrderId"); - - b1.ToTable("OrderItems", (string)null); - - b1.WithOwner() - .HasForeignKey("OrderId"); - - b1.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b2 => - { - b2.Property("OrderItemId") - .HasColumnType("uniqueidentifier"); - - b2.Property("OrderItemOrderId") - .HasColumnType("uniqueidentifier"); - - b2.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b2.Property("Currency") - .HasColumnType("int"); - - b2.HasKey("OrderItemId", "OrderItemOrderId"); - - b2.ToTable("OrderItems"); - - b2.WithOwner() - .HasForeignKey("OrderItemId", "OrderItemOrderId"); - }); - - b1.Navigation("UnitPrice") - .IsRequired(); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "DeliveryCharge", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "ShippingAddress", b1 => - { - b1.Property("OrderId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("OrderId"); - - b1.ToTable("Orders"); - - b1.WithOwner() - .HasForeignKey("OrderId"); - }); - - b.Navigation("DeliveryCharge") - .IsRequired(); - - b.Navigation("OrderItems"); - - b.Navigation("ShippingAddress") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Payments.Payment", b => - { - b.HasOne("Shopizy.Domain.Orders.Order", "Order") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "BillingAddress", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "Total", b1 => - { - b1.Property("PaymentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("PaymentId"); - - b1.ToTable("Payments"); - - b1.WithOwner() - .HasForeignKey("PaymentId"); - }); - - b.Navigation("BillingAddress") - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Total") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.ProductReviews.ProductReview", b => - { - b.HasOne("Shopizy.Domain.Products.Product", null) - .WithMany("ProductReviews") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Shopizy.Domain.Users.User", "User") - .WithMany("ProductReviews") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Rating", "Rating", b1 => - { - b1.Property("ProductReviewId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductReviewId"); - - b1.ToTable("ProductReviews"); - - b1.WithOwner() - .HasForeignKey("ProductReviewId"); - }); - - b.Navigation("Rating") - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.HasOne("Shopizy.Domain.Categories.Category", null) - .WithMany("Products") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.AverageRating", "AverageRating", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("NumRatings") - .HasColumnType("int"); - - b1.Property("Value") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsMany("Shopizy.Domain.Products.Entities.ProductImage", "ProductImages", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Id") - .HasColumnType("uniqueidentifier"); - - b1.Property("ImageUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("PublicId") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("Seq") - .HasColumnType("int"); - - b1.HasKey("ProductId", "Id"); - - b1.ToTable("ProductImages", (string)null); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Shopizy.Domain.Common.ValueObjects.Price", "UnitPrice", b1 => - { - b1.Property("ProductId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b1.Property("Currency") - .HasColumnType("int"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.Navigation("AverageRating") - .IsRequired(); - - b.Navigation("ProductImages"); - - b.Navigation("UnitPrice") - .IsRequired(); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.OwnsMany("Shopizy.Domain.Permissions.ValueObjects.PermissionId", "PermissionIds", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Value") - .HasColumnType("uniqueidentifier") - .HasColumnName("PermissionId"); - - b1.HasKey("Id"); - - b1.HasIndex("UserId"); - - b1.ToTable("UserPermissionIds", (string)null); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.OwnsOne("Shopizy.Domain.Orders.ValueObjects.Address", "Address", b1 => - { - b1.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b1.Property("City") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Country") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("State") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b1.Property("Street") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("ZipCode") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b1.HasKey("UserId"); - - b1.ToTable("Users"); - - b1.WithOwner() - .HasForeignKey("UserId"); - }); - - b.Navigation("Address"); - - b.Navigation("PermissionIds"); - }); - - modelBuilder.Entity("Shopizy.Domain.Categories.Category", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("Shopizy.Domain.Products.Product", b => - { - b.Navigation("ProductReviews"); - }); - - modelBuilder.Entity("Shopizy.Domain.Users.User", b => - { - b.Navigation("Orders"); - - b.Navigation("ProductReviews"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs b/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs deleted file mode 100644 index b0b313c..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241219151944_AddPermissionsTable.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class AddPermissionsTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Permissions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column( - type: "nvarchar(50)", - maxLength: 50, - nullable: false - ), - }, - constraints: table => - { - table.PrimaryKey("PK_Permissions", x => x.Id); - } - ); - - migrationBuilder.CreateTable( - name: "UserPermissionIds", - columns: table => new - { - Id = table - .Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PermissionId = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_UserPermissionIds", x => x.Id); - table.ForeignKey( - name: "FK_UserPermissionIds_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex( - name: "IX_UserPermissionIds_UserId", - table: "UserPermissionIds", - column: "UserId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "Permissions"); - - migrationBuilder.DropTable(name: "UserPermissionIds"); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs b/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs deleted file mode 100644 index 102e761..0000000 --- a/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace shopizy.Infrastructure.Migrations -{ - /// - public partial class UpdateUsersTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey(name: "FK_Orders_Users_UserId", table: "Orders"); - - migrationBuilder.DropIndex(name: "IX_Users_Phone", table: "Users"); - - migrationBuilder.DropIndex(name: "IX_Orders_UserId", table: "Orders"); - - migrationBuilder.AlterColumn( - name: "Phone", - table: "Users", - type: "nvarchar(15)", - maxLength: 15, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(15)", - oldMaxLength: 15 - ); - - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "nvarchar(50)", - maxLength: 50, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true - ); - - migrationBuilder.CreateTable( - name: "OrderIds", - columns: table => new - { - Id = table - .Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - OrderId = table.Column(type: "uniqueidentifier", nullable: false), - UseId = table.Column(type: "uniqueidentifier", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_OrderIds", x => x.Id); - table.ForeignKey( - name: "FK_OrderIds_Users_UseId", - column: x => x.UseId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateTable( - name: "ProductReviewIds", - columns: table => new - { - Id = table - .Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ProductReviewId = table.Column(type: "uniqueidentifier", nullable: false), - UseId = table.Column(type: "uniqueidentifier", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_ProductReviewIds", x => x.Id); - table.ForeignKey( - name: "FK_ProductReviewIds_Users_UseId", - column: x => x.UseId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - ); - - migrationBuilder.CreateIndex(name: "IX_Users_Email", table: "Users", column: "Email"); - - migrationBuilder.CreateIndex( - name: "IX_OrderIds_UseId", - table: "OrderIds", - column: "UseId" - ); - - migrationBuilder.CreateIndex( - name: "IX_ProductReviewIds_UseId", - table: "ProductReviewIds", - column: "UseId" - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable(name: "OrderIds"); - - migrationBuilder.DropTable(name: "ProductReviewIds"); - - migrationBuilder.DropIndex(name: "IX_Users_Email", table: "Users"); - - migrationBuilder.AlterColumn( - name: "Phone", - table: "Users", - type: "nvarchar(15)", - maxLength: 15, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(15)", - oldMaxLength: 15, - oldNullable: true - ); - - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(50)", - oldMaxLength: 50 - ); - - migrationBuilder.CreateIndex(name: "IX_Users_Phone", table: "Users", column: "Phone"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_UserId", - table: "Orders", - column: "UserId" - ); - - migrationBuilder.AddForeignKey( - name: "FK_Orders_Users_UserId", - table: "Orders", - column: "UserId", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade - ); - } - } -} diff --git a/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.Designer.cs b/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.Designer.cs similarity index 99% rename from src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.Designer.cs rename to src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.Designer.cs index 63ae69c..582d33d 100644 --- a/src/Shopizy.Infrastructure/Migrations/20241222122248_UpdateUsersTable.Designer.cs +++ b/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.Designer.cs @@ -9,18 +9,18 @@ #nullable disable -namespace shopizy.Infrastructure.Migrations +namespace Shopizy.Infrastructure.Migrations { [DbContext(typeof(AppDbContext))] - [Migration("20241222122248_UpdateUsersTable")] - partial class UpdateUsersTable + [Migration("20250123152917_InitialDBChanges")] + partial class InitialDBChanges { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs b/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs new file mode 100644 index 0000000..cf69b69 --- /dev/null +++ b/src/Shopizy.Infrastructure/Migrations/20250123152917_InitialDBChanges.cs @@ -0,0 +1,716 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Shopizy.Infrastructure.Migrations +{ + /// + public partial class InitialDBChanges : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Carts", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Carts", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Categories", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Categories", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + DeliveryMethod = table.Column(type: "int", nullable: false), + DeliveryCharge_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + DeliveryCharge_Currency = table.Column(type: "int", nullable: false), + OrderStatus = table.Column(type: "int", nullable: false), + CancellationReason = table.Column( + type: "nvarchar(200)", + maxLength: 200, + nullable: true + ), + PromoCode = table.Column( + type: "nvarchar(15)", + maxLength: 15, + nullable: true + ), + ShippingAddress_Street = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + ShippingAddress_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + ShippingAddress_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + ShippingAddress_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + ShippingAddress_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: false + ), + PaymentStatus = table.Column(type: "int", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Permissions", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + }, + constraints: table => + { + table.PrimaryKey("PK_Permissions", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "PromoCodes", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Code = table.Column( + type: "nvarchar(15)", + maxLength: 15, + nullable: false + ), + Description = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: true + ), + Discount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + IsPerchantage = table.Column( + type: "bit", + nullable: false, + defaultValue: true + ), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + NumOfTimeUsed = table.Column( + type: "int", + nullable: false, + defaultValue: 0 + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_PromoCodes", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + FirstName = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + LastName = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + Email = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + ProfileImageUrl = table.Column(type: "nvarchar(max)", nullable: true), + Phone = table.Column( + type: "nvarchar(15)", + maxLength: 15, + nullable: true + ), + Password = table.Column(type: "nvarchar(max)", nullable: true), + CustomerId = table.Column( + type: "nvarchar(256)", + maxLength: 256, + nullable: true + ), + Address_Street = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: true + ), + Address_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: true + ), + Address_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: true + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + } + ); + + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + ShortDescription = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + Description = table.Column( + type: "nvarchar(200)", + maxLength: 200, + nullable: false + ), + CategoryId = table.Column(type: "uniqueidentifier", nullable: false), + SKU = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + StockQuantity = table.Column(type: "int", nullable: false), + UnitPrice_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + UnitPrice_Currency = table.Column(type: "int", nullable: false), + Discount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: true + ), + Brand = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: true + ), + Colors = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: false + ), + Sizes = table.Column( + type: "nvarchar(20)", + maxLength: 20, + nullable: false + ), + Favourites = table.Column(type: "int", nullable: false), + Barcode = table.Column( + type: "nvarchar(50)", + maxLength: 50, + nullable: true + ), + Tags = table.Column( + type: "nvarchar(200)", + maxLength: 200, + nullable: true + ), + AverageRating_Value = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + AverageRating_NumRatings = table.Column(type: "int", nullable: false), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + table.ForeignKey( + name: "FK_Products_Categories_CategoryId", + column: x => x.CategoryId, + principalTable: "Categories", + principalColumn: "Id" + ); + } + ); + + migrationBuilder.CreateTable( + name: "OrderItems", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + OrderId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + PictureUrl = table.Column(type: "nvarchar(max)", nullable: true), + UnitPrice_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + UnitPrice_Currency = table.Column(type: "int", nullable: false), + Color = table.Column(type: "nvarchar(max)", nullable: false), + Size = table.Column(type: "nvarchar(max)", nullable: false), + Quantity = table.Column(type: "int", nullable: false), + Discount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + }, + constraints: table => + { + table.PrimaryKey("PK_OrderItems", x => new { x.Id, x.OrderId }); + table.ForeignKey( + name: "FK_OrderItems_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "OrderIds", + columns: table => new + { + Id = table + .Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OrderId = table.Column(type: "uniqueidentifier", nullable: false), + UseId = table.Column(type: "uniqueidentifier", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_OrderIds", x => x.Id); + table.ForeignKey( + name: "FK_OrderIds_Users_UseId", + column: x => x.UseId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "Payments", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + OrderId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + PaymentMethod = table.Column( + type: "nvarchar(20)", + maxLength: 20, + nullable: false + ), + PaymentMethodId = table.Column( + type: "nvarchar(260)", + maxLength: 260, + nullable: false + ), + TransactionId = table.Column( + type: "nvarchar(260)", + maxLength: 260, + nullable: true + ), + PaymentStatus = table.Column(type: "int", nullable: false), + Total_Amount = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + Total_Currency = table.Column(type: "int", nullable: false), + BillingAddress_Street = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + BillingAddress_City = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + BillingAddress_State = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + BillingAddress_Country = table.Column( + type: "nvarchar(30)", + maxLength: 30, + nullable: false + ), + BillingAddress_ZipCode = table.Column( + type: "nvarchar(10)", + maxLength: 10, + nullable: false + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_Payments", x => x.Id); + table.ForeignKey( + name: "FK_Payments_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id" + ); + table.ForeignKey( + name: "FK_Payments_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id" + ); + } + ); + + migrationBuilder.CreateTable( + name: "ProductReviewIds", + columns: table => new + { + Id = table + .Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductReviewId = table.Column(type: "uniqueidentifier", nullable: false), + UseId = table.Column(type: "uniqueidentifier", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_ProductReviewIds", x => x.Id); + table.ForeignKey( + name: "FK_ProductReviewIds_Users_UseId", + column: x => x.UseId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "UserPermissionIds", + columns: table => new + { + Id = table + .Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PermissionId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_UserPermissionIds", x => x.Id); + table.ForeignKey( + name: "FK_UserPermissionIds_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "CartItems", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CartId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + Color = table.Column(type: "nvarchar(max)", nullable: false), + Size = table.Column(type: "nvarchar(max)", nullable: false), + Quantity = table.Column(type: "int", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_CartItems", x => new { x.Id, x.CartId }); + table.ForeignKey( + name: "FK_CartItems_Carts_CartId", + column: x => x.CartId, + principalTable: "Carts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + table.ForeignKey( + name: "FK_CartItems_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "ProductImages", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + ImageUrl = table.Column(type: "nvarchar(max)", nullable: false), + Seq = table.Column(type: "int", nullable: false), + PublicId = table.Column( + type: "nvarchar(100)", + maxLength: 100, + nullable: false + ), + }, + constraints: table => + { + table.PrimaryKey("PK_ProductImages", x => new { x.ProductId, x.Id }); + table.ForeignKey( + name: "FK_ProductImages_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateTable( + name: "ProductReviews", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + Rating_Value = table.Column( + type: "decimal(18,2)", + precision: 18, + scale: 2, + nullable: false + ), + Comment = table.Column( + type: "nvarchar(1000)", + maxLength: 1000, + nullable: true + ), + CreatedOn = table.Column(type: "smalldatetime", nullable: false), + ModifiedOn = table.Column(type: "smalldatetime", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_ProductReviews", x => x.Id); + table.ForeignKey( + name: "FK_ProductReviews_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + table.ForeignKey( + name: "FK_ProductReviews_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade + ); + } + ); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_CartId", + table: "CartItems", + column: "CartId" + ); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_ProductId", + table: "CartItems", + column: "ProductId" + ); + + migrationBuilder.CreateIndex(name: "IX_Carts_UserId", table: "Carts", column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderIds_UseId", + table: "OrderIds", + column: "UseId" + ); + + migrationBuilder.CreateIndex( + name: "IX_OrderItems_OrderId", + table: "OrderItems", + column: "OrderId" + ); + + migrationBuilder.CreateIndex( + name: "IX_Payments_OrderId", + table: "Payments", + column: "OrderId" + ); + + migrationBuilder.CreateIndex( + name: "IX_Payments_UserId", + table: "Payments", + column: "UserId" + ); + + migrationBuilder.CreateIndex( + name: "IX_ProductReviewIds_UseId", + table: "ProductReviewIds", + column: "UseId" + ); + + migrationBuilder.CreateIndex( + name: "IX_ProductReviews_ProductId", + table: "ProductReviews", + column: "ProductId" + ); + + migrationBuilder.CreateIndex( + name: "IX_ProductReviews_UserId", + table: "ProductReviews", + column: "UserId" + ); + + migrationBuilder.CreateIndex( + name: "IX_Products_CategoryId", + table: "Products", + column: "CategoryId" + ); + + migrationBuilder.CreateIndex( + name: "IX_PromoCodes_Code", + table: "PromoCodes", + column: "Code" + ); + + migrationBuilder.CreateIndex( + name: "IX_UserPermissionIds_UserId", + table: "UserPermissionIds", + column: "UserId" + ); + + migrationBuilder.CreateIndex(name: "IX_Users_Email", table: "Users", column: "Email"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable(name: "CartItems"); + + migrationBuilder.DropTable(name: "OrderIds"); + + migrationBuilder.DropTable(name: "OrderItems"); + + migrationBuilder.DropTable(name: "Payments"); + + migrationBuilder.DropTable(name: "Permissions"); + + migrationBuilder.DropTable(name: "ProductImages"); + + migrationBuilder.DropTable(name: "ProductReviewIds"); + + migrationBuilder.DropTable(name: "ProductReviews"); + + migrationBuilder.DropTable(name: "PromoCodes"); + + migrationBuilder.DropTable(name: "UserPermissionIds"); + + migrationBuilder.DropTable(name: "Carts"); + + migrationBuilder.DropTable(name: "Orders"); + + migrationBuilder.DropTable(name: "Products"); + + migrationBuilder.DropTable(name: "Users"); + + migrationBuilder.DropTable(name: "Categories"); + } + } +} diff --git a/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs b/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs index 61c5c52..04cbe33 100644 --- a/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs +++ b/src/Shopizy.Infrastructure/Migrations/AppDbContextModelSnapshot.cs @@ -8,7 +8,7 @@ #nullable disable -namespace shopizy.Infrastructure.Migrations +namespace Shopizy.Infrastructure.Migrations { [DbContext(typeof(AppDbContext))] partial class AppDbContextModelSnapshot : ModelSnapshot @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);