| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- namespace Gateway.POS.Migrations
- {
- public partial class addMembership : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn<int>(
- name: "MembershipProfitAccountRechargeId",
- table: "Transactions",
- type: "INTEGER",
- nullable: true);
- migrationBuilder.AddColumn<int>(
- name: "MembershipProfitAccountRedeemId",
- table: "Transactions",
- type: "INTEGER",
- nullable: true);
- migrationBuilder.AddColumn<int>(
- name: "TransactionSubType",
- table: "Transactions",
- type: "INTEGER",
- nullable: true);
- migrationBuilder.AddColumn<string>(
- name: "CardReaderName",
- table: "Payments",
- type: "TEXT",
- nullable: true);
- migrationBuilder.AddColumn<int>(
- name: "TargetMembershipAccountId",
- table: "Payments",
- type: "INTEGER",
- nullable: true);
- migrationBuilder.AddColumn<int>(
- name: "TargetMembershipSubAccountId",
- table: "Payments",
- type: "INTEGER",
- nullable: true);
- migrationBuilder.CreateTable(
- name: "MembershipAccounts",
- columns: table => new
- {
- Id = table.Column<int>(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- Name = table.Column<string>(type: "TEXT", nullable: false),
- CompanyName = table.Column<string>(type: "TEXT", nullable: true),
- Age = table.Column<int>(type: "INTEGER", nullable: false),
- PhoneNumber = table.Column<string>(type: "TEXT", nullable: true),
- Address = table.Column<string>(type: "TEXT", nullable: true),
- Email = table.Column<string>(type: "TEXT", nullable: true),
- Birth = table.Column<DateTime>(type: "TEXT", nullable: true),
- IsMale = table.Column<bool>(type: "INTEGER", nullable: false),
- Description = table.Column<string>(type: "TEXT", nullable: true),
- InvoiceTaxNumber = table.Column<string>(type: "TEXT", nullable: true),
- InvoiceCompanyName = table.Column<string>(type: "TEXT", nullable: true),
- MembershipLevel = table.Column<int>(type: "INTEGER", nullable: true),
- AllowSubAccountAccessProfitAccounts = table.Column<bool>(type: "INTEGER", nullable: false),
- EnableProfitAccountBalanceChangeNotify = table.Column<bool>(type: "INTEGER", nullable: false),
- ConsumeRestrictionComplexData = table.Column<string>(type: "TEXT", nullable: true),
- ClientSideTimestamp = table.Column<DateTime>(type: "TEXT", nullable: true),
- ServerSideLastModifiedTimestamp = table.Column<DateTime>(type: "TEXT", nullable: true),
- ServerSideCreatedTimestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
- SuspendStateStartTime = table.Column<DateTime>(type: "TEXT", nullable: true),
- SuspendStateEndTime = table.Column<DateTime>(type: "TEXT", nullable: true),
- CreateByOperatorId = table.Column<int>(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<int>(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- Name = table.Column<string>(type: "TEXT", nullable: true),
- Description = table.Column<string>(type: "TEXT", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_MembershipTags", x => x.Id);
- });
- migrationBuilder.CreateTable(
- name: "MembershipSubAccounts",
- columns: table => new
- {
- Id = table.Column<int>(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- MembershipAccountId = table.Column<int>(type: "INTEGER", nullable: false),
- AccountState = table.Column<int>(type: "INTEGER", nullable: false),
- LastAccountStateUpdateTime = table.Column<DateTime>(type: "TEXT", nullable: true),
- LastAccountStateUpdateReason = table.Column<string>(type: "TEXT", nullable: true),
- SuspendStateStartTime = table.Column<DateTime>(type: "TEXT", nullable: true),
- SuspendStateEndTime = table.Column<DateTime>(type: "TEXT", nullable: true),
- ServerSideCreatedTimestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
- ServerSideLastModifiedTimestamp = table.Column<DateTime>(type: "TEXT", nullable: true),
- SubAccountHolderName = table.Column<string>(type: "TEXT", nullable: true),
- SubAccountHolderPhoneNumber = table.Column<string>(type: "TEXT", nullable: true),
- SubAccountHolderEmail = table.Column<string>(type: "TEXT", nullable: true),
- SubAccountHolderAddress = table.Column<string>(type: "TEXT", nullable: true),
- EnableProfitAccountBalanceChangeNotify = table.Column<bool>(type: "INTEGER", nullable: false),
- MembershipLevel = table.Column<int>(type: "INTEGER", nullable: true),
- ConsumeRestrictionComplexData = table.Column<string>(type: "TEXT", nullable: true),
- Description = table.Column<string>(type: "TEXT", nullable: true),
- CreateByOperatorId = table.Column<int>(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<int>(type: "INTEGER", nullable: false),
- MembershipTagId = table.Column<int>(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<int>(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- RedeemAuthMode = table.Column<int>(type: "INTEGER", nullable: false),
- RedeemAuthPassword = table.Column<string>(type: "TEXT", nullable: true),
- ProfitType = table.Column<int>(type: "INTEGER", nullable: false),
- Balance = table.Column<double>(type: "REAL", nullable: true),
- BalanceComplexData = table.Column<string>(type: "TEXT", nullable: true),
- MembershipAccountId = table.Column<int>(type: "INTEGER", nullable: true),
- MembershipSubAccountId = table.Column<int>(type: "INTEGER", nullable: true),
- ServerSideLastModifiedTimestamp = table.Column<DateTime>(type: "TEXT", nullable: true),
- ServerSideCreatedTimestamp = table.Column<DateTime>(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<int>(type: "INTEGER", nullable: false),
- MembershipTagId = table.Column<int>(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<int>(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- MembershipSubAccountId = table.Column<int>(type: "INTEGER", nullable: false),
- IdentityCarrierType = table.Column<int>(type: "INTEGER", nullable: false),
- Identity = table.Column<string>(type: "TEXT", nullable: true),
- Description = table.Column<string>(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<int>(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- RechargeSource = table.Column<int>(type: "INTEGER", nullable: false),
- RechargeAmount = table.Column<double>(type: "REAL", nullable: true),
- ProfitAccountAmountBalance = table.Column<decimal>(type: "TEXT", nullable: true),
- InvoiceIssuedDateTime = table.Column<DateTime>(type: "TEXT", nullable: true),
- Description = table.Column<string>(type: "TEXT", nullable: true),
- Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
- MembershipProfitAccountId = table.Column<int>(type: "INTEGER", nullable: false),
- CreateByOperatorId = table.Column<int>(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<int>(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- Purpose = table.Column<string>(type: "TEXT", nullable: true),
- RedeemedProfitAmount = table.Column<double>(type: "REAL", nullable: true),
- RedeemedProfitComplexData = table.Column<string>(type: "TEXT", nullable: true),
- ProfitAccountAmountBalance = table.Column<decimal>(type: "TEXT", nullable: true),
- Description = table.Column<string>(type: "TEXT", nullable: true),
- Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
- MembershipProfitAccountId = table.Column<int>(type: "INTEGER", nullable: false),
- CreateByOperatorId = table.Column<int>(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");
- }
- }
- }
|