using System; using Microsoft.EntityFrameworkCore.Migrations; namespace Gateway.POS.Migrations { public partial class addMembership : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "MembershipProfitAccountRechargeId", table: "Transactions", type: "INTEGER", nullable: true); migrationBuilder.AddColumn( name: "MembershipProfitAccountRedeemId", table: "Transactions", type: "INTEGER", nullable: true); migrationBuilder.AddColumn( name: "TransactionSubType", table: "Transactions", type: "INTEGER", nullable: true); migrationBuilder.AddColumn( name: "CardReaderName", table: "Payments", type: "TEXT", nullable: true); migrationBuilder.AddColumn( name: "TargetMembershipAccountId", table: "Payments", type: "INTEGER", nullable: true); migrationBuilder.AddColumn( name: "TargetMembershipSubAccountId", table: "Payments", type: "INTEGER", nullable: true); migrationBuilder.CreateTable( name: "MembershipAccounts", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false), CompanyName = table.Column(type: "TEXT", nullable: true), Age = table.Column(type: "INTEGER", nullable: false), PhoneNumber = table.Column(type: "TEXT", nullable: true), Address = table.Column(type: "TEXT", nullable: true), Email = table.Column(type: "TEXT", nullable: true), Birth = table.Column(type: "TEXT", nullable: true), IsMale = table.Column(type: "INTEGER", nullable: false), Description = table.Column(type: "TEXT", nullable: true), InvoiceTaxNumber = table.Column(type: "TEXT", nullable: true), InvoiceCompanyName = table.Column(type: "TEXT", nullable: true), MembershipLevel = table.Column(type: "INTEGER", nullable: true), AllowSubAccountAccessProfitAccounts = table.Column(type: "INTEGER", nullable: false), EnableProfitAccountBalanceChangeNotify = table.Column(type: "INTEGER", nullable: false), ConsumeRestrictionComplexData = table.Column(type: "TEXT", nullable: true), ClientSideTimestamp = table.Column(type: "TEXT", nullable: true), ServerSideLastModifiedTimestamp = table.Column(type: "TEXT", nullable: true), ServerSideCreatedTimestamp = table.Column(type: "TEXT", nullable: false), SuspendStateStartTime = table.Column(type: "TEXT", nullable: true), SuspendStateEndTime = table.Column(type: "TEXT", nullable: true), CreateByOperatorId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MembershipAccounts", x => x.Id); table.ForeignKey( name: "FK_MembershipAccounts_Operators_CreateByOperatorId", column: x => x.CreateByOperatorId, principalTable: "Operators", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "MembershipTags", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MembershipTags", x => x.Id); }); migrationBuilder.CreateTable( name: "MembershipSubAccounts", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), MembershipAccountId = table.Column(type: "INTEGER", nullable: false), AccountState = table.Column(type: "INTEGER", nullable: false), LastAccountStateUpdateTime = table.Column(type: "TEXT", nullable: true), LastAccountStateUpdateReason = table.Column(type: "TEXT", nullable: true), SuspendStateStartTime = table.Column(type: "TEXT", nullable: true), SuspendStateEndTime = table.Column(type: "TEXT", nullable: true), ServerSideCreatedTimestamp = table.Column(type: "TEXT", nullable: false), ServerSideLastModifiedTimestamp = table.Column(type: "TEXT", nullable: true), SubAccountHolderName = table.Column(type: "TEXT", nullable: true), SubAccountHolderPhoneNumber = table.Column(type: "TEXT", nullable: true), SubAccountHolderEmail = table.Column(type: "TEXT", nullable: true), SubAccountHolderAddress = table.Column(type: "TEXT", nullable: true), EnableProfitAccountBalanceChangeNotify = table.Column(type: "INTEGER", nullable: false), MembershipLevel = table.Column(type: "INTEGER", nullable: true), ConsumeRestrictionComplexData = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true), CreateByOperatorId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MembershipSubAccounts", x => x.Id); table.ForeignKey( name: "FK_MembershipSubAccounts_MembershipAccounts_MembershipAccountId", column: x => x.MembershipAccountId, principalTable: "MembershipAccounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MembershipSubAccounts_Operators_CreateByOperatorId", column: x => x.CreateByOperatorId, principalTable: "Operators", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "MembershipAccount_M2M_MembershipTags", columns: table => new { MembershipAccountId = table.Column(type: "INTEGER", nullable: false), MembershipTagId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MembershipAccount_M2M_MembershipTags", x => new { x.MembershipTagId, x.MembershipAccountId }); table.ForeignKey( name: "FK_MembershipAccount_M2M_MembershipTags_MembershipAccounts_MembershipAccountId", column: x => x.MembershipAccountId, principalTable: "MembershipAccounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MembershipAccount_M2M_MembershipTags_MembershipTags_MembershipTagId", column: x => x.MembershipTagId, principalTable: "MembershipTags", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MembershipProfitAccounts", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), RedeemAuthMode = table.Column(type: "INTEGER", nullable: false), RedeemAuthPassword = table.Column(type: "TEXT", nullable: true), ProfitType = table.Column(type: "INTEGER", nullable: false), Balance = table.Column(type: "REAL", nullable: true), BalanceComplexData = table.Column(type: "TEXT", nullable: true), MembershipAccountId = table.Column(type: "INTEGER", nullable: true), MembershipSubAccountId = table.Column(type: "INTEGER", nullable: true), ServerSideLastModifiedTimestamp = table.Column(type: "TEXT", nullable: true), ServerSideCreatedTimestamp = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MembershipProfitAccounts", x => x.Id); table.ForeignKey( name: "FK_MembershipProfitAccounts_MembershipAccounts_MembershipAccountId", column: x => x.MembershipAccountId, principalTable: "MembershipAccounts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_MembershipProfitAccounts_MembershipSubAccounts_MembershipSubAccountId", column: x => x.MembershipSubAccountId, principalTable: "MembershipSubAccounts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "MembershipSubAccount_M2M_MembershipTags", columns: table => new { MembershipSubAccountId = table.Column(type: "INTEGER", nullable: false), MembershipTagId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MembershipSubAccount_M2M_MembershipTags", x => new { x.MembershipTagId, x.MembershipSubAccountId }); table.ForeignKey( name: "FK_MembershipSubAccount_M2M_MembershipTags_MembershipSubAccounts_MembershipSubAccountId", column: x => x.MembershipSubAccountId, principalTable: "MembershipSubAccounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MembershipSubAccount_M2M_MembershipTags_MembershipTags_MembershipTagId", column: x => x.MembershipTagId, principalTable: "MembershipTags", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MembershipSubAccountIdentities", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), MembershipSubAccountId = table.Column(type: "INTEGER", nullable: false), IdentityCarrierType = table.Column(type: "INTEGER", nullable: false), Identity = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MembershipSubAccountIdentities", x => x.Id); table.ForeignKey( name: "FK_MembershipSubAccountIdentities_MembershipSubAccounts_MembershipSubAccountId", column: x => x.MembershipSubAccountId, principalTable: "MembershipSubAccounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MembershipProfitAccountRecharges", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), RechargeSource = table.Column(type: "INTEGER", nullable: false), RechargeAmount = table.Column(type: "REAL", nullable: true), ProfitAccountAmountBalance = table.Column(type: "TEXT", nullable: true), InvoiceIssuedDateTime = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true), Timestamp = table.Column(type: "TEXT", nullable: false), MembershipProfitAccountId = table.Column(type: "INTEGER", nullable: false), CreateByOperatorId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MembershipProfitAccountRecharges", x => x.Id); table.ForeignKey( name: "FK_MembershipProfitAccountRecharges_MembershipProfitAccounts_MembershipProfitAccountId", column: x => x.MembershipProfitAccountId, principalTable: "MembershipProfitAccounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MembershipProfitAccountRecharges_Operators_CreateByOperatorId", column: x => x.CreateByOperatorId, principalTable: "Operators", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "MembershipProfitAccountRedeems", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Purpose = table.Column(type: "TEXT", nullable: true), RedeemedProfitAmount = table.Column(type: "REAL", nullable: true), RedeemedProfitComplexData = table.Column(type: "TEXT", nullable: true), ProfitAccountAmountBalance = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true), Timestamp = table.Column(type: "TEXT", nullable: false), MembershipProfitAccountId = table.Column(type: "INTEGER", nullable: false), CreateByOperatorId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MembershipProfitAccountRedeems", x => x.Id); table.ForeignKey( name: "FK_MembershipProfitAccountRedeems_MembershipProfitAccounts_MembershipProfitAccountId", column: x => x.MembershipProfitAccountId, principalTable: "MembershipProfitAccounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MembershipProfitAccountRedeems_Operators_CreateByOperatorId", column: x => x.CreateByOperatorId, principalTable: "Operators", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_Transactions_MembershipProfitAccountRechargeId", table: "Transactions", column: "MembershipProfitAccountRechargeId"); migrationBuilder.CreateIndex( name: "IX_Transactions_MembershipProfitAccountRedeemId", table: "Transactions", column: "MembershipProfitAccountRedeemId"); migrationBuilder.CreateIndex( name: "IX_MembershipAccount_M2M_MembershipTags_MembershipAccountId", table: "MembershipAccount_M2M_MembershipTags", column: "MembershipAccountId"); migrationBuilder.CreateIndex( name: "IX_MembershipAccounts_CreateByOperatorId", table: "MembershipAccounts", column: "CreateByOperatorId"); migrationBuilder.CreateIndex( name: "IX_MembershipAccounts_Name_CompanyName_PhoneNumber", table: "MembershipAccounts", columns: new[] { "Name", "CompanyName", "PhoneNumber" }); migrationBuilder.CreateIndex( name: "IX_MembershipProfitAccountRecharges_CreateByOperatorId", table: "MembershipProfitAccountRecharges", column: "CreateByOperatorId"); migrationBuilder.CreateIndex( name: "IX_MembershipProfitAccountRecharges_MembershipProfitAccountId", table: "MembershipProfitAccountRecharges", column: "MembershipProfitAccountId"); migrationBuilder.CreateIndex( name: "IX_MembershipProfitAccountRedeems_CreateByOperatorId", table: "MembershipProfitAccountRedeems", column: "CreateByOperatorId"); migrationBuilder.CreateIndex( name: "IX_MembershipProfitAccountRedeems_MembershipProfitAccountId", table: "MembershipProfitAccountRedeems", column: "MembershipProfitAccountId"); migrationBuilder.CreateIndex( name: "IX_MembershipProfitAccounts_MembershipAccountId", table: "MembershipProfitAccounts", column: "MembershipAccountId"); migrationBuilder.CreateIndex( name: "IX_MembershipProfitAccounts_MembershipSubAccountId", table: "MembershipProfitAccounts", column: "MembershipSubAccountId"); migrationBuilder.CreateIndex( name: "IX_MembershipSubAccount_M2M_MembershipTags_MembershipSubAccountId", table: "MembershipSubAccount_M2M_MembershipTags", column: "MembershipSubAccountId"); migrationBuilder.CreateIndex( name: "IX_MembershipSubAccountIdentities_MembershipSubAccountId_Identity_IdentityCarrierType", table: "MembershipSubAccountIdentities", columns: new[] { "MembershipSubAccountId", "Identity", "IdentityCarrierType" }, unique: true); migrationBuilder.CreateIndex( name: "IX_MembershipSubAccounts_CreateByOperatorId", table: "MembershipSubAccounts", column: "CreateByOperatorId"); migrationBuilder.CreateIndex( name: "IX_MembershipSubAccounts_MembershipAccountId", table: "MembershipSubAccounts", column: "MembershipAccountId"); migrationBuilder.CreateIndex( name: "IX_MembershipTags_Name", table: "MembershipTags", column: "Name", unique: true); migrationBuilder.AddForeignKey( name: "FK_Transactions_MembershipProfitAccountRecharges_MembershipProfitAccountRechargeId", table: "Transactions", column: "MembershipProfitAccountRechargeId", principalTable: "MembershipProfitAccountRecharges", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Transactions_MembershipProfitAccountRedeems_MembershipProfitAccountRedeemId", table: "Transactions", column: "MembershipProfitAccountRedeemId", principalTable: "MembershipProfitAccountRedeems", principalColumn: "Id", onDelete: ReferentialAction.Restrict); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Transactions_MembershipProfitAccountRecharges_MembershipProfitAccountRechargeId", table: "Transactions"); migrationBuilder.DropForeignKey( name: "FK_Transactions_MembershipProfitAccountRedeems_MembershipProfitAccountRedeemId", table: "Transactions"); migrationBuilder.DropTable( name: "MembershipAccount_M2M_MembershipTags"); migrationBuilder.DropTable( name: "MembershipProfitAccountRecharges"); migrationBuilder.DropTable( name: "MembershipProfitAccountRedeems"); migrationBuilder.DropTable( name: "MembershipSubAccount_M2M_MembershipTags"); migrationBuilder.DropTable( name: "MembershipSubAccountIdentities"); migrationBuilder.DropTable( name: "MembershipProfitAccounts"); migrationBuilder.DropTable( name: "MembershipTags"); migrationBuilder.DropTable( name: "MembershipSubAccounts"); migrationBuilder.DropTable( name: "MembershipAccounts"); migrationBuilder.DropIndex( name: "IX_Transactions_MembershipProfitAccountRechargeId", table: "Transactions"); migrationBuilder.DropIndex( name: "IX_Transactions_MembershipProfitAccountRedeemId", table: "Transactions"); migrationBuilder.DropColumn( name: "MembershipProfitAccountRechargeId", table: "Transactions"); migrationBuilder.DropColumn( name: "MembershipProfitAccountRedeemId", table: "Transactions"); migrationBuilder.DropColumn( name: "TransactionSubType", table: "Transactions"); migrationBuilder.DropColumn( name: "CardReaderName", table: "Payments"); migrationBuilder.DropColumn( name: "TargetMembershipAccountId", table: "Payments"); migrationBuilder.DropColumn( name: "TargetMembershipSubAccountId", table: "Payments"); } } }