using System; using Microsoft.EntityFrameworkCore.Migrations; using NetTopologySuite.Geometries; #nullable disable namespace gehGassi.Persistence.Migrations { /// public partial class VouchersAdded : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "VoucherCampaigns", columns: table => new { Id = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), CustomerId = table.Column(type: "bigint", nullable: false), StartDate = table.Column(type: "datetimeoffset", nullable: true), EndDate = table.Column(type: "datetimeoffset", nullable: true), CampaignType = table.Column(type: "int", nullable: false), Status = table.Column(type: "int", nullable: false), NumberOfVouchers = table.Column(type: "int", nullable: false), VouchersUsed = table.Column(type: "int", nullable: false), MaxUsagePerUser = table.Column(type: "int", nullable: false), Budget = table.Column(type: "decimal(18,2)", nullable: false), BudgetUsed = table.Column(type: "decimal(18,2)", nullable: false), VoucherAmmount = table.Column(type: "decimal(18,2)", nullable: false), WalletFeeId = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), WalletCreditId = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), CartId = table.Column(type: "bigint", nullable: true), CartItemId = table.Column(type: "bigint", nullable: true), OrderId = table.Column(type: "bigint", nullable: true), OrderItemId = table.Column(type: "bigint", nullable: true), PaymentType = table.Column(type: "int", nullable: false), PaymentStatus = table.Column(type: "int", nullable: false), PayedDate = table.Column(type: "datetimeoffset", nullable: true), Image = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), Url = table.Column(type: "nvarchar(2083)", maxLength: 2083, nullable: true), NameLocalized = table.Column(type: "nvarchar(max)", nullable: true), ImageLanguageLocalized = table.Column(type: "nvarchar(max)", nullable: true), UrlLanguageLocalized = table.Column(type: "nvarchar(max)", nullable: true), GeoMode = table.Column(type: "int", nullable: false), Address_AddressLine1 = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), Address_AddressLine2 = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), Address_City = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), Address_Zip = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), Address_State = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), Address_CountryCode = table.Column(type: "nvarchar(2)", maxLength: 2, nullable: true), Location = table.Column(type: "geography", nullable: true), Radius = table.Column(type: "float", nullable: false), Created = table.Column(type: "datetimeoffset", nullable: false), Index = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Version = table.Column(type: "rowversion", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "datetimeoffset", nullable: false), Deleted = table.Column(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(type: "nvarchar(128)", maxLength: 128, nullable: false), VoucherCampaignId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), Code = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), QrCode = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), UsedCount = table.Column(type: "int", nullable: false), VoucherAmmount = table.Column(type: "decimal(18,2)", nullable: false), IsValid = table.Column(type: "bit", nullable: false), Index = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Version = table.Column(type: "rowversion", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "datetimeoffset", nullable: false), Deleted = table.Column(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(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), VoucherId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), AppUserId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), WalkId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), VoucherAmmount = table.Column(type: "decimal(18,2)", nullable: false), VoucherAmmountUsed = table.Column(type: "decimal(18,2)", nullable: false), Created = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "VoucherUsages"); migrationBuilder.DropTable( name: "Vouchers"); migrationBuilder.DropTable( name: "VoucherCampaigns"); } } }