174 lines
9.6 KiB
C#
174 lines
9.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using NetTopologySuite.Geometries;
|
|
|
|
#nullable disable
|
|
|
|
namespace gehGassi.Persistence.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class VouchersAdded : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "VoucherCampaigns",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
CustomerId = table.Column<long>(type: "bigint", nullable: false),
|
|
StartDate = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
|
EndDate = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
|
CampaignType = table.Column<int>(type: "int", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
NumberOfVouchers = table.Column<int>(type: "int", nullable: false),
|
|
VouchersUsed = table.Column<int>(type: "int", nullable: false),
|
|
MaxUsagePerUser = table.Column<int>(type: "int", nullable: false),
|
|
Budget = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
BudgetUsed = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
VoucherAmmount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
WalletFeeId = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
|
|
WalletCreditId = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
|
|
CartId = table.Column<long>(type: "bigint", nullable: true),
|
|
CartItemId = table.Column<long>(type: "bigint", nullable: true),
|
|
OrderId = table.Column<long>(type: "bigint", nullable: true),
|
|
OrderItemId = table.Column<long>(type: "bigint", nullable: true),
|
|
PaymentType = table.Column<int>(type: "int", nullable: false),
|
|
PaymentStatus = table.Column<int>(type: "int", nullable: false),
|
|
PayedDate = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
|
Image = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
|
Url = table.Column<string>(type: "nvarchar(2083)", maxLength: 2083, nullable: true),
|
|
NameLocalized = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
ImageLanguageLocalized = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
UrlLanguageLocalized = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
GeoMode = table.Column<int>(type: "int", nullable: false),
|
|
Address_AddressLine1 = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
|
Address_AddressLine2 = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
|
Address_City = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
|
Address_Zip = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
|
Address_State = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
|
Address_CountryCode = table.Column<string>(type: "nvarchar(2)", maxLength: 2, nullable: true),
|
|
Location = table.Column<Point>(type: "geography", nullable: true),
|
|
Radius = table.Column<double>(type: "float", nullable: false),
|
|
Created = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
|
Index = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Version = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
|
Deleted = table.Column<bool>(type: "bit", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_VoucherCampaigns", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_VoucherCampaigns_Customers_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Vouchers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
VoucherCampaignId = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
Code = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
QrCode = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
UsedCount = table.Column<int>(type: "int", nullable: false),
|
|
VoucherAmmount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
IsValid = table.Column<bool>(type: "bit", nullable: false),
|
|
Index = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Version = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
|
Deleted = table.Column<bool>(type: "bit", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Vouchers", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Vouchers_VoucherCampaigns_VoucherCampaignId",
|
|
column: x => x.VoucherCampaignId,
|
|
principalTable: "VoucherCampaigns",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "VoucherUsages",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
VoucherId = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
AppUserId = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
WalkId = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
|
|
VoucherAmmount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
VoucherAmmountUsed = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
Created = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_VoucherUsages", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_VoucherUsages_AppUsers_AppUserId",
|
|
column: x => x.AppUserId,
|
|
principalTable: "AppUsers",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_VoucherUsages_Vouchers_VoucherId",
|
|
column: x => x.VoucherId,
|
|
principalTable: "Vouchers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_VoucherUsages_Walks_WalkId",
|
|
column: x => x.WalkId,
|
|
principalTable: "Walks",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_VoucherCampaigns_CustomerId",
|
|
table: "VoucherCampaigns",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Vouchers_VoucherCampaignId",
|
|
table: "Vouchers",
|
|
column: "VoucherCampaignId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_VoucherUsages_AppUserId",
|
|
table: "VoucherUsages",
|
|
column: "AppUserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_VoucherUsages_VoucherId",
|
|
table: "VoucherUsages",
|
|
column: "VoucherId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_VoucherUsages_WalkId",
|
|
table: "VoucherUsages",
|
|
column: "WalkId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "VoucherUsages");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Vouchers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "VoucherCampaigns");
|
|
}
|
|
}
|
|
}
|