示例#1
0
        public int Create()
        {
            SchemaBuilder.CreateTable(typeof (ProductImageRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("Width")
                    .Column<int>("Height")
                    .Column<int>("Ppi")
                    .Column<int>("PrintableFrontLeft")
                    .Column<int>("PrintableFrontTop")
                    .Column<int>("PrintableFrontWidth")
                    .Column<int>("PrintableFrontHeight")
                    .Column<int>("ChestLineFront")
                    .Column<int>("PrintableBackLeft")
                    .Column<int>("PrintableBackTop")
                    .Column<int>("PrintableBackWidth")
                    .Column<int>("PrintableBackHeight")
                    .Column<int>("ChestLineBack")
                    .Column<string>("Gender", c => c.Nullable())

                );

            SchemaBuilder.CreateTable(typeof (ProductGroupRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name", c => c.WithLength(150))
                );

            SchemaBuilder.CreateTable(typeof (ProductHeadlineRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name", c => c.WithLength(150))
                );

            SchemaBuilder.CreateTable(typeof (ProductRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name", c => c.WithLength(250))
                    .Column<int>("ProductHeadlineRecord_Id")
                    .Column<int>("ProductImageRecord_Id")
                    .Column<string>("Materials", c => c.Nullable())
                    .Column<string>("Details", c => c.Unlimited().Nullable())
                );

            SchemaBuilder.CreateTable(typeof (ProductColorRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name", c => c.WithLength(150))
                    .Column<string>("Value", c => c.WithLength(10))
                    .Column<int>("Importance", c => c.Nullable())
                );

            SchemaBuilder.CreateTable(typeof (SizeCodeRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name", c => c.WithLength(10))
                );

            SchemaBuilder.CreateTable(typeof (ProductSizeRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("SizeCodeRecord_Id")
                    .Column<double>("LengthCm")
                    .Column<double>("WidthCm")
                    .Column<double>("SleeveCm", c => c.Nullable())
                    .Column<double>("LengthInch")
                    .Column<double>("WidthInch")
                    .Column<double>("SleeveInch", c => c.Nullable())
                );

            SchemaBuilder.CreateTable(typeof (LinkProductColorRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("ProductColorRecord_Id")
                    .Column<int>("ProductRecord_Id")
                    .Column<double>("BaseCost")
                );

            SchemaBuilder.CreateTable(typeof (LinkProductSizeRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("ProductSizeRecord_Id")
                    .Column<int>("ProductRecord_Id")
                );

            SchemaBuilder.CreateTable(typeof (TeeyootUserPartRecord).Name,
                table => table
                    .ContentPartRecord()
                    .Column<string>("PublicName", c => c.WithLength(50))
                    .Column<string>("PhoneNumber", c => c.WithLength(50))
                    .Column<DateTime>("CreatedUtc")
                );

            SchemaBuilder.CreateTable(typeof (CurrencyRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Code", c => c.WithLength(10))
                    .Column<string>("Name", c => c.WithLength(150))
                    .Column<string>("ShortName", c => c.WithLength(50))
                );

            SchemaBuilder.CreateTable(typeof (CampaignRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Title")
                    .Column<int>("TeeyootUserId")
                    .Column<int>("ProductCountGoal")
                    .Column<int>("ProductCountSold")
                    .Column<string>("Design", c => c.Unlimited())
                    .Column<string>("Description", c => c.Unlimited())
                    .Column<DateTime>("EndDate")
                    .Column<string>("URL")
                    .Column<bool>("IsForCharity", c => c.WithDefault(false))
                    .Column<bool>("BackSideByDefault", c => c.WithDefault(false))
                );

            SchemaBuilder.CreateTable(typeof (CampaignProductRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("CampaignRecord_Id")
                    .Column<int>("CurrencyRecord_Id")
                    .Column<double>("Price")
                    .Column<double>("BaseCost")
                    .Column<int>("ProductRecord_Id")
                    .Column<int>("ProductColorRecord_Id")
                );

            SchemaBuilder.CreateTable(typeof (FontRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Family", c => c.WithLength(150))
                    .Column<string>("FileName", c => c.WithLength(150))
                    .Column<string>("Tags", c => c.WithLength(250))
                    .Column<int>("Priority", c => c.Nullable())
                );

            SchemaBuilder.CreateTable(typeof (SwatchRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name", c => c.WithLength(150))
                    .Column<bool>("InStock", c => c.WithDefault(true))
                    .Column<int>("Red")
                    .Column<int>("Blue")
                    .Column<int>("Green")
                );

            SchemaBuilder.CreateTable(typeof (CampaignCategoriesRecord).Name,
                table => table
                    .ContentPartRecord()
                    .Column<string>("Name", c => c.WithLength(50))
                );

            ContentDefinitionManager.AlterPartDefinition(typeof (CampaignCategoriesPart).Name,
                part => part.Attachable(false));
            ContentDefinitionManager.AlterTypeDefinition("CampaignCategories", type => type
                .WithPart(typeof (CampaignCategoriesPart).Name)
                .WithPart("CommonPart")
                );

            SchemaBuilder.CreateForeignKey("Product_ProductHeadline", "ProductRecord",
                new[] {"ProductHeadlineRecord_Id"}, "ProductHeadlineRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("Product_ProductImage", "ProductRecord", new[] {"ProductImageRecord_Id"},
                "ProductImageRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("ProductSize_SizeCode", "ProductSizeRecord", new[] {"SizeCodeRecord_Id"},
                "SizeCodeRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("LinkProductColor_Product", "LinkProductColorRecord",
                new[] {"ProductRecord_Id"}, "ProductRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("LinkProductColor_ProductColor", "LinkProductColorRecord",
                new[] {"ProductColorRecord_Id"}, "ProductColorRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("LinkProductSize_Product", "LinkProductSizeRecord",
                new[] {"ProductRecord_Id"}, "ProductRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("LinkProductSize_ProductSize", "LinkProductSizeRecord",
                new[] {"ProductSizeRecord_Id"}, "ProductSizeRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("CampaignProduct_Campaign", "CampaignProductRecord",
                new[] {"CampaignRecord_Id"}, "CampaignRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("CampaignProduct_Product", "CampaignProductRecord",
                new[] {"ProductRecord_Id"}, "ProductRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("CampaignProduct_ProductColor", "CampaignProductRecord",
                new[] {"ProductColorRecord_Id"}, "ProductColorRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("Campaign_TeeyootUser", "CampaignRecord", new[] {"TeeyootUserId"},
                "TeeyootUserPartRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("CampaignProduct_Currency", "CampaignProductRecord",
                new[] {"CurrencyRecord_Id"}, "CurrencyRecord", new[] {"Id"});


            ContentDefinitionManager.AlterPartDefinition(typeof (TeeyootUserPart).Name, part => part
                .Attachable(false)
                );

            ContentDefinitionManager.AlterTypeDefinition("TeeyootUser", type => type
                .WithPart(typeof (TeeyootUserPart).Name)
                .WithPart("UserPart")
                );

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table
                    .AddColumn<string>("Alias", c => c.WithLength(100))
                );

            SchemaBuilder.CreateTable(typeof (OrderRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Email", c => c.WithLength(100))
                    .Column<string>("FirstName", c => c.WithLength(100))
                    .Column<string>("LastName", c => c.WithLength(100))
                    .Column<string>("City", c => c.WithLength(100))
                    .Column<string>("State", c => c.WithLength(100))
                    .Column<string>("Country", c => c.WithLength(100))
                    .Column<double>("TotalPrice")
                    .Column<int>("CurrencyRecord_Id")
                );

            SchemaBuilder.CreateTable(typeof (LinkOrderCampaignProductRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("OrderRecord_Id")
                    .Column<int>("CampaignProductRecord_Id")
                    .Column<int>("Count")
                    .Column<string>("Size", c => c.WithLength(10)));

            SchemaBuilder.CreateForeignKey("Order_Currency", "OrderRecord", new[] {"CurrencyRecord_Id"},
                "CurrencyRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("LinkOrderCampaignProduct_Order", "LinkOrderCampaignProductRecord",
                new[] {"OrderRecord_Id"}, "OrderRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("LinkOrderCampaignProduct_CampaignProduct", "LinkOrderCampaignProductRecord",
                new[] {"CampaignProductRecord_Id"}, "CampaignProductRecord", new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<string>("Tags", c => c.Unlimited()));

            SchemaBuilder.CreateTable(typeof (LinkProductGroupRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("ProductGroupRecord_Id")
                    .Column<int>("ProductRecord_Id")
                );

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<string>("StreetAddress", c => c.Unlimited()));
            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<string>("PostalCode", c => c.WithLength(50)));
            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<string>("PhoneNumber", c => c.WithLength(50)));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name, table => table.DropColumn("StreetAddress"));
            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name, table => table.DropColumn("PostalCode"));
            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name, table => table.DropColumn("PhoneNumber"));
            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<string>("StreetAddress", c => c.Unlimited()));
            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<string>("PostalCode", c => c.WithLength(50)));
            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<string>("PhoneNumber", c => c.WithLength(50)));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<DateTime>("Created", c => c.NotNull()));
            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<DateTime>("Paid", c => c.Nullable()));

            SchemaBuilder.CreateTable(typeof (CampaignStatusRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name", c => c.WithLength(150))
                );

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<int>("CampaignStatusRecord_Id"));

            SchemaBuilder.CreateForeignKey("Campaign_Status", "CampaignRecord", new[] {"CampaignStatusRecord_Id"},
                "CampaignStatusRecord", new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (LinkOrderCampaignProductRecord).Name,
                table => table.DropColumn("Size"));

            SchemaBuilder.AlterTable(typeof (LinkOrderCampaignProductRecord).Name,
                table => table.AddColumn<int>("SizeId"));

            SchemaBuilder.CreateForeignKey("OrderProduct_Size", "LinkOrderCampaignProductRecord", new[] {"SizeId"},
                "ProductSizeRecord", new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name, table => table.AddColumn<DateTime>("StartDate"));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name, table => table.DropColumn("Tags"));

            SchemaBuilder.AlterTable(typeof (CampaignCategoriesRecord).Name, table => table.AddColumn<bool>("IsVisible"));

            SchemaBuilder.CreateTable(typeof (LinkCampaignAndCategoriesRecord).Name, table => table
                .Column<int>("Id", column => column.PrimaryKey().Identity())
                .Column<int>("CampaignRecord_Id")
                .Column<int>("CampaignCategoriesPartRecord_Id")
                );

            SchemaBuilder.CreateForeignKey("LinkCampaignAndCategories_Campaign", "LinkCampaignAndCategoriesRecord",
                new[] {"CampaignRecord_Id"}, "CampaignRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("LinkCampaignAndCategories_CampaignCategories",
                "LinkCampaignAndCategoriesRecord", new[] {"CampaignCategoriesPartRecord_Id"},
                "CampaignCategoriesPartRecord", new[] {"Id"});

            SchemaBuilder.DropForeignKey("LinkOrderCampaignProductRecord", "OrderProduct_Size");

            SchemaBuilder.AlterTable(typeof (LinkOrderCampaignProductRecord).Name,
                table => table.DropColumn("SizeId"));

            SchemaBuilder.AlterTable(typeof (LinkOrderCampaignProductRecord).Name,
                table => table.AddColumn<int>("ProductSizeRecord_Id"));

            SchemaBuilder.CreateForeignKey("OrderProduct_Size", "LinkOrderCampaignProductRecord",
                new[] {"ProductSizeRecord_Id"}, "ProductSizeRecord", new[] {"Id"});

            SchemaBuilder.CreateTable(typeof (StoreRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("TeeyootUserId")
                    .Column<string>("Title")
                    .Column<string>("Description")
                    .Column<bool>("HideStore", c => c.WithDefault(false))
                    .Column<bool>("CrossSelling", c => c.WithDefault(false))
                );

            SchemaBuilder.CreateTable(typeof (LinkStoreCampaignRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("StoreRecord_Id")
                    .Column<int>("CampaignRecord_Id")
                );

            SchemaBuilder.CreateForeignKey("Store_TeeyootUser", "StoreRecord", new[] {"TeeyootUserId"},
                "TeeyootUserPartRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("LinkStoreCampaignRecord_CampaignRecord", "LinkStoreCampaignRecord",
                new[] {"CampaignRecord_Id"}, "CampaignRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("LinkOrderCampaignProduct_StoreRecord", "LinkStoreCampaignRecord",
                new[] {"StoreRecord_Id"}, "StoreRecord", new[] {"Id"});

            SchemaBuilder.DropForeignKey("LinkCampaignAndCategoriesRecord",
                "LinkCampaignAndCategories_CampaignCategories");
            SchemaBuilder.DropTable(typeof (CampaignCategoriesRecord).Name);
            ContentDefinitionManager.DeletePartDefinition(typeof (CampaignCategoriesPart).Name);
            ContentDefinitionManager.DeleteTypeDefinition("CampaignCategories");

            SchemaBuilder.CreateTable(typeof (CampaignCategoriesRecord).Name, table => table
                .Column<int>("Id", column => column.PrimaryKey().Identity())
                .Column<string>("Name", column => column.WithLength(50))
                .Column<bool>("IsVisible")
                );

            SchemaBuilder.CreateForeignKey("LinkCampaignAndCategories_CampaignCategories",
                "LinkCampaignAndCategoriesRecord", new[] {"CampaignCategoriesPartRecord_Id"}, "CampaignCategoriesRecord",
                new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<bool>("IsFeatured", cl => cl.WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (StoreRecord).Name,
                table => table.AddColumn<string>("Url", cl => cl.WithLength(150)));

            SchemaBuilder.CreateTable(typeof (TShirtCostRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<float>("FirstScreenCost")
                    .Column<float>("AdditionalScreenCosts")
                    .Column<float>("InkCost")
                    .Column<int>("PrintsPerLitre")
                    .Column<float>("LabourCost")
                    .Column<int>("LabourTimePerColourPerPrint")
                    .Column<int>("LabourTimePerSidePrintedPerPrint")
                    .Column<float>("CostOfMaterial")
                    .Column<float>("PercentageMarkUpRequired")
                    .Column<float>("DTGPrintPrice")
                );

            SchemaBuilder.CreateTable(typeof (OrderStatusRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name", c => c.WithLength(150))
                );

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<DateTime>("Reserved", c => c.Nullable()));
            SchemaBuilder.AlterTable(typeof (OrderRecord).Name, table => table.AddColumn<int>("OrderStatusRecord_Id"));

            SchemaBuilder.CreateForeignKey("Order_Status", "OrderRecord", new[] {"OrderStatusRecord_Id"},
                "OrderStatusRecord", new[] {"Id"});

            SchemaBuilder.CreateTable(typeof (PayoutRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<DateTime>("Date")
                    .Column<string>("Event", c => c.Unlimited())
                    .Column<double>("Amount")
                    .Column<bool>("IsPlus")
                    .Column<int>("UserId")
                );

            SchemaBuilder.CreateForeignKey("PayoutRecord_UserId", "PayoutRecord", new[] {"UserId"},
                "TeeyootUserPartRecord", new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (TeeyootUserPartRecord).Name,
                table => table.AddColumn<string>("Street", c => c.Unlimited()));
            SchemaBuilder.AlterTable(typeof (TeeyootUserPartRecord).Name,
                table => table.AddColumn<string>("Suit", c => c.WithLength(50)));
            SchemaBuilder.AlterTable(typeof (TeeyootUserPartRecord).Name,
                table => table.AddColumn<string>("City", c => c.WithLength(100)));
            SchemaBuilder.AlterTable(typeof (TeeyootUserPartRecord).Name,
                table => table.AddColumn<string>("State", c => c.WithLength(100)));
            SchemaBuilder.AlterTable(typeof (TeeyootUserPartRecord).Name,
                table => table.AddColumn<string>("Zip", c => c.WithLength(50)));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<string>("OrderPublicId", c => c.NotNull().WithLength(50)));

            SchemaBuilder.AlterTable(typeof (TShirtCostRecord).Name, table => table.DropColumn("CostOfMaterial"));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<bool>("IsActive", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (PayoutRecord).Name,
                table => table.AddColumn<string>("Status", c => c.NotNull().WithLength(50)));

            SchemaBuilder.CreateTable(typeof (PromotionRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<DateTime>("Expiration")
                    .Column<string>("PromoId", c => c.WithLength(15))
                    .Column<string>("AmountType", c => c.WithLength(50))
                    .Column<int>("AmountSize")
                    .Column<string>("DiscountType", c => c.WithLength(50))
                    .Column<bool>("Status")
                    .Column<int>("Redeemed")
                );

            SchemaBuilder.AlterTable(typeof (PromotionRecord).Name,
                table => table.AddColumn<int>("Userid", c => c.NotNull()));

            SchemaBuilder.CreateForeignKey("PromotionRecord_UserId", "PromotionRecord", new[] {"UserId"},
                "TeeyootUserPartRecord", new[] {"Id"});

            SchemaBuilder.CreateTable(typeof (OrderHistoryRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<DateTime>("EventDate")
                    .Column<string>("Event", c => c.Unlimited())
                    .Column<int>("OrderRecord_Id")
                );

            SchemaBuilder.CreateForeignKey("OrderHistory_Order", "OrderHistoryRecord", new[] {"OrderRecord_Id"},
                "OrderRecord", new[] {"Id"});

            SchemaBuilder.CreateTable(typeof (PaymentInformationRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("AccountNumber")
                    .Column<string>("BankName")
                    .Column<int>("ContactNumber")
                    .Column<string>("MessAdmin")
                    .Column<int>("TranzactionId")
                );

            SchemaBuilder.CreateForeignKey("Tranzaction_Payout_Id", "PaymentInformationRecord", new[] {"TranzactionId"},
                "PayoutRecord", new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name, table => table.AddColumn<double>("Promotion"));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name, table => table.AddColumn<double>("TotalPriceWithPromo"));

            SchemaBuilder.AlterTable(typeof (PaymentInformationRecord).Name,
                table => table.AddColumn<string>("AccountHolderName"));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<bool>("IsActive", c => c.NotNull().WithDefault(true)));
            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<bool>("IsApproved", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<string>("TranzactionId", c => c.Nullable()));

            SchemaBuilder.CreateTable(typeof (MessageRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("UserId")
                    .Column<string>("Text")
                    .Column<string>("From")
                    .Column<DateTime>("SendDate")
                );

            SchemaBuilder.CreateForeignKey("Message_User_Id", "MessageRecord", new[] {"UserId"}, "TeeyootUserPartRecord",
                new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<DateTime>("Delete", c => c.WithDefault(null)));

            SchemaBuilder.AlterTable(typeof (MessageRecord).Name, table => table.DropColumn("Text"));

            SchemaBuilder.AlterTable(typeof (MessageRecord).Name,
                table => table.AddColumn<string>("Text", c => c.Unlimited()));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name, table => table.DropColumn("Delete"));

            SchemaBuilder.AlterTable(typeof (MessageRecord).Name, table => table.DropColumn("From"));

            SchemaBuilder.AlterTable(typeof (MessageRecord).Name,
                table => table.AddColumn<string>("Sender", c => c.WithLength(50)));

            SchemaBuilder.AlterTable(typeof (MessageRecord).Name, table => table.AddColumn<int>("CampaignId"));

            SchemaBuilder.CreateForeignKey("Message_Campaign_Id", "MessageRecord", new[] {"CampaignId"},
                "CampaignRecord", new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<DateTime>("WhenDeleted", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<bool>("IsPrivate", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (MessageRecord).Name,
                table => table.AddColumn<bool>("IsApprowed", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (MessageRecord).Name,
                table => table.AddColumn<string>("Subject", c => c.WithLength(50)));

            SchemaBuilder.AlterTable(typeof (LinkProductSizeRecord).Name,
                table => table.AddColumn<float>("SizeCost", c => c.NotNull().WithDefault(float.Parse("0"))));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<bool>("ProfitPaid", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.CreateTable(typeof (MailChimpSettingsPartRecord).Name,
                table => table
                    .ContentPartRecord()
                    .Column<string>("ApiKey", c => c.WithLength(50))
                    .Column<string>("Culture", c => c.WithLength(50)));


            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<string>("CampaignProfit", c => c.NotNull().WithDefault(string.Empty)));

            SchemaBuilder.AlterTable(typeof (TShirtCostRecord).Name,
                table => table.AddColumn<int>("SalesGoal", c => c.NotNull().WithDefault(500)));

            SchemaBuilder.AlterTable(typeof (TShirtCostRecord).Name,
                table => table.AddColumn<int>("MaxColors", c => c.NotNull().WithDefault(10)));

            SchemaBuilder.CreateTable(typeof (CommonSettingsRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name", c => c.WithLength(50))
                    .Column<bool>("Value"));

            SchemaBuilder.DropTable(typeof (CommonSettingsRecord).Name);

            SchemaBuilder.CreateTable(typeof (CommonSettingsRecord).Name, table => table
                .Column<int>("Id", column => column.PrimaryKey().Identity())
                .Column<bool>("DoNotAcceptAnyNewCampaigns", column => column.NotNull().WithDefault(false))
                .Column<int>("ColoursPerPrint", column => column.NotNull().WithDefault(0)));

            var commonSettings = new CommonSettingsRecord();
            _commonSettingsRepository.Create(commonSettings);


            SchemaBuilder.CreateTable(typeof (PaymentSettingsRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Culture", c => c.WithLength(50))
                    .Column<int>("PaymentMethod"));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<int>("Environment", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("PublicKey", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("PrivateKey", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("MerchantId", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("ClientToken", c => c.Nullable()));



            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<int>("ProductMinimumGoal", c => c.NotNull().WithDefault(0)));

            SchemaBuilder.AlterTable(typeof (ProductRecord).Name,
                table => table.AddColumn<DateTime>("WhenDeleted", c => c.Nullable()));


            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name, table => table.DropColumn("ClientToken"));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("ClientToken", c => c.Unlimited()));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<bool>("Rejected", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<DateTime>("WhenApproved", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<DateTime>("WhenSentOut", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name, table => table.DropColumn("WhenApproved"));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<DateTime>("WhenApproved", c => c.Nullable()));

            SchemaBuilder.CreateTable(typeof (CheckoutCampaignRequest).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<DateTime>("RequestUtcDate", column => column.NotNull())
                    .Column<bool>("EmailSent", column => column.NotNull().WithDefault(false))
                    .Column<DateTime>("EmailSentUtcDate"));

            SchemaBuilder.AlterTable(typeof (CheckoutCampaignRequest).Name,
                table => table
                    .AddColumn<string>("Email", column => column.WithLength(100).NotNull()));

            SchemaBuilder.AlterTable(typeof (CommonSettingsRecord).Name,
                table => table
                    .DropColumn("ColoursPerPrint"));

            SchemaBuilder.CreateTable(typeof (BringBackCampaignRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("CampaignRecord_Id")
                    .Column<string>("Email", c => c.NotNull())
                );

            SchemaBuilder.CreateForeignKey("BringBackCampaign_Order", "BringBackCampaignRecord",
                new[] {"CampaignRecord_Id"}, "CampaignRecord", new[] {"Id"});

            SchemaBuilder.CreateTable(typeof (ArtRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Name")
                    .Column<string>("FileName")
                );

            SchemaBuilder.AlterTable(typeof (CheckoutCampaignRequest).Name,
                table => table
                    .DropColumn("EmailSent"));



            SchemaBuilder.AlterTable(typeof (PayoutRecord).Name,
                table => table
                    .AddColumn<int>("Currency_Id", column => column.NotNull().WithDefault(1)));

            SchemaBuilder.CreateForeignKey("CurrencyKey", "PayoutRecord", new[] {"Currency_Id"},
                "CurrencyRecord", new[] {"Id"});


            SchemaBuilder.AlterTable(typeof (PaymentInformationRecord).Name,
                table => table
                    .DropColumn("AccountNumber"));

            SchemaBuilder.AlterTable(typeof (PaymentInformationRecord).Name,
                table => table
                    .DropColumn("ContactNumber"));

            SchemaBuilder.AlterTable(typeof (PaymentInformationRecord).Name,
                table => table
                    .AddColumn<string>("AccountNumber", column => column.Nullable()));

            SchemaBuilder.AlterTable(typeof (PaymentInformationRecord).Name,
                table => table
                    .AddColumn<string>("ContactNumber", column => column.Nullable()));


            SchemaBuilder.AlterTable(typeof (PromotionRecord).Name,
                table => table
                    .DropColumn("AmountSize"));

            SchemaBuilder.AlterTable(typeof (PromotionRecord).Name,
                table => table
                    .AddColumn<double>("AmountSize"));

            SchemaBuilder.AlterTable(typeof (TeeyootUserPartRecord).Name,
                table => table.AddColumn<string>("Country", c => c.WithLength(100)));
            SchemaBuilder.AlterTable(typeof (LinkProductColorRecord).Name,
                table => table
                    .DropColumn("BaseCost"));

            SchemaBuilder.AlterTable(typeof (ProductRecord).Name,
                table => table
                    .AddColumn<float>("BaseCost"));

            SchemaBuilder.AlterTable(typeof (CampaignProductRecord).Name,
                table => table.AddColumn<int>("SecondProductColorRecord_Id", c => c.Nullable()));
            SchemaBuilder.AlterTable(typeof (CampaignProductRecord).Name,
                table => table.AddColumn<int>("ThirdProductColorRecord_Id", c => c.Nullable()));
            SchemaBuilder.AlterTable(typeof (CampaignProductRecord).Name,
                table => table.AddColumn<int>("FourthProductColorRecord_Id", c => c.Nullable()));
            SchemaBuilder.AlterTable(typeof (CampaignProductRecord).Name,
                table => table.AddColumn<int>("FifthProductColorRecord_Id", c => c.Nullable()));

            SchemaBuilder.CreateForeignKey("CampaignProduct_ProductColorSecond", "CampaignProductRecord",
                new[] {"SecondProductColorRecord_Id"}, "ProductColorRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("CampaignProduct_ProductColorThird", "CampaignProductRecord",
                new[] {"ThirdProductColorRecord_Id"}, "ProductColorRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("CampaignProduct_ProductColorFourth", "CampaignProductRecord",
                new[] {"FourthProductColorRecord_Id"}, "ProductColorRecord", new[] {"Id"});
            SchemaBuilder.CreateForeignKey("CampaignProduct_ProductColorFifth", "CampaignProductRecord",
                new[] {"FifthProductColorRecord_Id"}, "ProductColorRecord", new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (LinkOrderCampaignProductRecord).Name,
                table => table.AddColumn<int>("ProductColorRecord_Id", c => c.Nullable()));

            SchemaBuilder.CreateForeignKey("LinkOrderCampaignProduct_ProductColor", "LinkOrderCampaignProductRecord",
                new[] {"ProductColorRecord_Id"}, "ProductColorRecord", new[] {"Id"});

            SchemaBuilder.CreateTable(typeof (DeliverySettingRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("State")
                    .Column<double>("DeliveryCost")
                );


            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name, table => table.DropColumn("PaymentMethod"));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<bool>("CashDeliv", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<bool>("PayPal", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<bool>("Mol", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<bool>("CreditCard", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("MerchantIdMol", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("VerifyKey", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<bool>("IsArchived", c => c.NotNull().WithDefault(false)));
            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<int>("BaseCampaignId", c => c.Nullable()));

            SchemaBuilder.CreateForeignKey("CampaignRecord_BaseCampaignId", "CampaignRecord",
                new[] {"BaseCampaignId"}, "CampaignRecord", new[] {"Id"});


            SchemaBuilder.AlterTable(typeof (CampaignProductRecord).Name,
                table => table.AddColumn<DateTime>("WhenDeleted", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name, table => table.AddColumn<int>("CntFrontColor"));
            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name, table => table.AddColumn<int>("CntBackColor"));

            SchemaBuilder.AlterTable(typeof (DeliverySettingRecord).Name,
                table => table.AddColumn<bool>("Enabled", c => c.NotNull().WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table =>
                    table.AddColumn<string>("CampaignCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));

            SchemaBuilder.AlterTable(typeof (CurrencyRecord).Name,
                table =>
                    table.AddColumn<string>("CurrencyCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));

            SchemaBuilder.AlterTable(typeof (TShirtCostRecord).Name,
                table => table.AddColumn<string>("CostCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));
            SchemaBuilder.AlterTable(typeof (CampaignCategoriesRecord).Name,
                table =>
                    table.AddColumn<string>("CategoriesCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));

            SchemaBuilder.AlterTable(typeof (CommonSettingsRecord).Name,
                table => table.AddColumn<string>("CashOnDeliveryAvailabilityMessage"));

            SchemaBuilder.AlterTable(typeof (TeeyootUserPartRecord).Name,
                table =>
                    table.AddColumn<string>("TeeyootUserCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));

            SchemaBuilder.AlterTable(typeof (CommonSettingsRecord).Name,
                table => table.DropColumn("CashOnDeliveryAvailabilityMessage"));

            SchemaBuilder.AlterTable(typeof (ArtRecord).Name,
                table => table.AddColumn<string>("ArtCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));
            SchemaBuilder.AlterTable(typeof (ProductImageRecord).Name,
                table => table.AddColumn<string>("ProdImgCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));
            SchemaBuilder.AlterTable(typeof (ProductHeadlineRecord).Name,
                table =>
                    table.AddColumn<string>("ProdHeadCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));
            SchemaBuilder.AlterTable(typeof (ProductSizeRecord).Name,
                table =>
                    table.AddColumn<string>("ProdSizeCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));
            SchemaBuilder.AlterTable(typeof (ProductGroupRecord).Name,
                table =>
                    table.AddColumn<string>("ProdGroupCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));
            SchemaBuilder.AlterTable(typeof (FontRecord).Name,
                table => table.AddColumn<string>("FontCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));

            SchemaBuilder.AlterTable(typeof (ProductColorRecord).Name,
                table =>
                    table.AddColumn<string>("ProdColorCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));
            SchemaBuilder.AlterTable(typeof (SwatchRecord).Name,
                table => table.AddColumn<string>("SwatchCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));

            SchemaBuilder.AlterTable(typeof (CommonSettingsRecord).Name,
                table => table.AddColumn<string>("CommonCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));

            SchemaBuilder.AlterTable(typeof (DeliverySettingRecord).Name,
                table =>
                    table.AddColumn<string>("DeliveryCulture", c => c.NotNull().WithDefault("en-MY").WithLength(10)));

            SchemaBuilder.AlterTable(typeof (OrderRecord).Name,
                table => table.AddColumn<double>("Delivery"));

            SchemaBuilder.CreateTable(typeof (MailTemplateSubjectRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("TemplateName")
                    .Column<string>("Culture")
                    .Column<string>("Subject")
                );

            // Migration #95.

            SchemaBuilder.AlterTable(typeof (CommonSettingsRecord).Name,
                table => table.AddColumn<string>("CashOnDeliveryAvailabilityMessage"));
            //
            // Tab names for payment methods
            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("CashDelivTabName"));
            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("PayPalTabName"));
            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("MolTabName"));
            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("CreditCardTabName"));
            // Notes for payment methods
            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("CashDelivNote"));
            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("PayPalNote"));
            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("MolNote"));
            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<string>("CreditCardNote"));
            //
            SchemaBuilder.AlterTable(typeof (CommonSettingsRecord).Name,
                table => table.AddColumn<string>("CheckoutPageRightSideContent", c => c.Unlimited()));

            // Migration #96.

            SchemaBuilder.AlterTable(typeof (CurrencyRecord).Name,
                table => table.AddColumn<string>("FlagFileName", c => c.WithLength(1024)));

            SchemaBuilder.CreateTable(typeof (CountryRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<string>("Code", c => c.WithLength(10))
                    .Column<string>("Name", c => c.WithLength(150))
                );

            SchemaBuilder.CreateTable(typeof (LinkCountryCurrencyRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("CurrencyRecord_Id")
                    .Column<int>("CountryRecord_Id")
                );

            SchemaBuilder.CreateTable(typeof (LinkCountryCultureRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("CultureRecord_Id")
                    .Column<int>("CountryRecord_Id")
                );

            SchemaBuilder.CreateForeignKey("LinkCountryCurrency_Currency", "LinkCountryCurrencyRecord",
                new[] {"CurrencyRecord_Id"}, "CountryRecord", new[] {"Id"});

            SchemaBuilder.CreateForeignKey("LinkCountryCurrency_Country", "LinkCountryCurrencyRecord",
                new[] {"CountryRecord_Id"}, "CountryRecord", new[] {"Id"});

            SchemaBuilder.CreateForeignKey("LinkCountryCulture_Culture", "LinkCountryCultureRecord",
                new[] {"CultureRecord_Id"}, "CountryRecord", new[] {"Id"});

            SchemaBuilder.CreateForeignKey("LinkCountryCulture_Country", "LinkCountryCultureRecord",
                new[] {"CountryRecord_Id"}, "CountryRecord", new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<int>("CountryRecord_Id", c => c.WithDefault(1)));

            SchemaBuilder.CreateForeignKey("Campaign_Currency", "CampaignRecord",
                new[] {"CountryRecord_Id"}, "CountryRecord", new[] {"Id"});

            //TODO: (auth:keinlekan) Удалить колонку после того, как заработает полностью новая логика по привязке к странам
            //SchemaBuilder.AlterTable(typeof(CampaignRecord).Name, table => table.DropColumn("CampaignCulture"));

            SchemaBuilder.AlterTable(typeof (CommonSettingsRecord).Name,
                table => table.AddColumn<int>("CountryRecord_Id", c => c.WithDefault(1)));

            SchemaBuilder.CreateForeignKey("CommonSettings_Currency", "CommonSettingsRecord",
                new[] {"CountryRecord_Id"}, "CountryRecord", new[] {"Id"});

            //TODO: (auth:keinlekan) Удалить колонку после того, как заработает полностью новая логика по привязке к странам
            //SchemaBuilder.AlterTable(typeof(CommonSettingsRecord).Name, table => table.DropColumn("CommonCulture"));

            SchemaBuilder.AlterTable(typeof (PaymentSettingsRecord).Name,
                table => table.AddColumn<int>("CountryRecord_Id", c => c.WithDefault(1)));

            SchemaBuilder.CreateForeignKey("PaymentSettings_Currency", "PaymentSettingsRecord",
                new[] {"CountryRecord_Id"}, "CountryRecord", new[] {"Id"});

            //TODO: (auth:keinlekan) Удалить колонку после того, как заработает полностью новая логика по привязке к странам
            //SchemaBuilder.AlterTable(typeof(CommonSettingsRecord).Name, table => table.DropColumn("CommonCulture"));

            SchemaBuilder.AlterTable(typeof (TeeyootUserPartRecord).Name,
                table => table.AddColumn<int>("CurrencyRecord_Id"));

            SchemaBuilder.CreateForeignKey("TeeyootUserPartRecord_CurrencyRecord", "TeeyootUserPartRecord",
                new[] {"CurrencyRecord_Id"}, "CurrencyRecord", new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (PromotionRecord).Name,
                table => table.AddColumn<DateTime>("Created", c => c.Nullable()));

            SchemaBuilder.AlterTable(typeof (PromotionRecord).Name,
                table => table.AddColumn<int>("CampaignId", c => c.Nullable()));


            SchemaBuilder.AlterTable(typeof (CampaignCategoriesRecord).Name,
                table => table.AddColumn<int>("CountryRecord_Id", c => c.WithDefault(1)));

            SchemaBuilder.CreateForeignKey("CampaignCategories_Currency", "CampaignCategoriesRecord",
                new[] {"CountryRecord_Id"}, "CountryRecord", new[] {"Id"});

            //TODO: (auth:keinlekan) Удалить колонку после того, как заработает полностью новая логика по привязке к странам
            //SchemaBuilder.AlterTable(typeof(CampaignCategoriesRecord).Name, table => table.DropColumn("CountryRecord_Id"));

            SchemaBuilder.AlterTable(typeof (CurrencyRecord).Name,
                table => table.AddColumn<double>("PriceBuyers", c => c.WithDefault(1)));

            SchemaBuilder.AlterTable(typeof (CurrencyRecord).Name,
                table => table.AddColumn<double>("PriceSellers", c => c.WithDefault(1)));

            SchemaBuilder.AlterTable(typeof (CurrencyRecord).Name,
                table => table.AddColumn<bool>("IsConvert", c => c.WithDefault(false)));

            ContentDefinitionManager.AlterPartDefinition(
                "AllCountryWidgetPart",
                builder => builder.Attachable());

            ContentDefinitionManager.AlterTypeDefinition(
                "AllCountryWidget",
                cfg => cfg
                    .WithPart("AllCountryWidgetPart")
                    .WithPart("CommonPart")
                    .WithPart("WidgetPart")
                    .WithSetting("Stereotype", "Widget")
                );

            // Default is used only to set existing records Country field to 1 before applying notnull constaraint.
            SchemaBuilder.AlterTable(typeof (DeliverySettingRecord).Name,
                table => table.AddColumn<int>("Country_id", c => c.WithDefault(1).NotNull()));
            SchemaBuilder.CreateForeignKey("DeliverySettings_Country",
                typeof (DeliverySettingRecord).Name, new[] {"Country_id"},
                typeof (CountryRecord).Name, new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (DeliverySettingRecord).Name,
                table => table.AddColumn<double>("PostageCost"));

            SchemaBuilder.AlterTable(typeof (DeliverySettingRecord).Name,
                table => table.AddColumn<double>("CodCost"));

            // Dropping the default constarint for Country field
            SchemaBuilder.ExecuteSql(
                @"declare @table_name nvarchar(256)
                    declare @col_name nvarchar(256)
                    declare @Command  nvarchar(1000)

                    set @table_name = N'Teeyoot_Module_DeliverySettingRecord'
                    set @col_name = N'Country_id'

                    select @Command = 'ALTER TABLE ' + @table_name + ' drop constraint ' + d.name
                     from sys.tables t   
                      join    sys.default_constraints d       
                       on d.parent_object_id = t.object_id  
                      join    sys.columns c      
                       on c.object_id = t.object_id      
                        and c.column_id = d.parent_column_id
                     where t.name = @table_name
                      and c.name = @col_name

                    execute (@Command)"
                );

            SchemaBuilder.CreateTable(typeof (DeliveryInternationalSettingRecord).Name,
                table => table
                    .Column<int>("Id", column => column.PrimaryKey().Identity())
                    .Column<int>("CountryFrom_Id", c => c.NotNull())
                    .Column<int>("CountryTo_Id", c => c.NotNull())
                );

            SchemaBuilder.CreateForeignKey("FK_DeliveryInternationalSetting_CountryFrom",
                typeof (DeliveryInternationalSettingRecord).Name, new[] {"CountryFrom_Id"},
                typeof (CountryRecord).Name, new[] {"Id"});

            SchemaBuilder.CreateForeignKey("FK_DeliveryInternationalSetting_CountryTo",
                typeof (DeliveryInternationalSettingRecord).Name, new[] {"CountryTo_Id"},
                typeof (CountryRecord).Name, new[] {"Id"});

            SchemaBuilder.AlterTable(typeof (PayoutRecord).Name,
                table => table.AddColumn<bool>("IsProfitPaid", c => c.WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (PayoutRecord).Name,
                table => table.AddColumn<bool>("IsCampiaign", c => c.WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (PayoutRecord).Name,
                table => table.AddColumn<bool>("IsOrder", c => c.WithDefault(false)));

            SchemaBuilder.AlterTable(typeof (CampaignRecord).Name,
                table => table.AddColumn<int>("CurrencyRecord_Id"));

            SchemaBuilder.CreateForeignKey("FK_Campaign_Currency",
                typeof (CampaignRecord).Name, new[] {"CurrencyRecord_Id"},
                typeof (CurrencyRecord).Name, new[] {"Id"});

            SchemaBuilder.ExecuteSql(@"
                update 
                [dbo].[Teeyoot_Module_CampaignRecord]
                set CurrencyRecord_Id = 1
                ");

            SchemaBuilder.AlterTable(typeof (PromotionRecord).Name,
                table => table.AddColumn<int>("CurrencyRecord_Id"));

            SchemaBuilder.CreateForeignKey("Promotion_Currency",
                "PromotionRecord", new[] {"CurrencyRecord_Id"},
                "CurrencyRecord", new[] {"Id"});

            return 113;
        }
示例#2
0
        public int UpdateFrom52()
        {
            SchemaBuilder.DropTable(typeof (CommonSettingsRecord).Name);

            SchemaBuilder.CreateTable(typeof (CommonSettingsRecord).Name, table => table
                .Column<int>("Id", column => column.PrimaryKey().Identity())
                .Column<bool>("DoNotAcceptAnyNewCampaigns", column => column.NotNull().WithDefault(false))
                .Column<int>("ColoursPerPrint", column => column.NotNull().WithDefault(0)));

            var commonSettings = new CommonSettingsRecord();
            _commonSettingsRepository.Create(commonSettings);

            return 53;
        }