937 lines
42 KiB
C#
937 lines
42 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class UsedStringTableNames : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_PackageItem_ProductPrice_ProductPriceId",
|
|
table: "PackageItem");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ShoppingCartItems_ProductPrice_ProductPriceId",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ShoppingCartItems_ShoppingCart_ShoppingCartId",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Lead");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "OrderRefund");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ProductPrice");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Quote");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ShoppingCartPackage");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Product");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ShoppingCart");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Order");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "Sender",
|
|
table: "Notification",
|
|
newName: "SenderAddress");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "Recipient",
|
|
table: "Notification",
|
|
newName: "RecipientName");
|
|
|
|
migrationBuilder.AlterColumn<DateTime>(
|
|
name: "UpdatedAt",
|
|
table: "ShoppingCartItems",
|
|
type: "timestamp with time zone",
|
|
nullable: true,
|
|
oldClrType: typeof(DateTimeOffset),
|
|
oldType: "timestamp with time zone");
|
|
|
|
migrationBuilder.AlterColumn<int>(
|
|
name: "Quantity",
|
|
table: "ShoppingCartItems",
|
|
type: "integer",
|
|
nullable: false,
|
|
defaultValue: 1,
|
|
oldClrType: typeof(int),
|
|
oldType: "integer");
|
|
|
|
migrationBuilder.AlterColumn<DateTime>(
|
|
name: "CreatedAt",
|
|
table: "ShoppingCartItems",
|
|
type: "timestamp with time zone",
|
|
nullable: false,
|
|
defaultValueSql: "now()",
|
|
oldClrType: typeof(DateTimeOffset),
|
|
oldType: "timestamp with time zone");
|
|
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "ProductPriceId1",
|
|
table: "ShoppingCartItems",
|
|
type: "uuid",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "ShoppingCartId1",
|
|
table: "ShoppingCartItems",
|
|
type: "uuid",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Name",
|
|
table: "Customer",
|
|
type: "text",
|
|
nullable: true,
|
|
oldClrType: typeof(string),
|
|
oldType: "text");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "LastName",
|
|
table: "Customer",
|
|
type: "text",
|
|
nullable: true,
|
|
oldClrType: typeof(string),
|
|
oldType: "text");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Email",
|
|
table: "Customer",
|
|
type: "text",
|
|
nullable: true,
|
|
oldClrType: typeof(string),
|
|
oldType: "text");
|
|
|
|
migrationBuilder.AlterColumn<DateTime>(
|
|
name: "CreatedAt",
|
|
table: "Customer",
|
|
type: "timestamp with time zone",
|
|
nullable: false,
|
|
oldClrType: typeof(DateTimeOffset),
|
|
oldType: "timestamp with time zone",
|
|
oldDefaultValueSql: "now()");
|
|
|
|
migrationBuilder.AlterColumn<bool>(
|
|
name: "Active",
|
|
table: "Customer",
|
|
type: "boolean",
|
|
nullable: false,
|
|
oldClrType: typeof(bool),
|
|
oldType: "boolean",
|
|
oldDefaultValue: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Customers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
Company = table.Column<string>(type: "text", nullable: true),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
LastName = table.Column<string>(type: "text", nullable: false),
|
|
Tax = table.Column<string>(type: "text", nullable: true),
|
|
Email = table.Column<string>(type: "text", nullable: false),
|
|
Discord = table.Column<string>(type: "text", nullable: true),
|
|
Slack = table.Column<string>(type: "text", nullable: true),
|
|
LinkedIn = table.Column<string>(type: "text", nullable: true),
|
|
Whatsapp = table.Column<string>(type: "text", nullable: true),
|
|
Website = table.Column<string>(type: "text", nullable: true),
|
|
Phone = table.Column<string>(type: "text", nullable: true),
|
|
Address = table.Column<string>(type: "text", nullable: true),
|
|
City = table.Column<string>(type: "text", nullable: true),
|
|
Region = table.Column<string>(type: "text", nullable: true),
|
|
Country = table.Column<string>(type: "text", nullable: true),
|
|
PostalCode = table.Column<string>(type: "text", nullable: true),
|
|
Active = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Customers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Products",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Summary = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false),
|
|
Description = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
|
|
ImageUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
|
|
Thumbnails = table.Column<string>(type: "jsonb", nullable: true),
|
|
Active = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Products", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Leads",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CustomerId1 = table.Column<Guid>(type: "uuid", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
Source = table.Column<string>(type: "text", nullable: true),
|
|
ClickId = table.Column<string>(type: "text", nullable: true),
|
|
WebClickId = table.Column<string>(type: "text", nullable: true),
|
|
AppClickId = table.Column<string>(type: "text", nullable: true),
|
|
CampaignId = table.Column<long>(type: "bigint", nullable: true),
|
|
AdGroupId = table.Column<long>(type: "bigint", nullable: true),
|
|
AdName = table.Column<long>(type: "bigint", nullable: true),
|
|
TargetId = table.Column<long>(type: "bigint", nullable: true),
|
|
FeedItemId = table.Column<long>(type: "bigint", nullable: true),
|
|
ClickLocation = table.Column<string>(type: "text", nullable: true),
|
|
AttributionHash = table.Column<string>(type: "text", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Leads", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Leads_Customer_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customer",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Leads_Customers_CustomerId1",
|
|
column: x => x.CustomerId1,
|
|
principalTable: "Customers",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Orders",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
Requirements = table.Column<string>(type: "jsonb", nullable: true),
|
|
Notes = table.Column<string>(type: "jsonb", nullable: true),
|
|
Terms = table.Column<string>(type: "jsonb", nullable: true),
|
|
InvoiceUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true)
|
|
},
|
|
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.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ProductPrices",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Price = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
Discount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
Active = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ProductPrices", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ProductPrices_Products_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Products",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "OrderRefunds",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
OrderId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Reason = table.Column<string>(type: "text", nullable: false),
|
|
Amount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_OrderRefunds", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_OrderRefunds_Orders_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ShoppingCarts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
OrderId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ShoppingCarts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCarts_Customers_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCarts_Orders_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Quotes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
ExpiredAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
OrderId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
ShoppingCartId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
InvoiceUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
|
|
Reason = table.Column<string>(type: "text", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Quotes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Quotes_Customers_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Quotes_Orders_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_Quotes_ShoppingCarts_ShoppingCartId",
|
|
column: x => x.ShoppingCartId,
|
|
principalTable: "ShoppingCarts",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ShoppingCartPackages",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
ShoppingCartId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PackageId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ShoppingCartPackages", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCartPackages_Package_PackageId",
|
|
column: x => x.PackageId,
|
|
principalTable: "Package",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCartPackages_ShoppingCarts_ShoppingCartId",
|
|
column: x => x.ShoppingCartId,
|
|
principalTable: "ShoppingCarts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCartItems_ProductPriceId1",
|
|
table: "ShoppingCartItems",
|
|
column: "ProductPriceId1");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCartItems_ShoppingCartId1",
|
|
table: "ShoppingCartItems",
|
|
column: "ShoppingCartId1");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Leads_CustomerId",
|
|
table: "Leads",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Leads_CustomerId1",
|
|
table: "Leads",
|
|
column: "CustomerId1");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OrderRefunds_OrderId",
|
|
table: "OrderRefunds",
|
|
column: "OrderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Orders_CustomerId",
|
|
table: "Orders",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ProductPrices_ProductId",
|
|
table: "ProductPrices",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Quotes_CustomerId",
|
|
table: "Quotes",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Quotes_OrderId",
|
|
table: "Quotes",
|
|
column: "OrderId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Quotes_ShoppingCartId",
|
|
table: "Quotes",
|
|
column: "ShoppingCartId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCartPackages_PackageId",
|
|
table: "ShoppingCartPackages",
|
|
column: "PackageId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCartPackages_ShoppingCartId",
|
|
table: "ShoppingCartPackages",
|
|
column: "ShoppingCartId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCarts_CustomerId",
|
|
table: "ShoppingCarts",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCarts_OrderId",
|
|
table: "ShoppingCarts",
|
|
column: "OrderId",
|
|
unique: true);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_PackageItem_ProductPrices_ProductPriceId",
|
|
table: "PackageItem",
|
|
column: "ProductPriceId",
|
|
principalTable: "ProductPrices",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ShoppingCartItems_ProductPrices_ProductPriceId",
|
|
table: "ShoppingCartItems",
|
|
column: "ProductPriceId",
|
|
principalTable: "ProductPrices",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ShoppingCartItems_ProductPrices_ProductPriceId1",
|
|
table: "ShoppingCartItems",
|
|
column: "ProductPriceId1",
|
|
principalTable: "ProductPrices",
|
|
principalColumn: "Id");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ShoppingCartItems_ShoppingCarts_ShoppingCartId",
|
|
table: "ShoppingCartItems",
|
|
column: "ShoppingCartId",
|
|
principalTable: "ShoppingCarts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ShoppingCartItems_ShoppingCarts_ShoppingCartId1",
|
|
table: "ShoppingCartItems",
|
|
column: "ShoppingCartId1",
|
|
principalTable: "ShoppingCarts",
|
|
principalColumn: "Id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_PackageItem_ProductPrices_ProductPriceId",
|
|
table: "PackageItem");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ShoppingCartItems_ProductPrices_ProductPriceId",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ShoppingCartItems_ProductPrices_ProductPriceId1",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ShoppingCartItems_ShoppingCarts_ShoppingCartId",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ShoppingCartItems_ShoppingCarts_ShoppingCartId1",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Leads");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "OrderRefunds");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ProductPrices");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Quotes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ShoppingCartPackages");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Products");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ShoppingCarts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Orders");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Customers");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_ShoppingCartItems_ProductPriceId1",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_ShoppingCartItems_ShoppingCartId1",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "ProductPriceId1",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "ShoppingCartId1",
|
|
table: "ShoppingCartItems");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "SenderAddress",
|
|
table: "Notification",
|
|
newName: "Sender");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "RecipientName",
|
|
table: "Notification",
|
|
newName: "Recipient");
|
|
|
|
migrationBuilder.AlterColumn<DateTimeOffset>(
|
|
name: "UpdatedAt",
|
|
table: "ShoppingCartItems",
|
|
type: "timestamp with time zone",
|
|
nullable: false,
|
|
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
|
oldClrType: typeof(DateTime),
|
|
oldType: "timestamp with time zone",
|
|
oldNullable: true);
|
|
|
|
migrationBuilder.AlterColumn<int>(
|
|
name: "Quantity",
|
|
table: "ShoppingCartItems",
|
|
type: "integer",
|
|
nullable: false,
|
|
oldClrType: typeof(int),
|
|
oldType: "integer",
|
|
oldDefaultValue: 1);
|
|
|
|
migrationBuilder.AlterColumn<DateTimeOffset>(
|
|
name: "CreatedAt",
|
|
table: "ShoppingCartItems",
|
|
type: "timestamp with time zone",
|
|
nullable: false,
|
|
oldClrType: typeof(DateTime),
|
|
oldType: "timestamp with time zone",
|
|
oldDefaultValueSql: "now()");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Name",
|
|
table: "Customer",
|
|
type: "text",
|
|
nullable: false,
|
|
defaultValue: "",
|
|
oldClrType: typeof(string),
|
|
oldType: "text",
|
|
oldNullable: true);
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "LastName",
|
|
table: "Customer",
|
|
type: "text",
|
|
nullable: false,
|
|
defaultValue: "",
|
|
oldClrType: typeof(string),
|
|
oldType: "text",
|
|
oldNullable: true);
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Email",
|
|
table: "Customer",
|
|
type: "text",
|
|
nullable: false,
|
|
defaultValue: "",
|
|
oldClrType: typeof(string),
|
|
oldType: "text",
|
|
oldNullable: true);
|
|
|
|
migrationBuilder.AlterColumn<DateTimeOffset>(
|
|
name: "CreatedAt",
|
|
table: "Customer",
|
|
type: "timestamp with time zone",
|
|
nullable: false,
|
|
defaultValueSql: "now()",
|
|
oldClrType: typeof(DateTime),
|
|
oldType: "timestamp with time zone");
|
|
|
|
migrationBuilder.AlterColumn<bool>(
|
|
name: "Active",
|
|
table: "Customer",
|
|
type: "boolean",
|
|
nullable: false,
|
|
defaultValue: true,
|
|
oldClrType: typeof(bool),
|
|
oldType: "boolean");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Lead",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
AdGroupId = table.Column<long>(type: "bigint", nullable: true),
|
|
AdName = table.Column<long>(type: "bigint", nullable: true),
|
|
AppClickId = table.Column<string>(type: "text", nullable: true),
|
|
AttributionHash = table.Column<string>(type: "text", nullable: false),
|
|
CampaignId = table.Column<long>(type: "bigint", nullable: true),
|
|
ClickId = table.Column<string>(type: "text", nullable: true),
|
|
ClickLocation = table.Column<string>(type: "text", nullable: true),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
FeedItemId = table.Column<long>(type: "bigint", nullable: true),
|
|
Source = table.Column<string>(type: "text", nullable: true),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
TargetId = table.Column<long>(type: "bigint", nullable: true),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
WebClickId = table.Column<string>(type: "text", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Lead", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Lead_Customer_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customer",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Order",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
InvoiceUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
|
|
Notes = table.Column<string>(type: "jsonb", nullable: true),
|
|
Requirements = table.Column<string>(type: "jsonb", nullable: true),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
Terms = table.Column<string>(type: "jsonb", nullable: true),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Order", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Order_Customer_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customer",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Product",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Active = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true),
|
|
Description = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
|
|
ImageUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Summary = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false),
|
|
Thumbnails = table.Column<string>(type: "jsonb", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Product", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "OrderRefund",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
OrderId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Amount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
Reason = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_OrderRefund", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_OrderRefund_Order_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Order",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ShoppingCart",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
OrderId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ShoppingCart", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCart_Customer_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customer",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCart_Order_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Order",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ProductPrice",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Active = table.Column<bool>(type: "boolean", nullable: false),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
Discount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
Price = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ProductPrice", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ProductPrice_Product_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Product",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Quote",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
OrderId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
ShoppingCartId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
ExpiredAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
InvoiceUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
|
|
Reason = table.Column<string>(type: "text", nullable: true),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Quote", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Quote_Customer_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customer",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Quote_Order_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Order",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_Quote_ShoppingCart_ShoppingCartId",
|
|
column: x => x.ShoppingCartId,
|
|
principalTable: "ShoppingCart",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ShoppingCartPackage",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PackageId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ShoppingCartId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ShoppingCartPackage", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCartPackage_Package_PackageId",
|
|
column: x => x.PackageId,
|
|
principalTable: "Package",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCartPackage_ShoppingCart_ShoppingCartId",
|
|
column: x => x.ShoppingCartId,
|
|
principalTable: "ShoppingCart",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Lead_CustomerId",
|
|
table: "Lead",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Order_CustomerId",
|
|
table: "Order",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OrderRefund_OrderId",
|
|
table: "OrderRefund",
|
|
column: "OrderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ProductPrice_ProductId",
|
|
table: "ProductPrice",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Quote_CustomerId",
|
|
table: "Quote",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Quote_OrderId",
|
|
table: "Quote",
|
|
column: "OrderId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Quote_ShoppingCartId",
|
|
table: "Quote",
|
|
column: "ShoppingCartId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCart_CustomerId",
|
|
table: "ShoppingCart",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCart_OrderId",
|
|
table: "ShoppingCart",
|
|
column: "OrderId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCartPackage_PackageId",
|
|
table: "ShoppingCartPackage",
|
|
column: "PackageId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCartPackage_ShoppingCartId",
|
|
table: "ShoppingCartPackage",
|
|
column: "ShoppingCartId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_PackageItem_ProductPrice_ProductPriceId",
|
|
table: "PackageItem",
|
|
column: "ProductPriceId",
|
|
principalTable: "ProductPrice",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ShoppingCartItems_ProductPrice_ProductPriceId",
|
|
table: "ShoppingCartItems",
|
|
column: "ProductPriceId",
|
|
principalTable: "ProductPrice",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ShoppingCartItems_ShoppingCart_ShoppingCartId",
|
|
table: "ShoppingCartItems",
|
|
column: "ShoppingCartId",
|
|
principalTable: "ShoppingCart",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
}
|
|
}
|
|
}
|