using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace NetinaShop.Repository.Migrations { /// public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "public"); migrationBuilder.CreateTable( name: "BlogCategories", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_BlogCategories", x => x.Id); }); migrationBuilder.CreateTable( name: "Brands", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), HasSpecialPage = table.Column(type: "boolean", nullable: false), PageUrl = table.Column(type: "text", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Brands", x => x.Id); }); migrationBuilder.CreateTable( name: "ProductCategories", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), IsMain = table.Column(type: "boolean", nullable: false), ParentId = table.Column(type: "uuid", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ProductCategories", x => x.Id); table.ForeignKey( name: "FK_ProductCategories_ProductCategories_ParentId", column: x => x.ParentId, principalSchema: "public", principalTable: "ProductCategories", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Roles", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Description = table.Column(type: "text", nullable: false), EnglishName = table.Column(type: "text", nullable: false), PersianName = table.Column(type: "text", nullable: false), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), ConcurrencyStamp = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Roles", x => x.Id); }); migrationBuilder.CreateTable( name: "Shippings", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "text", nullable: false), WarehouseName = table.Column(type: "text", nullable: false), IsExpressShipping = table.Column(type: "boolean", nullable: false), IsShipBySeller = table.Column(type: "boolean", nullable: false), IsOriginalWarehouse = table.Column(type: "boolean", nullable: false), DeliveryCost = table.Column(type: "double precision", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Shippings", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), FirstName = table.Column(type: "text", nullable: false), LastName = table.Column(type: "text", nullable: false), NationalId = table.Column(type: "text", nullable: false), BirthDate = table.Column(type: "timestamp without time zone", nullable: false), Gender = table.Column(type: "integer", nullable: false), SignUpStatus = table.Column(type: "integer", nullable: false), UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), EmailConfirmed = table.Column(type: "boolean", nullable: false), PasswordHash = table.Column(type: "text", nullable: true), SecurityStamp = table.Column(type: "text", nullable: true), ConcurrencyStamp = table.Column(type: "text", nullable: true), PhoneNumber = table.Column(type: "text", nullable: true), PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), TwoFactorEnabled = table.Column(type: "boolean", nullable: false), LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), LockoutEnabled = table.Column(type: "boolean", nullable: false), AccessFailedCount = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Blogs", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "text", nullable: false), Content = table.Column(type: "text", nullable: false), Tags = table.Column(type: "text", nullable: false), ReadingTime = table.Column(type: "integer", nullable: false), Summery = table.Column(type: "text", nullable: false), IsSuggested = table.Column(type: "boolean", nullable: false), CategoryId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Blogs", x => x.Id); table.ForeignKey( name: "FK_Blogs_BlogCategories_CategoryId", column: x => x.CategoryId, principalSchema: "public", principalTable: "BlogCategories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Products", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), PersianName = table.Column(type: "text", nullable: false), EnglishName = table.Column(type: "text", nullable: false), Summery = table.Column(type: "text", nullable: false), ExpertCheck = table.Column(type: "text", nullable: false), Tags = table.Column(type: "text", nullable: false), Warranty = table.Column(type: "text", nullable: false), Cost = table.Column(type: "double precision", nullable: false), IsEnable = table.Column(type: "boolean", nullable: false), BeDisplayed = table.Column(type: "boolean", nullable: false), PackingCost = table.Column(type: "double precision", nullable: false), Rate = table.Column(type: "real", nullable: false), ReviewCount = table.Column(type: "integer", nullable: false), Viewed = table.Column(type: "integer", nullable: false), HasExpressDelivery = table.Column(type: "boolean", nullable: false), MaxOrderCount = table.Column(type: "integer", nullable: false), BrandId = table.Column(type: "uuid", nullable: false), CategoryId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Products", x => x.Id); table.ForeignKey( name: "FK_Products_Brands_BrandId", column: x => x.BrandId, principalSchema: "public", principalTable: "Brands", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Products_ProductCategories_CategoryId", column: x => x.CategoryId, principalSchema: "public", principalTable: "ProductCategories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "RoleClaims", schema: "public", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoleId = table.Column(type: "uuid", nullable: false), ClaimType = table.Column(type: "text", nullable: true), ClaimValue = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_RoleClaims", x => x.Id); table.ForeignKey( name: "FK_RoleClaims_Roles_RoleId", column: x => x.RoleId, principalSchema: "public", principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Claims", schema: "public", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column(type: "uuid", nullable: false), ClaimType = table.Column(type: "text", nullable: true), ClaimValue = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Claims", x => x.Id); table.ForeignKey( name: "FK_Claims_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Logins", schema: "public", columns: table => new { LoginProvider = table.Column(type: "text", nullable: false), ProviderKey = table.Column(type: "text", nullable: false), ProviderDisplayName = table.Column(type: "text", nullable: true), UserId = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Logins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_Logins_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Tokens", schema: "public", columns: table => new { UserId = table.Column(type: "uuid", nullable: false), LoginProvider = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false), Value = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Tokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_Tokens_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "UserAddresses", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Address = table.Column(type: "text", nullable: false), PostalCode = table.Column(type: "text", nullable: false), ReceiverFullName = table.Column(type: "text", nullable: false), ReceiverPhoneNumber = table.Column(type: "text", nullable: false), LocationLat = table.Column(type: "real", nullable: false), LocationLong = table.Column(type: "real", nullable: false), UserId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_UserAddresses", x => x.Id); table.ForeignKey( name: "FK_UserAddresses_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "UserRoles", schema: "public", columns: table => new { UserId = table.Column(type: "uuid", nullable: false), RoleId = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_UserRoles_Roles_RoleId", column: x => x.RoleId, principalSchema: "public", principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_UserRoles_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Discounts", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Code = table.Column(type: "text", nullable: false), DiscountPercent = table.Column(type: "integer", nullable: false), DiscountAmount = table.Column(type: "bigint", nullable: false), HasCode = table.Column(type: "boolean", nullable: false), AmountType = table.Column(type: "integer", nullable: false), Type = table.Column(type: "integer", nullable: false), Count = table.Column(type: "integer", nullable: false), StartDate = table.Column(type: "timestamp without time zone", nullable: false), ExpireDate = table.Column(type: "timestamp without time zone", nullable: false), PriceFloor = table.Column(type: "bigint", nullable: false), HasPriceFloor = table.Column(type: "boolean", nullable: false), PriceCeiling = table.Column(type: "bigint", nullable: false), HasPriceCeiling = table.Column(type: "boolean", nullable: false), IsInfinity = table.Column(type: "boolean", nullable: false), UseCount = table.Column(type: "bigint", nullable: false), IsForInvitation = table.Column(type: "boolean", nullable: false), Discriminator = table.Column(type: "character varying(21)", maxLength: 21, nullable: false), CategoryId = table.Column(type: "uuid", nullable: true), ProductId = table.Column(type: "uuid", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Discounts", x => x.Id); table.ForeignKey( name: "FK_Discounts_ProductCategories_CategoryId", column: x => x.CategoryId, principalSchema: "public", principalTable: "ProductCategories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Discounts_Products_ProductId", column: x => x.ProductId, principalSchema: "public", principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Reviews", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "text", nullable: false), Comment = table.Column(type: "text", nullable: false), Rate = table.Column(type: "real", nullable: false), IsBuyer = table.Column(type: "boolean", nullable: false), IsConfirmed = table.Column(type: "boolean", nullable: false), ProductId = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Reviews", x => x.Id); table.ForeignKey( name: "FK_Reviews_Products_ProductId", column: x => x.ProductId, principalSchema: "public", principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Reviews_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Specifications", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "text", nullable: false), Detail = table.Column(type: "text", nullable: false), Value = table.Column(type: "text", nullable: false), IsFeature = table.Column(type: "boolean", nullable: false), ProductId = table.Column(type: "uuid", nullable: false), ParentId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Specifications", x => x.Id); table.ForeignKey( name: "FK_Specifications_Products_ProductId", column: x => x.ProductId, principalSchema: "public", principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Specifications_Specifications_ParentId", column: x => x.ParentId, principalSchema: "public", principalTable: "Specifications", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "StorageFiles", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), FileLocation = table.Column(type: "text", nullable: false), FileName = table.Column(type: "text", nullable: false), IsHeader = table.Column(type: "boolean", nullable: false), IsPrimary = table.Column(type: "boolean", nullable: false), FileType = table.Column(type: "integer", nullable: false), Discriminator = table.Column(type: "character varying(34)", maxLength: 34, nullable: false), BlogId = table.Column(type: "uuid", nullable: true), BrandId = table.Column(type: "uuid", nullable: true), CategoryId = table.Column(type: "uuid", nullable: true), ProductId = table.Column(type: "uuid", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_StorageFiles", x => x.Id); table.ForeignKey( name: "FK_StorageFiles_Blogs_BlogId", column: x => x.BlogId, principalSchema: "public", principalTable: "Blogs", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_StorageFiles_Brands_BrandId", column: x => x.BrandId, principalSchema: "public", principalTable: "Brands", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_StorageFiles_ProductCategories_CategoryId", column: x => x.CategoryId, principalSchema: "public", principalTable: "ProductCategories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_StorageFiles_Products_ProductId", column: x => x.ProductId, principalSchema: "public", principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "UserFavoriteProducts", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ProductId = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_UserFavoriteProducts", x => x.Id); table.ForeignKey( name: "FK_UserFavoriteProducts_Products_ProductId", column: x => x.ProductId, principalSchema: "public", principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_UserFavoriteProducts_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Orders", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), TotalProductsPrice = table.Column(type: "double precision", nullable: false), PackingPrice = table.Column(type: "double precision", nullable: false), ServicePrice = table.Column(type: "double precision", nullable: false), DeliveryPrice = table.Column(type: "double precision", nullable: false), DiscountPrice = table.Column(type: "double precision", nullable: false), TaxesPrice = table.Column(type: "double precision", nullable: false), TotalPrice = table.Column(type: "double precision", nullable: false), IsPayed = table.Column(type: "boolean", nullable: false), PayedAt = table.Column(type: "timestamp without time zone", nullable: false), PaymentMethod = table.Column(type: "integer", nullable: false), OrderStatus = table.Column(type: "integer", nullable: false), DoneAt = table.Column(type: "timestamp without time zone", nullable: false), OrderAt = table.Column(type: "timestamp without time zone", nullable: false), PreparingMinute = table.Column(type: "integer", nullable: false), DiscountCode = table.Column(type: "text", nullable: false), UserId = table.Column(type: "uuid", nullable: false), DiscountId = table.Column(type: "uuid", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); table.ForeignKey( name: "FK_Orders_Discounts_DiscountId", column: x => x.DiscountId, principalSchema: "public", principalTable: "Discounts", principalColumn: "Id"); table.ForeignKey( name: "FK_Orders_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "OrderDeliveries", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Address = table.Column(type: "text", nullable: false), PostalCode = table.Column(type: "text", nullable: false), ReceiverPhoneNumber = table.Column(type: "text", nullable: false), ReceiverFullName = table.Column(type: "text", nullable: false), DeliveryCost = table.Column(type: "double precision", nullable: false), ShippingId = table.Column(type: "uuid", nullable: false), OrderId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_OrderDeliveries", x => x.Id); table.ForeignKey( name: "FK_OrderDeliveries_Orders_OrderId", column: x => x.OrderId, principalSchema: "public", principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_OrderDeliveries_Shippings_ShippingId", column: x => x.ShippingId, principalSchema: "public", principalTable: "Shippings", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "OrderProducts", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Count = table.Column(type: "integer", nullable: false), ProductFee = table.Column(type: "double precision", nullable: false), ProductCost = table.Column(type: "double precision", nullable: false), PackingFee = table.Column(type: "double precision", nullable: false), PackingCost = table.Column(type: "double precision", nullable: false), OrderProductStatus = table.Column(type: "integer", nullable: false), ProductId = table.Column(type: "uuid", nullable: false), ProductCategoryId = table.Column(type: "uuid", nullable: false), OrderId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_OrderProducts", x => x.Id); table.ForeignKey( name: "FK_OrderProducts_Orders_OrderId", column: x => x.OrderId, principalSchema: "public", principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_OrderProducts_Products_ProductId", column: x => x.ProductId, principalSchema: "public", principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_Blogs_CategoryId", schema: "public", table: "Blogs", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_Claims_UserId", schema: "public", table: "Claims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Discounts_CategoryId", schema: "public", table: "Discounts", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_Discounts_ProductId", schema: "public", table: "Discounts", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Logins_UserId", schema: "public", table: "Logins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_OrderDeliveries_OrderId", schema: "public", table: "OrderDeliveries", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_OrderDeliveries_ShippingId", schema: "public", table: "OrderDeliveries", column: "ShippingId"); migrationBuilder.CreateIndex( name: "IX_OrderProducts_OrderId", schema: "public", table: "OrderProducts", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_OrderProducts_ProductId", schema: "public", table: "OrderProducts", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Orders_DiscountId", schema: "public", table: "Orders", column: "DiscountId"); migrationBuilder.CreateIndex( name: "IX_Orders_UserId", schema: "public", table: "Orders", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_ProductCategories_ParentId", schema: "public", table: "ProductCategories", column: "ParentId"); migrationBuilder.CreateIndex( name: "IX_Products_BrandId", schema: "public", table: "Products", column: "BrandId"); migrationBuilder.CreateIndex( name: "IX_Products_CategoryId", schema: "public", table: "Products", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_Reviews_ProductId", schema: "public", table: "Reviews", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Reviews_UserId", schema: "public", table: "Reviews", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_RoleClaims_RoleId", schema: "public", table: "RoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", schema: "public", table: "Roles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_Specifications_ParentId", schema: "public", table: "Specifications", column: "ParentId"); migrationBuilder.CreateIndex( name: "IX_Specifications_ProductId", schema: "public", table: "Specifications", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_StorageFiles_BlogId", schema: "public", table: "StorageFiles", column: "BlogId"); migrationBuilder.CreateIndex( name: "IX_StorageFiles_BrandId", schema: "public", table: "StorageFiles", column: "BrandId"); migrationBuilder.CreateIndex( name: "IX_StorageFiles_CategoryId", schema: "public", table: "StorageFiles", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_StorageFiles_ProductId", schema: "public", table: "StorageFiles", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_UserAddresses_UserId", schema: "public", table: "UserAddresses", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_UserFavoriteProducts_ProductId", schema: "public", table: "UserFavoriteProducts", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_UserFavoriteProducts_UserId", schema: "public", table: "UserFavoriteProducts", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_UserRoles_RoleId", schema: "public", table: "UserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", schema: "public", table: "Users", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", schema: "public", table: "Users", column: "NormalizedUserName", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Claims", schema: "public"); migrationBuilder.DropTable( name: "Logins", schema: "public"); migrationBuilder.DropTable( name: "OrderDeliveries", schema: "public"); migrationBuilder.DropTable( name: "OrderProducts", schema: "public"); migrationBuilder.DropTable( name: "Reviews", schema: "public"); migrationBuilder.DropTable( name: "RoleClaims", schema: "public"); migrationBuilder.DropTable( name: "Specifications", schema: "public"); migrationBuilder.DropTable( name: "StorageFiles", schema: "public"); migrationBuilder.DropTable( name: "Tokens", schema: "public"); migrationBuilder.DropTable( name: "UserAddresses", schema: "public"); migrationBuilder.DropTable( name: "UserFavoriteProducts", schema: "public"); migrationBuilder.DropTable( name: "UserRoles", schema: "public"); migrationBuilder.DropTable( name: "Shippings", schema: "public"); migrationBuilder.DropTable( name: "Orders", schema: "public"); migrationBuilder.DropTable( name: "Blogs", schema: "public"); migrationBuilder.DropTable( name: "Roles", schema: "public"); migrationBuilder.DropTable( name: "Discounts", schema: "public"); migrationBuilder.DropTable( name: "Users", schema: "public"); migrationBuilder.DropTable( name: "BlogCategories", schema: "public"); migrationBuilder.DropTable( name: "Products", schema: "public"); migrationBuilder.DropTable( name: "Brands", schema: "public"); migrationBuilder.DropTable( name: "ProductCategories", schema: "public"); } } }