protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_ReleaseBatchItem_ReleaseBatch_ReleaseBatchId", schema: "kraken", table: "ReleaseBatchItem");
     migrationBuilder.DropForeignKey(name: "FK_ReleaseBatchLogo_ReleaseBatch_ReleaseBatchId", schema: "kraken", table: "ReleaseBatchLogo");
     migrationBuilder.DropColumn(name: "IsLocked", schema: "kraken", table: "ReleaseBatch");
     migrationBuilder.DropColumn(name: "LockComment", schema: "kraken", table: "ReleaseBatch");
     migrationBuilder.DropColumn(name: "LockUserName", schema: "kraken", table: "ReleaseBatch");
     migrationBuilder.AddForeignKey(
         name: "FK_ReleaseBatchItem_ReleaseBatch_ReleaseBatchId",
         schema: "kraken",
         table: "ReleaseBatchItem",
         column: "ReleaseBatchId",
         principalSchema: "kraken",
         principalTable: "ReleaseBatch",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_ReleaseBatchLogo_ReleaseBatch_ReleaseBatchId",
         schema: "kraken",
         table: "ReleaseBatchLogo",
         column: "ReleaseBatchId",
         principalSchema: "kraken",
         principalTable: "ReleaseBatch",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Category_Article", table: "Article");
     migrationBuilder.DropForeignKey(name: "FK_Section_Category", table: "Category");
     migrationBuilder.AlterColumn<int>(
         name: "SectionId",
         table: "Section",
         nullable: false)
         .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
     migrationBuilder.AddColumn<bool>(
         name: "IsDeleted",
         table: "Section",
         nullable: false,
         defaultValue: false);
     migrationBuilder.AddForeignKey(
         name: "FK_Category_Article",
         table: "Article",
         column: "CategoryId",
         principalTable: "Category",
         principalColumn: "CategoryId",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Section_Category",
         table: "Category",
         column: "SectionId",
         principalTable: "Section",
         principalColumn: "SectionId",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_MenuItem_Category_CategoryId", table: "MenuItem");
     migrationBuilder.DropForeignKey(name: "FK_OrderItem_Order_OrderId", table: "OrderItem");
     migrationBuilder.AlterColumn<int>(
         name: "Id",
         table: "OrderItem",
         nullable: false)
         .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
     migrationBuilder.AddColumn<decimal>(
         name: "Total",
         table: "Order",
         nullable: false,
         defaultValue: 0m);
     migrationBuilder.AddForeignKey(
         name: "FK_MenuItem_Category_CategoryId",
         table: "MenuItem",
         column: "CategoryId",
         principalTable: "Category",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_OrderItem_Order_OrderId",
         table: "OrderItem",
         column: "OrderId",
         principalTable: "Order",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "DisplayName",
                table: "TestClasses",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_Commits_ProjectId",
                table: "Commits",
                column: "ProjectId");

            migrationBuilder.CreateIndex(
                name: "IX_Commits_UserId",
                table: "Commits",
                column: "UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_Commits_Projects_ProjectId",
                table: "Commits",
                column: "ProjectId",
                principalTable: "Projects",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Commits_Users_UserId",
                table: "Commits",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Category_Article", table: "Article");
     migrationBuilder.AlterColumn<string>(
         name: "Url",
         table: "Section",
         nullable: false);
     migrationBuilder.AlterColumn<string>(
         name: "Title",
         table: "Section",
         nullable: false);
     migrationBuilder.AlterColumn<string>(
         name: "Url",
         table: "Category",
         nullable: false);
     migrationBuilder.AlterColumn<string>(
         name: "Title",
         table: "Category",
         nullable: false);
     migrationBuilder.AddForeignKey(
         name: "FK_Category_Article",
         table: "Article",
         column: "CategoryId",
         principalTable: "Category",
         principalColumn: "CategoryId",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Section_Category",
         table: "Category",
         column: "SectionId",
         principalTable: "Section",
         principalColumn: "SectionId",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.CreateTable(
         name: "Event",
         columns: table => new
         {
             ID = table.Column<int>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             CompleteAddress = table.Column<string>(nullable: true),
             EventEnd = table.Column<DateTime>(nullable: false),
             EventStart = table.Column<DateTime>(nullable: false),
             IsCurrent = table.Column<bool>(nullable: false),
             Name = table.Column<string>(nullable: true),
             SocialMediaHashtag = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Event", x => x.ID);
         });
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_OpeningHours_Shop_ShopId", table: "OpeningHours");
     migrationBuilder.DropForeignKey(name: "FK_Prize_Shop_ShopId", table: "Prize");
     migrationBuilder.DropForeignKey(name: "FK_Puzzle_Shop_ShopId", table: "Puzzle");
     migrationBuilder.AddForeignKey(
         name: "FK_OpeningHours_Shop_ShopId",
         table: "OpeningHours",
         column: "ShopId",
         principalTable: "Shop",
         principalColumn: "ID",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_Prize_Shop_ShopId",
         table: "Prize",
         column: "ShopId",
         principalTable: "Shop",
         principalColumn: "ID",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_Puzzle_Shop_ShopId",
         table: "Puzzle",
         column: "ShopId",
         principalTable: "Shop",
         principalColumn: "ID",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_PriceHistory_Stock_StockId", table: "PriceHistory");
     migrationBuilder.DropForeignKey(name: "FK_Txn_Stock_StockId", table: "Txn");
     migrationBuilder.AlterColumn<decimal>(
         name: "Open",
         table: "PriceHistory",
         nullable: false);
     migrationBuilder.AlterColumn<decimal>(
         name: "Low",
         table: "PriceHistory",
         nullable: false);
     migrationBuilder.AlterColumn<decimal>(
         name: "High",
         table: "PriceHistory",
         nullable: false);
     migrationBuilder.AlterColumn<decimal>(
         name: "Close",
         table: "PriceHistory",
         nullable: false);
     migrationBuilder.AddForeignKey(
         name: "FK_PriceHistory_Stock_StockId",
         table: "PriceHistory",
         column: "StockId",
         principalTable: "Stock",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_Txn_Stock_StockId",
         table: "Txn",
         column: "StockId",
         principalTable: "Stock",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Resource_ResourceType_ResourceTypeId", table: "Resource");
     migrationBuilder.DropForeignKey(name: "FK_Resource_Supplier_SupplierId", table: "Resource");
     migrationBuilder.DropForeignKey(name: "FK_Supplier_Address_AddressId", table: "Supplier");
     migrationBuilder.AddForeignKey(
         name: "FK_Resource_ResourceType_ResourceTypeId",
         table: "Resource",
         column: "ResourceTypeId",
         principalTable: "ResourceType",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Resource_Supplier_SupplierId",
         table: "Resource",
         column: "SupplierId",
         principalTable: "Supplier",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Supplier_Address_AddressId",
         table: "Supplier",
         column: "AddressId",
         principalTable: "Address",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Photo_Album_AlbumId", table: "Photo");
     migrationBuilder.DropForeignKey(name: "FK_UserRole_Role_RoleId", table: "UserRole");
     migrationBuilder.DropForeignKey(name: "FK_UserRole_User_UserId", table: "UserRole");
     migrationBuilder.AddColumn<string>(
         name: "Throwaway",
         table: "Album",
         nullable: true);
     migrationBuilder.AddForeignKey(
         name: "FK_Photo_Album_AlbumId",
         table: "Photo",
         column: "AlbumId",
         principalTable: "Album",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_UserRole_Role_RoleId",
         table: "UserRole",
         column: "RoleId",
         principalTable: "Role",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_UserRole_User_UserId",
         table: "UserRole",
         column: "UserId",
         principalTable: "User",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Produto_Categoria_CategoriaID", table: "Produto");
     migrationBuilder.DropForeignKey(name: "FK_ProdutoVenda_Produto_ProdutoID", table: "ProdutoVenda");
     migrationBuilder.DropForeignKey(name: "FK_ProdutoVenda_Venda_VendaID", table: "ProdutoVenda");
     migrationBuilder.DropColumn(name: "Discriminator", table: "Usuario");
     migrationBuilder.DropColumn(name: "CPF", table: "Usuario");
     migrationBuilder.DropColumn(name: "CNPJ", table: "Usuario");
     migrationBuilder.AddForeignKey(
         name: "FK_Produto_Categoria_CategoriaID",
         table: "Produto",
         column: "CategoriaID",
         principalTable: "Categoria",
         principalColumn: "ID",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_ProdutoVenda_Produto_ProdutoID",
         table: "ProdutoVenda",
         column: "ProdutoID",
         principalTable: "Produto",
         principalColumn: "ID",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_ProdutoVenda_Venda_VendaID",
         table: "ProdutoVenda",
         column: "VendaID",
         principalTable: "Venda",
         principalColumn: "ID",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_SkillToTag_Skill_SkillId", schema: "skill", table: "SkillToTag");
     migrationBuilder.DropForeignKey(name: "FK_SkillToTag_SkillTag_TagId", schema: "skill", table: "SkillToTag");
     migrationBuilder.DropTable(name: "Comment", schema: "blog");
     migrationBuilder.DropTable(name: "Entry", schema: "blog");
     migrationBuilder.AddForeignKey(
         name: "FK_SkillToTag_Skill_SkillId",
         schema: "skill",
         table: "SkillToTag",
         column: "SkillId",
         principalSchema: "skill",
         principalTable: "Skill",
         principalColumn: "SkillId",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_SkillToTag_SkillTag_TagId",
         schema: "skill",
         table: "SkillToTag",
         column: "TagId",
         principalSchema: "skill",
         principalTable: "Tag",
         principalColumn: "TagId",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Photo_Album_AlbumId", table: "Photo");
     migrationBuilder.DropForeignKey(name: "FK_UserRole_Role_RoleId", table: "UserRole");
     migrationBuilder.DropForeignKey(name: "FK_UserRole_User_UserId", table: "UserRole");
     migrationBuilder.DropColumn(name: "Throwaway", table: "Album");
     migrationBuilder.AddForeignKey(
         name: "FK_Photo_Album_AlbumId",
         table: "Photo",
         column: "AlbumId",
         principalTable: "Album",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_UserRole_Role_RoleId",
         table: "UserRole",
         column: "RoleId",
         principalTable: "Role",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_UserRole_User_UserId",
         table: "UserRole",
         column: "UserId",
         principalTable: "User",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
Esempio n. 14
0
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Prize_Shop_ShopId", table: "Prize");
     migrationBuilder.DropForeignKey(name: "FK_Puzzle_Shop_ShopId", table: "Puzzle");
     migrationBuilder.AlterColumn<TimeSpan>(
         name: "Opening2",
         table: "OpeningHours",
         nullable: true);
     migrationBuilder.AlterColumn<TimeSpan>(
         name: "Opening1",
         table: "OpeningHours",
         nullable: true);
     migrationBuilder.AlterColumn<TimeSpan>(
         name: "Closing2",
         table: "OpeningHours",
         nullable: true);
     migrationBuilder.AlterColumn<TimeSpan>(
         name: "Closing1",
         table: "OpeningHours",
         nullable: true);
     migrationBuilder.AddForeignKey(
         name: "FK_Prize_Shop_ShopId",
         table: "Prize",
         column: "ShopId",
         principalTable: "Shop",
         principalColumn: "ID",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Puzzle_Shop_ShopId",
         table: "Puzzle",
         column: "ShopId",
         principalTable: "Shop",
         principalColumn: "ID",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Student_Teacher_TeacherID", table: "Student");
     migrationBuilder.CreateTable(
         name: "School",
         columns: table => new
         {
             ID = table.Column<long>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             Name = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_School", x => x.ID);
         });
     migrationBuilder.AddColumn<long>(
         name: "SchoolID",
         table: "Teacher",
         nullable: false,
         defaultValue: 0L);
     migrationBuilder.AddForeignKey(
         name: "FK_Student_Teacher_TeacherID",
         table: "Student",
         column: "TeacherID",
         principalTable: "Teacher",
         principalColumn: "ID",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Teacher_School_SchoolID",
         table: "Teacher",
         column: "SchoolID",
         principalTable: "School",
         principalColumn: "ID",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Character_Planet_HomePlanetId", table: "Character");
     migrationBuilder.CreateTable(
         name: "Species",
         columns: table => new
         {
             Id = table.Column<Guid>(nullable: false),
             Description = table.Column<string>(nullable: true),
             Name = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Species", x => x.Id);
         });
     migrationBuilder.AddColumn<Guid>(
         name: "SpeciesId",
         table: "Character",
         nullable: true);
     migrationBuilder.AddForeignKey(
         name: "FK_Character_Planet_HomePlanetId",
         table: "Character",
         column: "HomePlanetId",
         principalTable: "Planet",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Character_Species_SpeciesId",
         table: "Character",
         column: "SpeciesId",
         principalTable: "Species",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateIndex(
                name: "IX_UserQuestionData_QuestionId",
                table: "UserQuestionData",
                column: "QuestionId");

            migrationBuilder.CreateIndex(
                name: "IX_UserQuestionData_UserId",
                table: "UserQuestionData",
                column: "UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_UserQuestionData_Questions_QuestionId",
                table: "UserQuestionData",
                column: "QuestionId",
                principalTable: "Questions",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_UserQuestionData_Users_UserId",
                table: "UserQuestionData",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.DropColumn(name: "City", table: "AspNetUsers");
     migrationBuilder.DropColumn(name: "State", table: "AspNetUsers");
     migrationBuilder.DropTable("ToDo");
     migrationBuilder.AlterColumn<string>(
         name: "UserId",
         table: "AspNetUserLogins",
         nullable: true);
     migrationBuilder.AlterColumn<string>(
         name: "UserId",
         table: "AspNetUserClaims",
         nullable: true);
     migrationBuilder.AlterColumn<string>(
         name: "RoleId",
         table: "AspNetRoleClaims",
         nullable: true);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.CreateTable(
         name: "Announcement",
         columns: table => new
         {
             ID = table.Column<int>(nullable: false),
             ExpiresOn = table.Column<DateTime>(nullable: false),
             Message = table.Column<string>(nullable: true),
             PublishOn = table.Column<DateTime>(nullable: false),
             Rank = table.Column<int>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Announcement", x => x.ID);
         });
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Resource_ResourceType_ResourceTypeId", table: "Resource");
     migrationBuilder.DropForeignKey(name: "FK_Resource_Supplier_SupplierId", table: "Resource");
     migrationBuilder.CreateTable(
         name: "HousingDetail",
         columns: table => new
         {
             Id = table.Column<int>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             OtherShelterInfo = table.Column<string>(nullable: true),
             PatientHasShelter = table.Column<bool>(nullable: false),
             ShelterIsIndoors = table.Column<bool>(nullable: false),
             ShelterIsSafe = table.Column<bool>(nullable: false),
             ShelterLocation = table.Column<string>(nullable: true),
             ShelterWithFamily = table.Column<bool>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_HousingDetail", x => x.Id);
         });
     migrationBuilder.CreateTable(
         name: "QuestionAnswer",
         columns: table => new
         {
             Id = table.Column<int>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             AnswerBool = table.Column<bool>(nullable: false),
             AnswerString = table.Column<string>(nullable: true),
             QuestionText = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_QuestionAnswer", x => x.Id);
         });
     migrationBuilder.AddForeignKey(
         name: "FK_Resource_ResourceType_ResourceTypeId",
         table: "Resource",
         column: "ResourceTypeId",
         principalTable: "ResourceType",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Resource_Supplier_SupplierId",
         table: "Resource",
         column: "SupplierId",
         principalTable: "Supplier",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Supplier_Address_AddressId",
         table: "Supplier",
         column: "AddressId",
         principalTable: "Address",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.AddColumn<string>(
         name: "CompanyName",
         table: "Speaker",
         nullable: true);
     migrationBuilder.AddColumn<string>(
         name: "SponsorLevel",
         table: "Speaker",
         nullable: true);
     migrationBuilder.AlterColumn<int>(
         name: "ID",
         table: "Announcement",
         nullable: false)
         .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.CreateTable(
         name: "Products",
         columns: table => new
         {
             ID = table.Column<int>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             PreviewUrl = table.Column<string>(nullable: true),
             Title = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Products", x => x.ID);
         });
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
Esempio n. 23
0
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.CreateTable(
         name: "Project",
         columns: table => new
         {
             Id = table.Column<int>(nullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             Name = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Project", x => x.Id);
         });
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
Esempio n. 24
0
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.AlterColumn<string>(
         name: "UserId",
         table: "AspNetUserLogins",
         nullable: false);
     migrationBuilder.AlterColumn<string>(
         name: "UserId",
         table: "AspNetUserClaims",
         nullable: false);
     migrationBuilder.AlterColumn<string>(
         name: "RoleId",
         table: "AspNetRoleClaims",
         nullable: false);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_ChirpPost_ChirpUser_UserId", table: "ChirpPost");
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ChirpUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ChirpUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ChirpUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.DropColumn(name: "HasProfilePicture", table: "AspNetUsers");
     migrationBuilder.AlterColumn<int>(
         name: "UserId",
         table: "ChirpPost",
         nullable: false);
     migrationBuilder.AlterColumn<DateTime>(
         name: "PostTime",
         table: "ChirpPost",
         nullable: false);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ChirpUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ChirpUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ChirpUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_TimeLog_Client_ClientId", table: "TimeLog");
     migrationBuilder.DropForeignKey(name: "FK_TimeLog_User_UserId", table: "TimeLog");
     migrationBuilder.CreateTable(
         name: "Invoice",
         columns: table => new
         {
             Id = table.Column<int>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             ClientId = table.Column<int>(nullable: true),
             From = table.Column<DateTime>(nullable: false),
             InvoiceNumber = table.Column<int>(nullable: false),
             Paid = table.Column<bool>(nullable: false),
             To = table.Column<DateTime>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Invoice", x => x.Id);
             table.ForeignKey(
                 name: "FK_Invoice_Client_ClientId",
                 column: x => x.ClientId,
                 principalTable: "Client",
                 principalColumn: "Id",
                 onDelete: ReferentialAction.Restrict);
         });
     migrationBuilder.AddColumn<int>(
         name: "OnInvoiceId",
         table: "TimeLog",
         nullable: true);
     migrationBuilder.AddForeignKey(
         name: "FK_TimeLog_Client_ClientId",
         table: "TimeLog",
         column: "ClientId",
         principalTable: "Client",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_TimeLog_Invoice_OnInvoiceId",
         table: "TimeLog",
         column: "OnInvoiceId",
         principalTable: "Invoice",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_TimeLog_User_UserId",
         table: "TimeLog",
         column: "UserId",
         principalTable: "User",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.AddColumn<string>(
         name: "LastName",
         table: "User",
         nullable: true);
     migrationBuilder.AddColumn<DateTime>(
         name: "birthdate",
         table: "User",
         nullable: false,
         defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.DropColumn(name: "ChineseSentenceExample", table: "Vocabulary");
     migrationBuilder.AddColumn<string>(
         name: "Example",
         table: "Vocabulary",
         nullable: true);
     migrationBuilder.AddColumn<string>(
         name: "Pinyin",
         table: "Vocabulary",
         nullable: true);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.AlterColumn<int>(
         name: "Tolerance",
         table: "Resistor",
         nullable: false);
     migrationBuilder.AddColumn<int>(
         name: "Value",
         table: "Resistor",
         nullable: false,
         defaultValue: 0);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Session_Speaker_SpeakerID", table: "Session");
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.AddForeignKey(
         name: "FK_Session_Speaker_SpeakerID",
         table: "Session",
         column: "SpeakerID",
         principalTable: "Speaker",
         principalColumn: "ID",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AspNetRoleClaims_Role_RoleId1",
                table: "AspNetRoleClaims");

            migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserClaims_AspNetUsers_UserId1",
                table: "AspNetUserClaims");

            migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserRoles_Role_RoleId1",
                table: "AspNetUserRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserRoles_AspNetUsers_UserId1",
                table: "AspNetUserRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserTokens_AspNetUsers_UserId1",
                table: "AspNetUserTokens");

            migrationBuilder.DropForeignKey(
                name: "FK_Comments_UserPhotos_UserPhotoId",
                table: "Comments");

            migrationBuilder.DropForeignKey(
                name: "FK_UserPhotos_Activities_ActivityId",
                table: "UserPhotos");

            migrationBuilder.DropTable(
                name: "AppUserUsedPasswords");

            migrationBuilder.DropTable(
                name: "Role");

            migrationBuilder.DropPrimaryKey(
                name: "PK_UserPhotos",
                table: "UserPhotos");

            migrationBuilder.DropIndex(
                name: "IX_UserPhotos_ActivityId",
                table: "UserPhotos");

            migrationBuilder.DropIndex(
                name: "IX_AspNetUserTokens_UserId1",
                table: "AspNetUserTokens");

            migrationBuilder.DropIndex(
                name: "IX_AspNetUserRoles_RoleId1",
                table: "AspNetUserRoles");

            migrationBuilder.DropIndex(
                name: "IX_AspNetUserRoles_UserId1",
                table: "AspNetUserRoles");

            migrationBuilder.DropIndex(
                name: "IX_AspNetUserClaims_UserId1",
                table: "AspNetUserClaims");

            migrationBuilder.DropIndex(
                name: "IX_AspNetRoleClaims_RoleId1",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "alakyId",
                table: "UserPhotos");

            migrationBuilder.DropColumn(
                name: "ActivityId",
                table: "UserPhotos");

            migrationBuilder.DropColumn(
                name: "AccessTokenExpiresDateTime",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "AccessTokenHash",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "CreatedByBrowserName",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "CreatedByIp",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "CreatedByUserId",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "CreatedDateTime",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "Id",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "ModifiedByBrowserName",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "ModifiedByIp",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "ModifiedByUserId",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "ModifiedDateTime",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "RefreshTokenExpiresDateTime",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "RefreshTokenIdHash",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "RefreshTokenIdHashSource",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "UserId1",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "Discriminator",
                table: "AspNetUserTokens");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "AspNetUsers");

            migrationBuilder.DropColumn(
                name: "SerialNumber",
                table: "AspNetUsers");

            migrationBuilder.DropColumn(
                name: "CreatedByBrowserName",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "CreatedByIp",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "CreatedByUserId",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "CreatedDateTime",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "ModifiedByBrowserName",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "ModifiedByIp",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "ModifiedByUserId",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "ModifiedDateTime",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "RoleId1",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "UserId1",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "Discriminator",
                table: "AspNetUserRoles");

            migrationBuilder.DropColumn(
                name: "CreatedByBrowserName",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "CreatedByIp",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "CreatedByUserId",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "CreatedDateTime",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "ModifiedByBrowserName",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "ModifiedByIp",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "ModifiedByUserId",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "ModifiedDateTime",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "UserId1",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "Discriminator",
                table: "AspNetUserClaims");

            migrationBuilder.DropColumn(
                name: "CreatedByBrowserName",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "CreatedByIp",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "CreatedByUserId",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "CreatedDateTime",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "ModifiedByBrowserName",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "ModifiedByIp",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "ModifiedByUserId",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "ModifiedDateTime",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "RoleId1",
                table: "AspNetRoleClaims");

            migrationBuilder.DropColumn(
                name: "Discriminator",
                table: "AspNetRoleClaims");

            migrationBuilder.AddColumn <int>(
                name: "Id",
                table: "UserPhotos",
                type: "int",
                nullable: false,
                defaultValue: 0)
            .Annotation("SqlServer:Identity", "1, 1");

            migrationBuilder.AlterColumn <int>(
                name: "UserPhotoId",
                table: "Comments",
                type: "int",
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ImagePath",
                table: "Activities",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_UserPhotos",
                table: "UserPhotos",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Comments_UserPhotos_UserPhotoId",
                table: "Comments",
                column: "UserPhotoId",
                principalTable: "UserPhotos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
Esempio n. 32
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "BookAuthor",
                table: "BookCheckedOutModel");

            migrationBuilder.DropColumn(
                name: "BookTitle",
                table: "BookCheckedOutModel");

            migrationBuilder.RenameColumn(
                name: "BookYear",
                table: "BookCheckedOutModel",
                newName: "UserId");

            migrationBuilder.RenameColumn(
                name: "BookToBeReturned",
                table: "BookCheckedOutModel",
                newName: "ReturnDate");

            migrationBuilder.RenameColumn(
                name: "BookCheckedOutByLibrarian",
                table: "BookCheckedOutModel",
                newName: "LibrarianId");

            migrationBuilder.RenameColumn(
                name: "BookCheckedOut",
                table: "BookCheckedOutModel",
                newName: "IssueDate");

            migrationBuilder.RenameColumn(
                name: "BookBorrowedByUser",
                table: "BookCheckedOutModel",
                newName: "BookId");

            migrationBuilder.RenameColumn(
                name: "BookCheckedOutId",
                table: "BookCheckedOutModel",
                newName: "CopyId");

            migrationBuilder.DropColumn(
                name: "UserDOB",
                table: "UserModel");

            migrationBuilder.AddColumn <DateTime>(
                name: "UserDOB",
                table: "UserModel",
                type: "datetime2",
                nullable: false);

            migrationBuilder.AddColumn <int>(
                name: "BookModelBookId",
                table: "BookCheckedOutModel",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "LibrarianModelLibrarianId",
                table: "BookCheckedOutModel",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "UserModelUserId",
                table: "BookCheckedOutModel",
                type: "int",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_BookCheckedOutModel_BookModelBookId",
                table: "BookCheckedOutModel",
                column: "BookModelBookId");

            migrationBuilder.CreateIndex(
                name: "IX_BookCheckedOutModel_LibrarianModelLibrarianId",
                table: "BookCheckedOutModel",
                column: "LibrarianModelLibrarianId");

            migrationBuilder.CreateIndex(
                name: "IX_BookCheckedOutModel_UserModelUserId",
                table: "BookCheckedOutModel",
                column: "UserModelUserId");

            migrationBuilder.AddForeignKey(
                name: "FK_BookCheckedOutModel_BookModel_BookModelBookId",
                table: "BookCheckedOutModel",
                column: "BookModelBookId",
                principalTable: "BookModel",
                principalColumn: "BookId",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_BookCheckedOutModel_LibrarianModel_LibrarianModelLibrarianId",
                table: "BookCheckedOutModel",
                column: "LibrarianModelLibrarianId",
                principalTable: "LibrarianModel",
                principalColumn: "LibrarianId",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_BookCheckedOutModel_UserModel_UserModelUserId",
                table: "BookCheckedOutModel",
                column: "UserModelUserId",
                principalTable: "UserModel",
                principalColumn: "UserId",
                onDelete: ReferentialAction.Restrict);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Comments_UserPhotos_UserPhotoId",
                table: "Comments");

            migrationBuilder.DropPrimaryKey(
                name: "PK_UserPhotos",
                table: "UserPhotos");

            migrationBuilder.DropColumn(
                name: "Id",
                table: "UserPhotos");

            migrationBuilder.DropColumn(
                name: "ImagePath",
                table: "Activities");

            migrationBuilder.AddColumn <string>(
                name: "alakyId",
                table: "UserPhotos",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <Guid>(
                name: "ActivityId",
                table: "UserPhotos",
                nullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "UserPhotoId",
                table: "Comments",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int",
                oldNullable: true);

            migrationBuilder.AddColumn <DateTimeOffset>(
                name: "AccessTokenExpiresDateTime",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "AccessTokenHash",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "CreatedByBrowserName",
                table: "AspNetUserTokens",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "CreatedByIp",
                table: "AspNetUserTokens",
                maxLength: 255,
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "CreatedByUserId",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <DateTime>(
                name: "CreatedDateTime",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "Id",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ModifiedByBrowserName",
                table: "AspNetUserTokens",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ModifiedByIp",
                table: "AspNetUserTokens",
                maxLength: 255,
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "ModifiedByUserId",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <DateTime>(
                name: "ModifiedDateTime",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <DateTimeOffset>(
                name: "RefreshTokenExpiresDateTime",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "RefreshTokenIdHash",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "RefreshTokenIdHashSource",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "UserId1",
                table: "AspNetUserTokens",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "Discriminator",
                table: "AspNetUserTokens",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <bool>(
                name: "IsActive",
                table: "AspNetUsers",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn <string>(
                name: "SerialNumber",
                table: "AspNetUsers",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "CreatedByBrowserName",
                table: "AspNetUserRoles",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "CreatedByIp",
                table: "AspNetUserRoles",
                maxLength: 255,
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "CreatedByUserId",
                table: "AspNetUserRoles",
                nullable: true);

            migrationBuilder.AddColumn <DateTime>(
                name: "CreatedDateTime",
                table: "AspNetUserRoles",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ModifiedByBrowserName",
                table: "AspNetUserRoles",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ModifiedByIp",
                table: "AspNetUserRoles",
                maxLength: 255,
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "ModifiedByUserId",
                table: "AspNetUserRoles",
                nullable: true);

            migrationBuilder.AddColumn <DateTime>(
                name: "ModifiedDateTime",
                table: "AspNetUserRoles",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "RoleId1",
                table: "AspNetUserRoles",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "UserId1",
                table: "AspNetUserRoles",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "Discriminator",
                table: "AspNetUserRoles",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <string>(
                name: "CreatedByBrowserName",
                table: "AspNetUserClaims",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "CreatedByIp",
                table: "AspNetUserClaims",
                maxLength: 255,
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "CreatedByUserId",
                table: "AspNetUserClaims",
                nullable: true);

            migrationBuilder.AddColumn <DateTime>(
                name: "CreatedDateTime",
                table: "AspNetUserClaims",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ModifiedByBrowserName",
                table: "AspNetUserClaims",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ModifiedByIp",
                table: "AspNetUserClaims",
                maxLength: 255,
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "ModifiedByUserId",
                table: "AspNetUserClaims",
                nullable: true);

            migrationBuilder.AddColumn <DateTime>(
                name: "ModifiedDateTime",
                table: "AspNetUserClaims",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "UserId1",
                table: "AspNetUserClaims",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "Discriminator",
                table: "AspNetUserClaims",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <string>(
                name: "CreatedByBrowserName",
                table: "AspNetRoleClaims",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "CreatedByIp",
                table: "AspNetRoleClaims",
                maxLength: 255,
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "CreatedByUserId",
                table: "AspNetRoleClaims",
                nullable: true);

            migrationBuilder.AddColumn <DateTime>(
                name: "CreatedDateTime",
                table: "AspNetRoleClaims",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ModifiedByBrowserName",
                table: "AspNetRoleClaims",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ModifiedByIp",
                table: "AspNetRoleClaims",
                maxLength: 255,
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "ModifiedByUserId",
                table: "AspNetRoleClaims",
                nullable: true);

            migrationBuilder.AddColumn <DateTime>(
                name: "ModifiedDateTime",
                table: "AspNetRoleClaims",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "RoleId1",
                table: "AspNetRoleClaims",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "Discriminator",
                table: "AspNetRoleClaims",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddPrimaryKey(
                name: "PK_UserPhotos",
                table: "UserPhotos",
                column: "alakyId");

            migrationBuilder.CreateTable(
                name: "AppUserUsedPasswords",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                HashedPassword        = table.Column <string>(maxLength: 450, nullable: false),
                UserId                = table.Column <string>(nullable: true),
                CreatedByBrowserName  = table.Column <string>(maxLength: 1000, nullable: true),
                CreatedByIp           = table.Column <string>(maxLength: 255, nullable: true),
                CreatedByUserId       = table.Column <int>(nullable: true),
                CreatedDateTime       = table.Column <DateTime>(nullable: true),
                ModifiedByBrowserName = table.Column <string>(maxLength: 1000, nullable: true),
                ModifiedByIp          = table.Column <string>(maxLength: 255, nullable: true),
                ModifiedByUserId      = table.Column <int>(nullable: true),
                ModifiedDateTime      = table.Column <DateTime>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AppUserUsedPasswords", x => x.Id);
                table.ForeignKey(
                    name: "FK_AppUserUsedPasswords_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Role",
                columns: table => new
            {
                Id                    = table.Column <string>(nullable: false),
                Name                  = table.Column <string>(nullable: true),
                NormalizedName        = table.Column <string>(nullable: true),
                ConcurrencyStamp      = table.Column <string>(nullable: true),
                Description           = table.Column <string>(nullable: true),
                CreatedByBrowserName  = table.Column <string>(maxLength: 1000, nullable: true),
                CreatedByIp           = table.Column <string>(maxLength: 255, nullable: true),
                CreatedByUserId       = table.Column <int>(nullable: true),
                CreatedDateTime       = table.Column <DateTime>(nullable: true),
                ModifiedByBrowserName = table.Column <string>(maxLength: 1000, nullable: true),
                ModifiedByIp          = table.Column <string>(maxLength: 255, nullable: true),
                ModifiedByUserId      = table.Column <int>(nullable: true),
                ModifiedDateTime      = table.Column <DateTime>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Role", x => x.Id);
            });

            migrationBuilder.CreateIndex(
                name: "IX_UserPhotos_ActivityId",
                table: "UserPhotos",
                column: "ActivityId");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserTokens_UserId1",
                table: "AspNetUserTokens",
                column: "UserId1");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserRoles_RoleId1",
                table: "AspNetUserRoles",
                column: "RoleId1");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserRoles_UserId1",
                table: "AspNetUserRoles",
                column: "UserId1");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserClaims_UserId1",
                table: "AspNetUserClaims",
                column: "UserId1");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetRoleClaims_RoleId1",
                table: "AspNetRoleClaims",
                column: "RoleId1");

            migrationBuilder.CreateIndex(
                name: "IX_AppUserUsedPasswords_UserId",
                table: "AppUserUsedPasswords",
                column: "UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetRoleClaims_Role_RoleId1",
                table: "AspNetRoleClaims",
                column: "RoleId1",
                principalTable: "Role",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserClaims_AspNetUsers_UserId1",
                table: "AspNetUserClaims",
                column: "UserId1",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserRoles_Role_RoleId1",
                table: "AspNetUserRoles",
                column: "RoleId1",
                principalTable: "Role",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserRoles_AspNetUsers_UserId1",
                table: "AspNetUserRoles",
                column: "UserId1",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserTokens_AspNetUsers_UserId1",
                table: "AspNetUserTokens",
                column: "UserId1",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Comments_UserPhotos_UserPhotoId",
                table: "Comments",
                column: "UserPhotoId",
                principalTable: "UserPhotos",
                principalColumn: "alakyId",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_UserPhotos_Activities_ActivityId",
                table: "UserPhotos",
                column: "ActivityId",
                principalTable: "Activities",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Imagems",
                columns: table => new
            {
                ImagemId = table.Column <int>(nullable: false)
                           .Annotation("SqlServer:Identity", "1, 1"),
                Foto = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Imagems", x => x.ImagemId);
            });

            migrationBuilder.CreateTable(
                name: "Imovels",
                columns: table => new
            {
                ImovelId = table.Column <int>(nullable: false)
                           .Annotation("SqlServer:Identity", "1, 1"),
                NomeImovel = table.Column <string>(nullable: false),
                Cidade     = table.Column <string>(nullable: true),
                Estado     = table.Column <string>(nullable: true),
                Bairro     = table.Column <string>(nullable: false),
                Rua        = table.Column <string>(nullable: false),
                Numero     = table.Column <int>(nullable: false),
                Cep        = table.Column <int>(nullable: false),
                Status     = table.Column <bool>(nullable: false),
                ContratoId = table.Column <int>(nullable: true),
                ImovelId1  = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Imovels", x => x.ImovelId);
                table.ForeignKey(
                    name: "FK_Imovels_Imovels_ImovelId1",
                    column: x => x.ImovelId1,
                    principalTable: "Imovels",
                    principalColumn: "ImovelId",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Locadores",
                columns: table => new
            {
                LocadorId = table.Column <int>(nullable: false)
                            .Annotation("SqlServer:Identity", "1, 1"),
                Nome          = table.Column <string>(nullable: false),
                SobreNome     = table.Column <string>(nullable: false),
                Cpf           = table.Column <decimal>(nullable: false),
                Rg            = table.Column <decimal>(nullable: false),
                OrgaoEmissor  = table.Column <string>(nullable: false),
                Profissao     = table.Column <string>(nullable: false),
                EstadoCivil   = table.Column <int>(nullable: false),
                Email         = table.Column <string>(nullable: false),
                Tel           = table.Column <decimal>(nullable: false),
                TelTestemunha = table.Column <decimal>(nullable: false),
                Status        = table.Column <bool>(nullable: false),
                ContratoId    = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Locadores", x => x.LocadorId);
            });

            migrationBuilder.CreateTable(
                name: "Locatarios",
                columns: table => new
            {
                LocatarioId = table.Column <int>(nullable: false)
                              .Annotation("SqlServer:Identity", "1, 1"),
                Nome          = table.Column <string>(nullable: false),
                SobreNome     = table.Column <string>(nullable: false),
                Cpf           = table.Column <decimal>(nullable: false),
                Rg            = table.Column <decimal>(nullable: false),
                OrgaoEmissor  = table.Column <string>(nullable: false),
                Profissao     = table.Column <string>(nullable: false),
                EstadoCivil   = table.Column <int>(nullable: false),
                Email         = table.Column <string>(nullable: false),
                Tel           = table.Column <decimal>(nullable: false),
                TelTestemunha = table.Column <decimal>(nullable: false),
                Status        = table.Column <bool>(nullable: false),
                ContratoId    = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Locatarios", x => x.LocatarioId);
            });

            migrationBuilder.CreateTable(
                name: "Contratos",
                columns: table => new
            {
                ContratoId = table.Column <int>(nullable: false)
                             .Annotation("SqlServer:Identity", "1, 1"),
                LocadorId           = table.Column <int>(nullable: false),
                LocatarioId         = table.Column <int>(nullable: false),
                imovelId            = table.Column <int>(nullable: false),
                DataContrato        = table.Column <DateTime>(nullable: false),
                DiaVencimentoAlguel = table.Column <DateTime>(nullable: false),
                DataInicio          = table.Column <DateTime>(nullable: false),
                DataFim             = table.Column <DateTime>(nullable: false),
                Status = table.Column <bool>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Contratos", x => x.ContratoId);
                table.ForeignKey(
                    name: "FK_Contratos_Locadores_LocadorId",
                    column: x => x.LocadorId,
                    principalTable: "Locadores",
                    principalColumn: "LocadorId",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_Contratos_Locatarios_LocatarioId",
                    column: x => x.LocatarioId,
                    principalTable: "Locatarios",
                    principalColumn: "LocatarioId",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_Contratos_Imovels_imovelId",
                    column: x => x.imovelId,
                    principalTable: "Imovels",
                    principalColumn: "ImovelId",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Contratos_LocadorId",
                table: "Contratos",
                column: "LocadorId");

            migrationBuilder.CreateIndex(
                name: "IX_Contratos_LocatarioId",
                table: "Contratos",
                column: "LocatarioId");

            migrationBuilder.CreateIndex(
                name: "IX_Contratos_imovelId",
                table: "Contratos",
                column: "imovelId");

            migrationBuilder.CreateIndex(
                name: "IX_Imovels_ContratoId",
                table: "Imovels",
                column: "ContratoId");

            migrationBuilder.CreateIndex(
                name: "IX_Imovels_ImovelId1",
                table: "Imovels",
                column: "ImovelId1");

            migrationBuilder.CreateIndex(
                name: "IX_Locadores_ContratoId",
                table: "Locadores",
                column: "ContratoId");

            migrationBuilder.CreateIndex(
                name: "IX_Locatarios_ContratoId",
                table: "Locatarios",
                column: "ContratoId");

            migrationBuilder.AddForeignKey(
                name: "FK_Imovels_Contratos_ContratoId",
                table: "Imovels",
                column: "ContratoId",
                principalTable: "Contratos",
                principalColumn: "ContratoId",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Locadores_Contratos_ContratoId",
                table: "Locadores",
                column: "ContratoId",
                principalTable: "Contratos",
                principalColumn: "ContratoId",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Locatarios_Contratos_ContratoId",
                table: "Locatarios",
                column: "ContratoId",
                principalTable: "Contratos",
                principalColumn: "ContratoId",
                onDelete: ReferentialAction.Restrict);
        }
Esempio n. 35
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Services_ServiceItems_ServiceItemId",
                table: "Services");

            migrationBuilder.DropIndex(
                name: "IX_Services_ServiceItemId",
                table: "Services");

            migrationBuilder.DropColumn(
                name: "ServiceItemId",
                table: "Services");

            migrationBuilder.DropColumn(
                name: "Description",
                table: "ServiceItems");

            migrationBuilder.DropColumn(
                name: "Image",
                table: "ServiceItems");

            migrationBuilder.DropColumn(
                name: "ShortDescription",
                table: "ServiceItems");

            migrationBuilder.DropColumn(
                name: "ShortText",
                table: "ServiceItems");

            migrationBuilder.AlterColumn <string>(
                name: "Logo",
                table: "Services",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "nvarchar(50)",
                oldMaxLength: 50);

            migrationBuilder.AddColumn <string>(
                name: "Description",
                table: "Services",
                maxLength: 200,
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <string>(
                name: "EndPoint",
                table: "Services",
                maxLength: 200,
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <string>(
                name: "Image",
                table: "Services",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <string>(
                name: "Slogan",
                table: "Services",
                maxLength: 200,
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <string>(
                name: "Text",
                table: "Services",
                maxLength: 500,
                nullable: false,
                defaultValue: "");

            migrationBuilder.AlterColumn <string>(
                name: "Text",
                table: "ServiceItems",
                maxLength: 500,
                nullable: false,
                oldClrType: typeof(string),
                oldType: "nvarchar(200)",
                oldMaxLength: 200);

            migrationBuilder.AddColumn <string>(
                name: "Logo",
                table: "ServiceItems",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <string>(
                name: "Name",
                table: "ServiceItems",
                maxLength: 50,
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <int>(
                name: "ServiceId",
                table: "ServiceItems",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateIndex(
                name: "IX_ServiceSpecs_ServiceId",
                table: "ServiceSpecs",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_ServiceItems_ServiceId",
                table: "ServiceItems",
                column: "ServiceId");

            migrationBuilder.AddForeignKey(
                name: "FK_ServiceItems_Services_ServiceId",
                table: "ServiceItems",
                column: "ServiceId",
                principalTable: "Services",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ServiceSpecs_Services_ServiceId",
                table: "ServiceSpecs",
                column: "ServiceId",
                principalTable: "Services",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Insurances_AspNetUsers_IDUser",
                table: "Insurances");

            migrationBuilder.DropForeignKey(
                name: "FK_PolicyDetails_AspNetUsers_IDUser",
                table: "PolicyDetails");

            migrationBuilder.DropForeignKey(
                name: "FK_PolicyDetails_PriceLists_IDTypeInsurance",
                table: "PolicyDetails");

            migrationBuilder.DropIndex(
                name: "IX_PolicyDetails_IDTypeInsurance",
                table: "PolicyDetails");

            migrationBuilder.DropIndex(
                name: "IX_PolicyDetails_IDUser",
                table: "PolicyDetails");

            migrationBuilder.DropIndex(
                name: "IX_Insurances_IDUser",
                table: "Insurances");

            migrationBuilder.DropColumn(
                name: "IDTypeInsurance",
                table: "PolicyDetails");

            migrationBuilder.DropColumn(
                name: "IDUser",
                table: "PolicyDetails");

            migrationBuilder.DropColumn(
                name: "IDUser",
                table: "Insurances");

            migrationBuilder.RenameColumn(
                name: "IDTypeInsurance",
                table: "PriceLists",
                newName: "IDPriceList");

            migrationBuilder.AddColumn <int>(
                name: "IDForm",
                table: "Insurances",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn <int>(
                name: "IDPriceList",
                table: "Insurances",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateTable(
                name: "Forms",
                columns: table => new
            {
                IDForm = table.Column <int>(type: "int", nullable: false)
                         .Annotation("SqlServer:Identity", "1, 1"),
                IDPolicyDetails = table.Column <int>(type: "int", nullable: false),
                IDUser          = table.Column <string>(type: "nvarchar(450)", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Forms", x => x.IDForm);
                table.ForeignKey(
                    name: "FK_Forms_AspNetUsers_IDUser",
                    column: x => x.IDUser,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Forms_PolicyDetails_IDPolicyDetails",
                    column: x => x.IDPolicyDetails,
                    principalTable: "PolicyDetails",
                    principalColumn: "IDPolicyDetails",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Insurances_IDForm",
                table: "Insurances",
                column: "IDForm");

            migrationBuilder.CreateIndex(
                name: "IX_Insurances_IDPriceList",
                table: "Insurances",
                column: "IDPriceList");

            migrationBuilder.CreateIndex(
                name: "IX_Forms_IDPolicyDetails",
                table: "Forms",
                column: "IDPolicyDetails");

            migrationBuilder.CreateIndex(
                name: "IX_Forms_IDUser",
                table: "Forms",
                column: "IDUser");

            migrationBuilder.AddForeignKey(
                name: "FK_Insurances_Forms_IDForm",
                table: "Insurances",
                column: "IDForm",
                principalTable: "Forms",
                principalColumn: "IDForm",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Insurances_PriceLists_IDPriceList",
                table: "Insurances",
                column: "IDPriceList",
                principalTable: "PriceLists",
                principalColumn: "IDPriceList",
                onDelete: ReferentialAction.Cascade);
        }
Esempio n. 37
0
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ATMSources_ATMs_TradePointId",
                table: "ATMSources");

            migrationBuilder.DropForeignKey(
                name: "FK_InfoKioskSources_InfoKiosks_TradePointId",
                table: "InfoKioskSources");

            migrationBuilder.DropForeignKey(
                name: "FK_OfficeSources_Offices_TradePointId",
                table: "OfficeSources");

            migrationBuilder.DropIndex(
                name: "IX_OfficeSources_TradePointId",
                table: "OfficeSources");

            migrationBuilder.DropIndex(
                name: "IX_InfoKioskSources_TradePointId",
                table: "InfoKioskSources");

            migrationBuilder.DropIndex(
                name: "IX_ATMSources_TradePointId",
                table: "ATMSources");

            migrationBuilder.DropColumn(
                name: "TradePointId",
                table: "OfficeSources");

            migrationBuilder.DropColumn(
                name: "TradePointId",
                table: "InfoKioskSources");

            migrationBuilder.DropColumn(
                name: "TradePointId",
                table: "ATMSources");

            migrationBuilder.AddColumn<string>(
                name: "SourceDataFileType",
                table: "Offices",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "SourceTradePointSourceId",
                table: "Offices",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "SourceDataFileType",
                table: "InfoKiosks",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "SourceTradePointSourceId",
                table: "InfoKiosks",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "SourceDataFileType",
                table: "ATMs",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "SourceTradePointSourceId",
                table: "ATMs",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_Offices_SourceTradePointSourceId_SourceDataFileType",
                table: "Offices",
                columns: new[] { "SourceTradePointSourceId", "SourceDataFileType" },
                unique: true,
                filter: "[SourceTradePointSourceId] IS NOT NULL AND [SourceDataFileType] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_InfoKiosks_SourceTradePointSourceId_SourceDataFileType",
                table: "InfoKiosks",
                columns: new[] { "SourceTradePointSourceId", "SourceDataFileType" },
                unique: true,
                filter: "[SourceTradePointSourceId] IS NOT NULL AND [SourceDataFileType] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_ATMs_SourceTradePointSourceId_SourceDataFileType",
                table: "ATMs",
                columns: new[] { "SourceTradePointSourceId", "SourceDataFileType" },
                unique: true,
                filter: "[SourceTradePointSourceId] IS NOT NULL AND [SourceDataFileType] IS NOT NULL");

            migrationBuilder.AddForeignKey(
                name: "FK_ATMs_ATMSources_SourceTradePointSourceId_SourceDataFileType",
                table: "ATMs",
                columns: new[] { "SourceTradePointSourceId", "SourceDataFileType" },
                principalTable: "ATMSources",
                principalColumns: new[] { "TradePointSourceId", "DataFileType" },
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_InfoKiosks_InfoKioskSources_SourceTradePointSourceId_SourceDataFileType",
                table: "InfoKiosks",
                columns: new[] { "SourceTradePointSourceId", "SourceDataFileType" },
                principalTable: "InfoKioskSources",
                principalColumns: new[] { "TradePointSourceId", "DataFileType" },
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Offices_OfficeSources_SourceTradePointSourceId_SourceDataFileType",
                table: "Offices",
                columns: new[] { "SourceTradePointSourceId", "SourceDataFileType" },
                principalTable: "OfficeSources",
                principalColumns: new[] { "TradePointSourceId", "DataFileType" },
                onDelete: ReferentialAction.Restrict);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "UserNameIndex",
                table: "AspNetUsers");

            migrationBuilder.DropIndex(
                name: "IX_AspNetUserRoles_UserId",
                table: "AspNetUserRoles");

            migrationBuilder.DropIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles");

            migrationBuilder.CreateTable(
                name: "Genres",
                columns: table => new
            {
                Id   = table.Column <byte>(nullable: false),
                Name = table.Column <string>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Genres", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "MembershipTypes",
                columns: table => new
            {
                Id               = table.Column <byte>(nullable: false),
                DiscountRate     = table.Column <byte>(nullable: false),
                DurationInMonths = table.Column <byte>(nullable: false),
                Name             = table.Column <string>(nullable: false),
                SignUpFee        = table.Column <short>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_MembershipTypes", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Movies",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                DateAdded     = table.Column <DateTime>(nullable: false),
                GenreId       = table.Column <byte>(nullable: false),
                Name          = table.Column <string>(nullable: false),
                NumberInStock = table.Column <short>(nullable: false),
                ReleaseDate   = table.Column <DateTime>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Movies", x => x.Id);
                table.ForeignKey(
                    name: "FK_Movies_Genres_GenreId",
                    column: x => x.GenreId,
                    principalTable: "Genres",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Customers",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Birthday = table.Column <DateTime>(nullable: true),
                IsSubscribedToNewsletter = table.Column <bool>(nullable: false),
                MembershipTypeId         = table.Column <byte>(nullable: false),
                Name = table.Column <string>(maxLength: 255, nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Customers", x => x.Id);
                table.ForeignKey(
                    name: "FK_Customers_MembershipTypes_MembershipTypeId",
                    column: x => x.MembershipTypeId,
                    principalTable: "MembershipTypes",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "UserNameIndex",
                table: "AspNetUsers",
                column: "NormalizedUserName",
                unique: true,
                filter: "[NormalizedUserName] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles",
                column: "NormalizedName",
                unique: true,
                filter: "[NormalizedName] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_Customers_MembershipTypeId",
                table: "Customers",
                column: "MembershipTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_Movies_GenreId",
                table: "Movies",
                column: "GenreId");

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserTokens_AspNetUsers_UserId",
                table: "AspNetUserTokens",
                column: "UserId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Hotels_Addresses_AddressId",
                table: "Hotels");

            migrationBuilder.DropForeignKey(
                name: "FK_Hotels_Amenities_AmenityId",
                table: "Hotels");

            migrationBuilder.DropForeignKey(
                name: "FK_Hotels_Infos_InfoId",
                table: "Hotels");

            migrationBuilder.AlterColumn <int>(
                name: "InfoId",
                table: "Hotels",
                type: "int",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn <int>(
                name: "AmenityId",
                table: "Hotels",
                type: "int",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn <int>(
                name: "AddressId",
                table: "Hotels",
                type: "int",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AddColumn <int>(
                name: "ReviewId",
                table: "Hotels",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn <int>(
                name: "RoomId",
                table: "Hotels",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn <int>(
                name: "StayId",
                table: "Hotels",
                type: "int",
                nullable: true);

            migrationBuilder.AddForeignKey(
                name: "FK_Hotels_Addresses_AddressId",
                table: "Hotels",
                column: "AddressId",
                principalTable: "Addresses",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Hotels_Amenities_AmenityId",
                table: "Hotels",
                column: "AmenityId",
                principalTable: "Amenities",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Hotels_Infos_InfoId",
                table: "Hotels",
                column: "InfoId",
                principalTable: "Infos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_GamesRates_Games_GameId",
                table: "GamesRates");

            migrationBuilder.DropPrimaryKey(
                name: "PK_GamesRates",
                table: "GamesRates");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Games",
                table: "Games");

            migrationBuilder.DropColumn(
                name: "GameRateId",
                table: "GamesRates");

            migrationBuilder.DropColumn(
                name: "GameId",
                table: "Games");

            migrationBuilder.AlterColumn <int>(
                name: "GameId",
                table: "GamesRates",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "nvarchar(450)",
                oldNullable: true);

            migrationBuilder.AddColumn <int>(
                name: "Id",
                table: "GamesRates",
                nullable: false,
                defaultValue: 0)
            .Annotation("SqlServer:Identity", "1, 1");

            migrationBuilder.AddColumn <int>(
                name: "Id",
                table: "Games",
                nullable: false,
                defaultValue: 0)
            .Annotation("SqlServer:Identity", "1, 1");

            migrationBuilder.AddPrimaryKey(
                name: "PK_GamesRates",
                table: "GamesRates",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Games",
                table: "Games",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_GamesRates_Games_GameId",
                table: "GamesRates",
                column: "GameId",
                principalTable: "Games",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.CreateTable(
         name: "Warehouses",
         columns: table => new
     {
         id = table.Column <int>(nullable: false)
              .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
         addr1             = table.Column <string>(nullable: true),
         addr2             = table.Column <string>(nullable: true),
         addr3             = table.Column <string>(nullable: true),
         addr4             = table.Column <string>(nullable: true),
         country           = table.Column <string>(nullable: true),
         desc              = table.Column <string>(nullable: true),
         name              = table.Column <string>(nullable: true),
         post_code         = table.Column <string>(nullable: true),
         type_of_transport = table.Column <string>(nullable: true),
         warehouse_id      = table.Column <string>(nullable: true)
     },
         constraints: table =>
     {
         table.PrimaryKey("PK_Warehouses", x => x.id);
     });
     migrationBuilder.AlterColumn <string>(
         name: "UserId",
         table: "AspNetUserLogins",
         nullable: false);
     migrationBuilder.AlterColumn <string>(
         name: "UserId",
         table: "AspNetUserClaims",
         nullable: false);
     migrationBuilder.AlterColumn <string>(
         name: "RoleId",
         table: "AspNetRoleClaims",
         nullable: false);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn <int>(
                name: "TreinadorId",
                table: "Times",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateTable(
                name: "Campeonatos",
                columns: table => new
            {
                CampeonatoId = table.Column <int>(nullable: false)
                               .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Premiacao      = table.Column <decimal>(nullable: false),
                TipoCampeonato = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Campeonatos", x => x.CampeonatoId);
            });

            migrationBuilder.CreateTable(
                name: "jogadores",
                columns: table => new
            {
                JogadorId = table.Column <int>(nullable: false)
                            .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Nome           = table.Column <string>(nullable: true),
                DataNascimento = table.Column <DateTime>(nullable: false),
                Altura         = table.Column <float>(nullable: false),
                TimeId         = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_jogadores", x => x.JogadorId);
                table.ForeignKey(
                    name: "FK_jogadores_Times_TimeId",
                    column: x => x.TimeId,
                    principalTable: "Times",
                    principalColumn: "Codigo",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Treinadores",
                columns: table => new
            {
                TreinadorId = table.Column <int>(nullable: false)
                              .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Nome    = table.Column <string>(nullable: true),
                Salario = table.Column <decimal>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Treinadores", x => x.TreinadorId);
            });

            migrationBuilder.CreateTable(
                name: "CampeonatoTime",
                columns: table => new
            {
                TimeId         = table.Column <int>(nullable: false),
                CampeonatoId   = table.Column <int>(nullable: false),
                TipoCampeonato = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_CampeonatoTime", x => new { x.CampeonatoId, x.TimeId });
                table.ForeignKey(
                    name: "FK_CampeonatoTime_Campeonatos_CampeonatoId",
                    column: x => x.CampeonatoId,
                    principalTable: "Campeonatos",
                    principalColumn: "CampeonatoId",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_CampeonatoTime_Times_TimeId",
                    column: x => x.TimeId,
                    principalTable: "Times",
                    principalColumn: "Codigo",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Times_TreinadorId",
                table: "Times",
                column: "TreinadorId");

            migrationBuilder.CreateIndex(
                name: "IX_CampeonatoTime_TimeId",
                table: "CampeonatoTime",
                column: "TimeId");

            migrationBuilder.CreateIndex(
                name: "IX_jogadores_TimeId",
                table: "jogadores",
                column: "TimeId");

            migrationBuilder.AddForeignKey(
                name: "FK_Times_Treinadores_TreinadorId",
                table: "Times",
                column: "TreinadorId",
                principalTable: "Treinadores",
                principalColumn: "TreinadorId",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ArcVolume_Arcs_ArcsId",
                table: "ArcVolume");

            migrationBuilder.DropForeignKey(
                name: "FK_ArcVolume_Volumes_VolumesId",
                table: "ArcVolume");

            migrationBuilder.DropTable(
                name: "ArcCharacter");

            migrationBuilder.DropTable(
                name: "ArcVolumes");

            migrationBuilder.DropTable(
                name: "CharacterIssue");

            migrationBuilder.DropTable(
                name: "CharacterSeries");

            migrationBuilder.DropTable(
                name: "CharacterVolume");

            migrationBuilder.DropTable(
                name: "IssuePublisher");

            migrationBuilder.DropTable(
                name: "PublisherVolume");

            migrationBuilder.RenameColumn(
                name: "VolumesId",
                table: "ArcVolume",
                newName: "VolumeId");

            migrationBuilder.RenameColumn(
                name: "ArcsId",
                table: "ArcVolume",
                newName: "ArcId");

            migrationBuilder.RenameIndex(
                name: "IX_ArcVolume_VolumesId",
                table: "ArcVolume",
                newName: "IX_ArcVolume_VolumeId");

            migrationBuilder.AddForeignKey(
                name: "FK_ArcVolume_Arcs_ArcId",
                table: "ArcVolume",
                column: "ArcId",
                principalTable: "Arcs",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ArcVolume_Volumes_VolumeId",
                table: "ArcVolume",
                column: "VolumeId",
                principalTable: "Volumes",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DeleteData(
                table: "AspNetRoles",
                keyColumn: "Id",
                keyValue: "79ddf8ea-46f9-4bb9-9e9d-bc2e2ea0c83b");

            migrationBuilder.CreateTable(
                name: "Diets",
                columns: table => new
            {
                DietId = table.Column <int>(nullable: false)
                         .Annotation("SqlServer:Identity", "1, 1")
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Diets", x => x.DietId);
            });

            migrationBuilder.CreateTable(
                name: "Customers",
                columns: table => new
            {
                CustomerId = table.Column <int>(nullable: false)
                             .Annotation("SqlServer:Identity", "1, 1"),
                UserName       = table.Column <string>(nullable: true),
                IdentityUserId = table.Column <string>(nullable: true),
                DietId         = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Customers", x => x.CustomerId);
                table.ForeignKey(
                    name: "FK_Customers_Diets_DietId",
                    column: x => x.DietId,
                    principalTable: "Diets",
                    principalColumn: "DietId",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_Customers_AspNetUsers_IdentityUserId",
                    column: x => x.IdentityUserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Meals",
                columns: table => new
            {
                MealId = table.Column <int>(nullable: false)
                         .Annotation("SqlServer:Identity", "1, 1"),
                DietId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Meals", x => x.MealId);
                table.ForeignKey(
                    name: "FK_Meals_Diets_DietId",
                    column: x => x.DietId,
                    principalTable: "Diets",
                    principalColumn: "DietId",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Foods",
                columns: table => new
            {
                FoodId = table.Column <int>(nullable: false)
                         .Annotation("SqlServer:Identity", "1, 1"),
                MealsID               = table.Column <int>(nullable: false),
                food_name             = table.Column <string>(nullable: true),
                brand_name            = table.Column <string>(nullable: true),
                serving_qty           = table.Column <int>(nullable: false),
                serving_unit          = table.Column <string>(nullable: true),
                serving_weight_grams  = table.Column <float>(nullable: false),
                nf_calories           = table.Column <float>(nullable: false),
                nf_total_fat          = table.Column <float>(nullable: false),
                nf_saturated_fat      = table.Column <float>(nullable: false),
                nf_cholesterol        = table.Column <float>(nullable: false),
                nf_sodium             = table.Column <float>(nullable: false),
                nf_total_carbohydrate = table.Column <float>(nullable: false),
                nf_dietary_fiber      = table.Column <float>(nullable: false),
                nf_sugars             = table.Column <float>(nullable: false),
                nf_protein            = table.Column <float>(nullable: false),
                nf_potassium          = table.Column <float>(nullable: false),
                nf_p             = table.Column <float>(nullable: false),
                full_nutrientsID = table.Column <int>(nullable: false),
                nix_brand_name   = table.Column <string>(nullable: true),
                nix_brand_id     = table.Column <string>(nullable: true),
                nix_item_name    = table.Column <string>(nullable: true),
                nix_item_id      = table.Column <string>(nullable: true),
                upc            = table.Column <string>(nullable: true),
                consumed_at    = table.Column <DateTime>(nullable: false),
                source         = table.Column <int>(nullable: false),
                ndb_no         = table.Column <int>(nullable: false),
                tagsID         = table.Column <int>(nullable: false),
                alt_measuresID = table.Column <int>(nullable: false),
                lat            = table.Column <string>(nullable: true),
                lng            = table.Column <string>(nullable: true),
                meal_type      = table.Column <int>(nullable: false),
                photoID        = table.Column <int>(nullable: false),
                sub_recipe     = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Foods", x => x.FoodId);
                table.ForeignKey(
                    name: "FK_Foods_Meals_MealsID",
                    column: x => x.MealsID,
                    principalTable: "Meals",
                    principalColumn: "MealId",
                    onDelete: ReferentialAction.NoAction);
            });

            migrationBuilder.CreateTable(
                name: "Alt_Measures",
                columns: table => new
            {
                Alt_MeasuresID = table.Column <int>(nullable: false)
                                 .Annotation("SqlServer:Identity", "1, 1"),
                foodID         = table.Column <int>(nullable: false),
                serving_weight = table.Column <float>(nullable: false),
                measure        = table.Column <string>(nullable: true),
                seq            = table.Column <int>(nullable: true),
                qty            = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Alt_Measures", x => x.Alt_MeasuresID);
                table.ForeignKey(
                    name: "FK_Alt_Measures_Foods_foodID",
                    column: x => x.foodID,
                    principalTable: "Foods",
                    principalColumn: "FoodId",
                    onDelete: ReferentialAction.NoAction);
            });

            migrationBuilder.CreateTable(
                name: "Full_Nutrients",
                columns: table => new
            {
                Full_NutrientsID = table.Column <int>(nullable: false)
                                   .Annotation("SqlServer:Identity", "1, 1"),
                foodId  = table.Column <int>(nullable: false),
                attr_id = table.Column <int>(nullable: false),
                value   = table.Column <float>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Full_Nutrients", x => x.Full_NutrientsID);
                table.ForeignKey(
                    name: "FK_Full_Nutrients_Foods_foodId",
                    column: x => x.foodId,
                    principalTable: "Foods",
                    principalColumn: "FoodId",
                    onDelete: ReferentialAction.NoAction);
            });

            migrationBuilder.CreateTable(
                name: "Metadata",
                columns: table => new
            {
                metaDataID = table.Column <int>(nullable: false)
                             .Annotation("SqlServer:Identity", "1, 1"),
                is_raw_food = table.Column <bool>(nullable: false),
                FoodId      = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Metadata", x => x.metaDataID);
                table.ForeignKey(
                    name: "FK_Metadata_Foods_FoodId",
                    column: x => x.FoodId,
                    principalTable: "Foods",
                    principalColumn: "FoodId",
                    onDelete: ReferentialAction.NoAction);
            });

            migrationBuilder.CreateTable(
                name: "Photo",
                columns: table => new
            {
                photoID = table.Column <int>(nullable: false)
                          .Annotation("SqlServer:Identity", "1, 1"),
                foodID           = table.Column <int>(nullable: false),
                thumb            = table.Column <string>(nullable: true),
                highres          = table.Column <string>(nullable: true),
                is_user_uploaded = table.Column <bool>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Photo", x => x.photoID);
                table.ForeignKey(
                    name: "FK_Photo_Foods_foodID",
                    column: x => x.foodID,
                    principalTable: "Foods",
                    principalColumn: "FoodId",
                    onDelete: ReferentialAction.NoAction);
            });

            migrationBuilder.CreateTable(
                name: "Tags",
                columns: table => new
            {
                TagId = table.Column <int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                FoodId     = table.Column <int>(nullable: false),
                item       = table.Column <string>(nullable: true),
                measure    = table.Column <string>(nullable: true),
                quantity   = table.Column <string>(nullable: true),
                food_group = table.Column <int>(nullable: false),
                tag_id     = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Tags", x => x.TagId);
                table.ForeignKey(
                    name: "FK_Tags_Foods_FoodId",
                    column: x => x.FoodId,
                    principalTable: "Foods",
                    principalColumn: "FoodId",
                    onDelete: ReferentialAction.NoAction);
            });

            migrationBuilder.InsertData(
                table: "AspNetRoles",
                columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
                values: new object[] { "edf29ae9-ad37-4511-88ef-905037225de9", "ece829be-4f8d-4627-a9ad-e09f56ad9f41", "Admin", "ADMIN" });

            migrationBuilder.CreateIndex(
                name: "IX_Alt_Measures_foodID",
                table: "Alt_Measures",
                column: "foodID");

            migrationBuilder.CreateIndex(
                name: "IX_Customers_DietId",
                table: "Customers",
                column: "DietId");

            migrationBuilder.CreateIndex(
                name: "IX_Customers_IdentityUserId",
                table: "Customers",
                column: "IdentityUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Foods_MealsID",
                table: "Foods",
                column: "MealsID");

            migrationBuilder.CreateIndex(
                name: "IX_Foods_alt_measuresID",
                table: "Foods",
                column: "alt_measuresID");

            migrationBuilder.CreateIndex(
                name: "IX_Foods_full_nutrientsID",
                table: "Foods",
                column: "full_nutrientsID");

            migrationBuilder.CreateIndex(
                name: "IX_Foods_photoID",
                table: "Foods",
                column: "photoID");

            migrationBuilder.CreateIndex(
                name: "IX_Foods_tagsID",
                table: "Foods",
                column: "tagsID");

            migrationBuilder.CreateIndex(
                name: "IX_Full_Nutrients_foodId",
                table: "Full_Nutrients",
                column: "foodId");

            migrationBuilder.CreateIndex(
                name: "IX_Meals_DietId",
                table: "Meals",
                column: "DietId");

            migrationBuilder.CreateIndex(
                name: "IX_Metadata_FoodId",
                table: "Metadata",
                column: "FoodId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Photo_foodID",
                table: "Photo",
                column: "foodID");

            migrationBuilder.CreateIndex(
                name: "IX_Tags_FoodId",
                table: "Tags",
                column: "FoodId");

            migrationBuilder.AddForeignKey(
                name: "FK_Foods_Alt_Measures_alt_measuresID",
                table: "Foods",
                column: "alt_measuresID",
                principalTable: "Alt_Measures",
                principalColumn: "Alt_MeasuresID",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Foods_Full_Nutrients_full_nutrientsID",
                table: "Foods",
                column: "full_nutrientsID",
                principalTable: "Full_Nutrients",
                principalColumn: "Full_NutrientsID",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Foods_Photo_photoID",
                table: "Foods",
                column: "photoID",
                principalTable: "Photo",
                principalColumn: "photoID",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Foods_Tags_tagsID",
                table: "Foods",
                column: "tagsID",
                principalTable: "Tags",
                principalColumn: "TagId",
                onDelete: ReferentialAction.Cascade);
        }
Esempio n. 45
0
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "GalleryImages");

            migrationBuilder.DropTable(
                name: "Pages");

            migrationBuilder.DropTable(
                name: "Partniors");

            migrationBuilder.DropTable(
                name: "Projects");

            migrationBuilder.DropTable(
                name: "Images");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Galleries",
                table: "Galleries");

            migrationBuilder.DropColumn(
                name: "Name",
                table: "Settings");

            migrationBuilder.RenameTable(
                name: "Galleries",
                newName: "Gallerys");

            migrationBuilder.RenameColumn(
                name: "Name",
                table: "Gallerys",
                newName: "Title");

            migrationBuilder.AddColumn <string>(
                name: "Description",
                table: "AspNetUsers",
                type: "text",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "Discriminator",
                table: "AspNetUsers",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn <string>(
                name: "Facebook",
                table: "AspNetUsers",
                type: "text",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ImageId",
                table: "AspNetUsers",
                type: "text",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "JobTitle",
                table: "AspNetUsers",
                type: "text",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "Description",
                table: "Gallerys",
                type: "text",
                nullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_Gallerys",
                table: "Gallerys",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "Category",
                columns: table => new
            {
                Id          = table.Column <string>(type: "text", nullable: false),
                Description = table.Column <string>(type: "text", nullable: true),
                Title       = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Category", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Logs",
                columns: table => new
            {
                Id      = table.Column <string>(type: "text", nullable: false),
                Date    = table.Column <DateTime>(type: "timestamp without time zone", nullable: false),
                Message = table.Column <string>(type: "text", nullable: true),
                Type    = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Logs", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "MediaTypes",
                columns: table => new
            {
                Id   = table.Column <string>(type: "text", nullable: false),
                Type = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_MediaTypes", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Statistics",
                columns: table => new
            {
                Id     = table.Column <string>(type: "text", nullable: false),
                PageId = table.Column <string>(type: "text", nullable: true),
                Time   = table.Column <DateTime>(type: "timestamp without time zone", nullable: false),
                UserId = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Statistics", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "INMedias",
                columns: table => new
            {
                Id          = table.Column <string>(type: "text", nullable: false),
                Description = table.Column <string>(type: "text", nullable: true),
                Path        = table.Column <string>(type: "text", nullable: true),
                Title       = table.Column <string>(type: "text", nullable: true),
                TypeId      = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_INMedias", x => x.Id);
                table.ForeignKey(
                    name: "FK_INMedias_MediaTypes_TypeId",
                    column: x => x.TypeId,
                    principalTable: "MediaTypes",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "AboutSkilsSections",
                columns: table => new
            {
                Id          = table.Column <string>(type: "text", nullable: false),
                Description = table.Column <string>(type: "text", nullable: true),
                ImageId     = table.Column <string>(type: "text", nullable: true),
                Title       = table.Column <string>(type: "text", nullable: true),
                VideoId     = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AboutSkilsSections", x => x.Id);
                table.ForeignKey(
                    name: "FK_AboutSkilsSections_INMedias_ImageId",
                    column: x => x.ImageId,
                    principalTable: "INMedias",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AboutSkilsSections_INMedias_VideoId",
                    column: x => x.VideoId,
                    principalTable: "INMedias",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "BlogPosts",
                columns: table => new
            {
                Id              = table.Column <string>(type: "text", nullable: false),
                Active          = table.Column <bool>(type: "boolean", nullable: false),
                AppUserId       = table.Column <string>(type: "text", nullable: true),
                ComentsIsActive = table.Column <bool>(type: "boolean", nullable: false),
                Content         = table.Column <string>(type: "text", nullable: true),
                DateCreated     = table.Column <DateTime>(type: "timestamp without time zone", nullable: false),
                DateEdited      = table.Column <DateTime>(type: "timestamp without time zone", nullable: true),
                GalleryId       = table.Column <string>(type: "text", nullable: true),
                PostImageId     = table.Column <string>(type: "text", nullable: true),
                Title           = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_BlogPosts", x => x.Id);
                table.ForeignKey(
                    name: "FK_BlogPosts_AspNetUsers_AppUserId",
                    column: x => x.AppUserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_BlogPosts_Gallerys_GalleryId",
                    column: x => x.GalleryId,
                    principalTable: "Gallerys",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_BlogPosts_INMedias_PostImageId",
                    column: x => x.PostImageId,
                    principalTable: "INMedias",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Carousels",
                columns: table => new
            {
                Id          = table.Column <string>(type: "text", nullable: false),
                Ative       = table.Column <bool>(type: "boolean", nullable: false),
                Description = table.Column <string>(type: "text", nullable: true),
                Link        = table.Column <string>(type: "text", nullable: true),
                MediaId     = table.Column <string>(type: "text", nullable: true),
                Number      = table.Column <int>(type: "integer", nullable: true),
                Title       = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Carousels", x => x.Id);
                table.ForeignKey(
                    name: "FK_Carousels_INMedias_MediaId",
                    column: x => x.MediaId,
                    principalTable: "INMedias",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "GalleryINMedias",
                columns: table => new
            {
                GalleryId = table.Column <string>(type: "text", nullable: false),
                INMediaId = table.Column <string>(type: "text", nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_GalleryINMedias", x => new { x.GalleryId, x.INMediaId });
                table.ForeignKey(
                    name: "FK_GalleryINMedias_Gallerys_GalleryId",
                    column: x => x.GalleryId,
                    principalTable: "Gallerys",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_GalleryINMedias_INMedias_INMediaId",
                    column: x => x.INMediaId,
                    principalTable: "INMedias",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "INMediaCategories",
                columns: table => new
            {
                INMediaId  = table.Column <string>(type: "text", nullable: false),
                CategoryId = table.Column <string>(type: "text", nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_INMediaCategories", x => new { x.INMediaId, x.CategoryId });
                table.ForeignKey(
                    name: "FK_INMediaCategories_Category_CategoryId",
                    column: x => x.CategoryId,
                    principalTable: "Category",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_INMediaCategories_INMedias_INMediaId",
                    column: x => x.INMediaId,
                    principalTable: "INMedias",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "INServices",
                columns: table => new
            {
                Id          = table.Column <string>(type: "text", nullable: false),
                Description = table.Column <string>(type: "text", nullable: true),
                ImageId     = table.Column <string>(type: "text", nullable: true),
                Link        = table.Column <string>(type: "text", nullable: true),
                Title       = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_INServices", x => x.Id);
                table.ForeignKey(
                    name: "FK_INServices_INMedias_ImageId",
                    column: x => x.ImageId,
                    principalTable: "INMedias",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Skils",
                columns: table => new
            {
                Id      = table.Column <string>(type: "text", nullable: false),
                Content = table.Column <string>(type: "text", nullable: true),
                ImageId = table.Column <string>(type: "text", nullable: true),
                Title   = table.Column <string>(type: "text", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Skils", x => x.Id);
                table.ForeignKey(
                    name: "FK_Skils_INMedias_ImageId",
                    column: x => x.ImageId,
                    principalTable: "INMedias",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Comments",
                columns: table => new
            {
                Id          = table.Column <string>(type: "text", nullable: false),
                AppUserId   = table.Column <string>(type: "text", nullable: true),
                BlogPostId  = table.Column <string>(type: "text", nullable: true),
                CommentText = table.Column <string>(type: "text", nullable: true),
                Visable     = table.Column <bool>(type: "boolean", nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Comments", x => x.Id);
                table.ForeignKey(
                    name: "FK_Comments_AspNetUsers_AppUserId",
                    column: x => x.AppUserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Comments_BlogPosts_BlogPostId",
                    column: x => x.BlogPostId,
                    principalTable: "BlogPosts",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "PostCategories",
                columns: table => new
            {
                BlogPostId = table.Column <string>(type: "text", nullable: false),
                CategoryId = table.Column <string>(type: "text", nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_PostCategories", x => new { x.BlogPostId, x.CategoryId });
                table.ForeignKey(
                    name: "FK_PostCategories_BlogPosts_BlogPostId",
                    column: x => x.BlogPostId,
                    principalTable: "BlogPosts",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_PostCategories_Category_CategoryId",
                    column: x => x.CategoryId,
                    principalTable: "Category",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUsers_ImageId",
                table: "AspNetUsers",
                column: "ImageId");

            migrationBuilder.CreateIndex(
                name: "IX_AboutSkilsSections_ImageId",
                table: "AboutSkilsSections",
                column: "ImageId");

            migrationBuilder.CreateIndex(
                name: "IX_AboutSkilsSections_VideoId",
                table: "AboutSkilsSections",
                column: "VideoId");

            migrationBuilder.CreateIndex(
                name: "IX_BlogPosts_AppUserId",
                table: "BlogPosts",
                column: "AppUserId");

            migrationBuilder.CreateIndex(
                name: "IX_BlogPosts_GalleryId",
                table: "BlogPosts",
                column: "GalleryId");

            migrationBuilder.CreateIndex(
                name: "IX_BlogPosts_PostImageId",
                table: "BlogPosts",
                column: "PostImageId");

            migrationBuilder.CreateIndex(
                name: "IX_Carousels_MediaId",
                table: "Carousels",
                column: "MediaId");

            migrationBuilder.CreateIndex(
                name: "IX_Comments_AppUserId",
                table: "Comments",
                column: "AppUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Comments_BlogPostId",
                table: "Comments",
                column: "BlogPostId");

            migrationBuilder.CreateIndex(
                name: "IX_GalleryINMedias_INMediaId",
                table: "GalleryINMedias",
                column: "INMediaId");

            migrationBuilder.CreateIndex(
                name: "IX_INMediaCategories_CategoryId",
                table: "INMediaCategories",
                column: "CategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_INMedias_TypeId",
                table: "INMedias",
                column: "TypeId");

            migrationBuilder.CreateIndex(
                name: "IX_INServices_ImageId",
                table: "INServices",
                column: "ImageId");

            migrationBuilder.CreateIndex(
                name: "IX_PostCategories_CategoryId",
                table: "PostCategories",
                column: "CategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_Skils_ImageId",
                table: "Skils",
                column: "ImageId");

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUsers_INMedias_ImageId",
                table: "AspNetUsers",
                column: "ImageId",
                principalTable: "INMedias",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
Esempio n. 46
0
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "Id",
                table: "InquiryItems");

            migrationBuilder.AddColumn<int>(
                name: "InventoryId1",
                table: "InquiryItems",
                type: "int",
                nullable: true);

            migrationBuilder.UpdateData(
                table: "Inquirys",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "DateCreated", "DateIssued", "DateUpdated" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 776, DateTimeKind.Local).AddTicks(966), new DateTime(2020, 10, 15, 12, 17, 17, 776, DateTimeKind.Local).AddTicks(557), new DateTime(2020, 10, 15, 12, 17, 17, 776, DateTimeKind.Local).AddTicks(1348) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(514), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(916) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1795), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1806) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 3,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1822), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1823) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 4,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1825), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1826) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 5,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1827), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1829) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 6,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1838), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1839) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 7,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1840), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1841) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 8,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1843), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1844) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 9,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1845), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1846) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 10,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1849), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1850) });

            migrationBuilder.UpdateData(
                table: "Inventories",
                keyColumn: "Id",
                keyValue: 11,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1852), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(1853) });

            migrationBuilder.UpdateData(
                table: "Invoices",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "DateCreated", "DateUpdated" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 775, DateTimeKind.Local).AddTicks(5206), new DateTime(2020, 10, 15, 12, 17, 17, 775, DateTimeKind.Local).AddTicks(5597) });

            migrationBuilder.UpdateData(
                table: "Orders",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "DateCreated", "DateUpdated" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(4935), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(5397) });

            migrationBuilder.UpdateData(
                table: "Orders",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "DateCreated", "DateUpdated" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(5875), new DateTime(2020, 10, 15, 12, 17, 17, 773, DateTimeKind.Local).AddTicks(5904) });

            migrationBuilder.UpdateData(
                table: "Quotations",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "DateCreated", "DateUpdated" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 774, DateTimeKind.Local).AddTicks(6929), new DateTime(2020, 10, 15, 12, 17, 17, 774, DateTimeKind.Local).AddTicks(7333) });

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 770, DateTimeKind.Local).AddTicks(6872), new DateTime(2020, 10, 15, 12, 17, 17, 771, DateTimeKind.Local).AddTicks(5273) });

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "DateCreated", "DateUpdate" },
                values: new object[] { new DateTime(2020, 10, 15, 12, 17, 17, 771, DateTimeKind.Local).AddTicks(5792), new DateTime(2020, 10, 15, 12, 17, 17, 771, DateTimeKind.Local).AddTicks(5837) });

            migrationBuilder.CreateIndex(
                name: "IX_InquiryItems_InventoryId1",
                table: "InquiryItems",
                column: "InventoryId1");

            migrationBuilder.AddForeignKey(
                name: "FK_InquiryItems_Inventories_InventoryId1",
                table: "InquiryItems",
                column: "InventoryId1",
                principalTable: "Inventories",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
                table: "AspNetRoleClaims");

            migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserClaims_AspNetUsers_UserId",
                table: "AspNetUserClaims");

            migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserLogins_AspNetUsers_UserId",
                table: "AspNetUserLogins");

            migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
                table: "AspNetUserRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserRoles_AspNetUsers_UserId",
                table: "AspNetUserRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserTokens_AspNetUsers_UserId",
                table: "AspNetUserTokens");

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
                table: "AspNetRoleClaims",
                column: "RoleId",
                principalTable: "AspNetRoles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserClaims_AspNetUsers_UserId",
                table: "AspNetUserClaims",
                column: "UserId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserLogins_AspNetUsers_UserId",
                table: "AspNetUserLogins",
                column: "UserId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
                table: "AspNetUserRoles",
                column: "RoleId",
                principalTable: "AspNetRoles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserRoles_AspNetUsers_UserId",
                table: "AspNetUserRoles",
                column: "UserId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserTokens_AspNetUsers_UserId",
                table: "AspNetUserTokens",
                column: "UserId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
Esempio n. 48
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn <string>(
                name: "Password",
                table: "Users",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)");

            migrationBuilder.AlterColumn <string>(
                name: "Name",
                table: "Users",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)");

            migrationBuilder.AddColumn <int>(
                name: "RentalId",
                table: "EquipmentList",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "Rental",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                SerialNumber = table.Column <string>(nullable: true),
                Name         = table.Column <string>(nullable: true),
                IsApproved   = table.Column <bool>(nullable: false),
                FeedBack     = table.Column <string>(nullable: true),
                CategoryId   = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Rental", x => x.Id);
                table.ForeignKey(
                    name: "FK_Rental_Categories_CategoryId",
                    column: x => x.CategoryId,
                    principalTable: "Categories",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.UpdateData(
                table: "EquipmentList",
                keyColumn: "Id",
                keyValue: 1,
                column: "RentalDates",
                value: ",");

            migrationBuilder.CreateIndex(
                name: "IX_EquipmentList_RentalId",
                table: "EquipmentList",
                column: "RentalId");

            migrationBuilder.CreateIndex(
                name: "IX_Rental_CategoryId",
                table: "Rental",
                column: "CategoryId");

            migrationBuilder.AddForeignKey(
                name: "FK_EquipmentList_Rental_RentalId",
                table: "EquipmentList",
                column: "RentalId",
                principalTable: "Rental",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
Esempio n. 49
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ATMs_ATMSources_SourceTradePointSourceId_SourceDataFileType",
                table: "ATMs");

            migrationBuilder.DropForeignKey(
                name: "FK_InfoKiosks_InfoKioskSources_SourceTradePointSourceId_SourceDataFileType",
                table: "InfoKiosks");

            migrationBuilder.DropForeignKey(
                name: "FK_Offices_OfficeSources_SourceTradePointSourceId_SourceDataFileType",
                table: "Offices");

            migrationBuilder.DropIndex(
                name: "IX_Offices_SourceTradePointSourceId_SourceDataFileType",
                table: "Offices");

            migrationBuilder.DropIndex(
                name: "IX_InfoKiosks_SourceTradePointSourceId_SourceDataFileType",
                table: "InfoKiosks");

            migrationBuilder.DropIndex(
                name: "IX_ATMs_SourceTradePointSourceId_SourceDataFileType",
                table: "ATMs");

            migrationBuilder.DropColumn(
                name: "SourceDataFileType",
                table: "Offices");

            migrationBuilder.DropColumn(
                name: "SourceTradePointSourceId",
                table: "Offices");

            migrationBuilder.DropColumn(
                name: "SourceDataFileType",
                table: "InfoKiosks");

            migrationBuilder.DropColumn(
                name: "SourceTradePointSourceId",
                table: "InfoKiosks");

            migrationBuilder.DropColumn(
                name: "SourceDataFileType",
                table: "ATMs");

            migrationBuilder.DropColumn(
                name: "SourceTradePointSourceId",
                table: "ATMs");

            migrationBuilder.AddColumn<Guid>(
                name: "TradePointId",
                table: "OfficeSources",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "TradePointId",
                table: "InfoKioskSources",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "TradePointId",
                table: "ATMSources",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_OfficeSources_TradePointId",
                table: "OfficeSources",
                column: "TradePointId");

            migrationBuilder.CreateIndex(
                name: "IX_InfoKioskSources_TradePointId",
                table: "InfoKioskSources",
                column: "TradePointId");

            migrationBuilder.CreateIndex(
                name: "IX_ATMSources_TradePointId",
                table: "ATMSources",
                column: "TradePointId");

            migrationBuilder.AddForeignKey(
                name: "FK_ATMSources_ATMs_TradePointId",
                table: "ATMSources",
                column: "TradePointId",
                principalTable: "ATMs",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_InfoKioskSources_InfoKiosks_TradePointId",
                table: "InfoKioskSources",
                column: "TradePointId",
                principalTable: "InfoKiosks",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_OfficeSources_Offices_TradePointId",
                table: "OfficeSources",
                column: "TradePointId",
                principalTable: "Offices",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
Esempio n. 50
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn <string>(
                name: "UserId",
                table: "Products",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "AspNetRoles",
                columns: table => new
            {
                Id               = table.Column <string>(nullable: false),
                Name             = table.Column <string>(maxLength: 256, nullable: true),
                NormalizedName   = table.Column <string>(maxLength: 256, nullable: true),
                ConcurrencyStamp = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetRoles", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUsers",
                columns: table => new
            {
                Id                   = table.Column <string>(nullable: false),
                UserName             = table.Column <string>(maxLength: 256, nullable: true),
                NormalizedUserName   = table.Column <string>(maxLength: 256, nullable: true),
                Email                = table.Column <string>(maxLength: 256, nullable: true),
                NormalizedEmail      = table.Column <string>(maxLength: 256, nullable: true),
                EmailConfirmed       = table.Column <bool>(nullable: false),
                PasswordHash         = table.Column <string>(nullable: true),
                SecurityStamp        = table.Column <string>(nullable: true),
                ConcurrencyStamp     = table.Column <string>(nullable: true),
                PhoneNumber          = table.Column <string>(nullable: true),
                PhoneNumberConfirmed = table.Column <bool>(nullable: false),
                TwoFactorEnabled     = table.Column <bool>(nullable: false),
                LockoutEnd           = table.Column <DateTimeOffset>(nullable: true),
                LockoutEnabled       = table.Column <bool>(nullable: false),
                AccessFailedCount    = table.Column <int>(nullable: false),
                FirstName            = table.Column <string>(nullable: true),
                LastName             = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUsers", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "AspNetRoleClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                RoleId     = table.Column <string>(nullable: false),
                ClaimType  = table.Column <string>(nullable: true),
                ClaimValue = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
                table.ForeignKey(
                    name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
                    column: x => x.RoleId,
                    principalTable: "AspNetRoles",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUserClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                UserId     = table.Column <string>(nullable: false),
                ClaimType  = table.Column <string>(nullable: true),
                ClaimValue = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
                table.ForeignKey(
                    name: "FK_AspNetUserClaims_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUserLogins",
                columns: table => new
            {
                LoginProvider       = table.Column <string>(nullable: false),
                ProviderKey         = table.Column <string>(nullable: false),
                ProviderDisplayName = table.Column <string>(nullable: true),
                UserId = table.Column <string>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
                table.ForeignKey(
                    name: "FK_AspNetUserLogins_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUserRoles",
                columns: table => new
            {
                UserId = table.Column <string>(nullable: false),
                RoleId = table.Column <string>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
                table.ForeignKey(
                    name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
                    column: x => x.RoleId,
                    principalTable: "AspNetRoles",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AspNetUserRoles_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUserTokens",
                columns: table => new
            {
                UserId        = table.Column <string>(nullable: false),
                LoginProvider = table.Column <string>(nullable: false),
                Name          = table.Column <string>(nullable: false),
                Value         = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
                table.ForeignKey(
                    name: "FK_AspNetUserTokens_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Products_UserId",
                table: "Products",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetRoleClaims_RoleId",
                table: "AspNetRoleClaims",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles",
                column: "NormalizedName",
                unique: true,
                filter: "[NormalizedName] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserClaims_UserId",
                table: "AspNetUserClaims",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserLogins_UserId",
                table: "AspNetUserLogins",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserRoles_RoleId",
                table: "AspNetUserRoles",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "EmailIndex",
                table: "AspNetUsers",
                column: "NormalizedEmail");

            migrationBuilder.CreateIndex(
                name: "UserNameIndex",
                table: "AspNetUsers",
                column: "NormalizedUserName",
                unique: true,
                filter: "[NormalizedUserName] IS NOT NULL");

            migrationBuilder.AddForeignKey(
                name: "FK_Products_AspNetUsers_UserId",
                table: "Products",
                column: "UserId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn <string>(
                name: "LastName",
                table: "Student",
                maxLength: 50,
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 50,
                oldNullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "FirstName",
                table: "Student",
                maxLength: 50,
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 50,
                oldNullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "Title",
                table: "Course",
                maxLength: 50,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            //  migrationBuilder.AddColumn<int>(
            //    name: "DepartmentID",
            //  table: "Course",
            //  nullable: false,
            //  defaultValue: 0);

            migrationBuilder.CreateTable(
                name: "Instructor",
                columns: table => new
            {
                ID = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                LastName  = table.Column <string>(maxLength: 50, nullable: false),
                FirstName = table.Column <string>(maxLength: 50, nullable: false),
                HireDate  = table.Column <DateTime>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Instructor", x => x.ID);
            });

            migrationBuilder.CreateTable(
                name: "CourseAssignment",
                columns: table => new
            {
                InstructorID = table.Column <int>(nullable: false),
                CourseID     = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_CourseAssignment", x => new { x.CourseID, x.InstructorID });
                table.ForeignKey(
                    name: "FK_CourseAssignment_Course_CourseID",
                    column: x => x.CourseID,
                    principalTable: "Course",
                    principalColumn: "CourseID",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_CourseAssignment_Instructor_InstructorID",
                    column: x => x.InstructorID,
                    principalTable: "Instructor",
                    principalColumn: "ID",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Department",
                columns: table => new
            {
                DepartmentID = table.Column <int>(nullable: false)
                               .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name         = table.Column <string>(maxLength: 50, nullable: true),
                Budget       = table.Column <decimal>(type: "money", nullable: false),
                StartDate    = table.Column <DateTime>(nullable: false),
                InstructorID = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Department", x => x.DepartmentID);
                table.ForeignKey(
                    name: "FK_Department_Instructor_InstructorID",
                    column: x => x.InstructorID,
                    principalTable: "Instructor",
                    principalColumn: "ID",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.Sql("INSERT INTO dbo.Department (Name, Budget, StartDate) VALUES ('Temp', 0.00, GETDATE())");
            // Default value for FK points to department created above, with
            // defaultValue changed to 1 in following AddColumn statement.

            migrationBuilder.AddColumn <int>(
                name: "DepartmentID",
                table: "Course",
                nullable: false,
                defaultValue: 1);

            migrationBuilder.CreateTable(
                name: "OfficeAssignment",
                columns: table => new
            {
                InstructorID = table.Column <int>(nullable: false),
                Location     = table.Column <string>(maxLength: 50, nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_OfficeAssignment", x => x.InstructorID);
                table.ForeignKey(
                    name: "FK_OfficeAssignment_Instructor_InstructorID",
                    column: x => x.InstructorID,
                    principalTable: "Instructor",
                    principalColumn: "ID",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Course_DepartmentID",
                table: "Course",
                column: "DepartmentID");

            migrationBuilder.CreateIndex(
                name: "IX_CourseAssignment_InstructorID",
                table: "CourseAssignment",
                column: "InstructorID");

            migrationBuilder.CreateIndex(
                name: "IX_Department_InstructorID",
                table: "Department",
                column: "InstructorID");

            migrationBuilder.AddForeignKey(
                name: "FK_Course_Department_DepartmentID",
                table: "Course",
                column: "DepartmentID",
                principalTable: "Department",
                principalColumn: "DepartmentID",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Eventos_UnidadesSesi_UnidadeId",
                table: "Eventos");

            migrationBuilder.DropForeignKey(
                name: "FK_FuncionariosUnidadesFavoritas_UnidadesSesi_UnidadeId",
                table: "FuncionariosUnidadesFavoritas");

            migrationBuilder.DropForeignKey(
                name: "FK_Pesquisas_Empresas_EmpresaId",
                table: "Pesquisas");

            migrationBuilder.RenameColumn(
                name: "EmpresaId",
                table: "Pesquisas",
                newName: "EmpresaDomainId");

            migrationBuilder.RenameIndex(
                name: "IX_Pesquisas_EmpresaId",
                table: "Pesquisas",
                newName: "IX_Pesquisas_EmpresaDomainId");

            migrationBuilder.RenameColumn(
                name: "NomePermissao",
                table: "Permissoes",
                newName: "Permissao");

            migrationBuilder.RenameColumn(
                name: "Descricao",
                table: "Perguntas",
                newName: "Pergunta");

            migrationBuilder.RenameColumn(
                name: "UnidadeId",
                table: "FuncionariosUnidadesFavoritas",
                newName: "UnidadeSesiId");

            migrationBuilder.RenameIndex(
                name: "IX_FuncionariosUnidadesFavoritas_UnidadeId",
                table: "FuncionariosUnidadesFavoritas",
                newName: "IX_FuncionariosUnidadesFavoritas_UnidadeSesiId");

            migrationBuilder.RenameColumn(
                name: "UnidadeId",
                table: "Eventos",
                newName: "UnidadeFavoritaId");

            migrationBuilder.RenameIndex(
                name: "IX_Eventos_UnidadeId",
                table: "Eventos",
                newName: "IX_Eventos_UnidadeFavoritaId");

            migrationBuilder.RenameColumn(
                name: "Descricao",
                table: "Alternativas",
                newName: "Resposta");

            migrationBuilder.AddColumn <DateTime>(
                name: "DataAlteracao",
                table: "Dicas",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddForeignKey(
                name: "FK_Eventos_UnidadesSesi_UnidadeFavoritaId",
                table: "Eventos",
                column: "UnidadeFavoritaId",
                principalTable: "UnidadesSesi",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_FuncionariosUnidadesFavoritas_UnidadesSesi_UnidadeSesiId",
                table: "FuncionariosUnidadesFavoritas",
                column: "UnidadeSesiId",
                principalTable: "UnidadesSesi",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Pesquisas_Empresas_EmpresaDomainId",
                table: "Pesquisas",
                column: "EmpresaDomainId",
                principalTable: "Empresas",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Insurances_Forms_IDForm",
                table: "Insurances");

            migrationBuilder.DropForeignKey(
                name: "FK_Insurances_PriceLists_IDPriceList",
                table: "Insurances");

            migrationBuilder.DropTable(
                name: "Forms");

            migrationBuilder.DropIndex(
                name: "IX_Insurances_IDForm",
                table: "Insurances");

            migrationBuilder.DropIndex(
                name: "IX_Insurances_IDPriceList",
                table: "Insurances");

            migrationBuilder.DropColumn(
                name: "IDForm",
                table: "Insurances");

            migrationBuilder.DropColumn(
                name: "IDPriceList",
                table: "Insurances");

            migrationBuilder.RenameColumn(
                name: "IDPriceList",
                table: "PriceLists",
                newName: "IDTypeInsurance");

            migrationBuilder.AddColumn <int>(
                name: "IDTypeInsurance",
                table: "PolicyDetails",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn <string>(
                name: "IDUser",
                table: "PolicyDetails",
                type: "nvarchar(450)",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "IDUser",
                table: "Insurances",
                type: "nvarchar(450)",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_PolicyDetails_IDTypeInsurance",
                table: "PolicyDetails",
                column: "IDTypeInsurance");

            migrationBuilder.CreateIndex(
                name: "IX_PolicyDetails_IDUser",
                table: "PolicyDetails",
                column: "IDUser");

            migrationBuilder.CreateIndex(
                name: "IX_Insurances_IDUser",
                table: "Insurances",
                column: "IDUser");

            migrationBuilder.AddForeignKey(
                name: "FK_Insurances_AspNetUsers_IDUser",
                table: "Insurances",
                column: "IDUser",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PolicyDetails_AspNetUsers_IDUser",
                table: "PolicyDetails",
                column: "IDUser",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PolicyDetails_PriceLists_IDTypeInsurance",
                table: "PolicyDetails",
                column: "IDTypeInsurance",
                principalTable: "PriceLists",
                principalColumn: "IDTypeInsurance",
                onDelete: ReferentialAction.Cascade);
        }
Esempio n. 54
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn <int>(
                name: "BrandId",
                table: "Products",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn <int>(
                name: "CategoryId",
                table: "Products",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn <DateTime>(
                name: "CreatedDate",
                table: "Products",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn <double>(
                name: "Price",
                table: "Products",
                type: "float",
                nullable: false,
                defaultValue: 0.0);

            migrationBuilder.AddColumn <int>(
                name: "StorageId",
                table: "Products",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateTable(
                name: "Brands",
                columns: table => new
            {
                Id = table.Column <int>(type: "int", nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name = table.Column <string>(type: "nvarchar(max)", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Brands", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Categories",
                columns: table => new
            {
                Id = table.Column <int>(type: "int", nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name = table.Column <string>(type: "nvarchar(max)", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Categories", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Storages",
                columns: table => new
            {
                Id = table.Column <int>(type: "int", nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Count = table.Column <int>(type: "int", nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Storages", x => x.Id);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Products_BrandId",
                table: "Products",
                column: "BrandId");

            migrationBuilder.CreateIndex(
                name: "IX_Products_CategoryId",
                table: "Products",
                column: "CategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_Products_StorageId",
                table: "Products",
                column: "StorageId",
                unique: true);

            migrationBuilder.AddForeignKey(
                name: "FK_Products_Brands_BrandId",
                table: "Products",
                column: "BrandId",
                principalTable: "Brands",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Products_Categories_CategoryId",
                table: "Products",
                column: "CategoryId",
                principalTable: "Categories",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Products_Storages_StorageId",
                table: "Products",
                column: "StorageId",
                principalTable: "Storages",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Hotels_Addresses_AddressId",
                table: "Hotels");

            migrationBuilder.DropForeignKey(
                name: "FK_Hotels_Amenities_AmenityId",
                table: "Hotels");

            migrationBuilder.DropForeignKey(
                name: "FK_Hotels_Infos_InfoId",
                table: "Hotels");

            migrationBuilder.DropColumn(
                name: "ReviewId",
                table: "Hotels");

            migrationBuilder.DropColumn(
                name: "RoomId",
                table: "Hotels");

            migrationBuilder.DropColumn(
                name: "StayId",
                table: "Hotels");

            migrationBuilder.AlterColumn <int>(
                name: "InfoId",
                table: "Hotels",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn <int>(
                name: "AmenityId",
                table: "Hotels",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn <int>(
                name: "AddressId",
                table: "Hotels",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AddForeignKey(
                name: "FK_Hotels_Addresses_AddressId",
                table: "Hotels",
                column: "AddressId",
                principalTable: "Addresses",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Hotels_Amenities_AmenityId",
                table: "Hotels",
                column: "AmenityId",
                principalTable: "Amenities",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Hotels_Infos_InfoId",
                table: "Hotels",
                column: "InfoId",
                principalTable: "Infos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
Esempio n. 56
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_IndustrialProperties_ProviderModels_ProviderModelId",
                table: "IndustrialProperties");

            migrationBuilder.DropForeignKey(
                name: "FK_OnSaleProperties_ProviderModels_ProviderModelId",
                table: "OnSaleProperties");

            migrationBuilder.DropForeignKey(
                name: "FK_RentalProperties_ProviderModels_ProviderModelId",
                table: "RentalProperties");

            migrationBuilder.AlterColumn <int>(
                name: "ProviderModelId",
                table: "RentalProperties",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "int",
                oldNullable: true);

            migrationBuilder.AlterColumn <int>(
                name: "ProviderModelId",
                table: "OnSaleProperties",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "int",
                oldNullable: true);

            migrationBuilder.AlterColumn <int>(
                name: "ProviderModelId",
                table: "IndustrialProperties",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "int",
                oldNullable: true);

            migrationBuilder.AddForeignKey(
                name: "FK_IndustrialProperties_ProviderModels_ProviderModelId",
                table: "IndustrialProperties",
                column: "ProviderModelId",
                principalTable: "ProviderModels",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_OnSaleProperties_ProviderModels_ProviderModelId",
                table: "OnSaleProperties",
                column: "ProviderModelId",
                principalTable: "ProviderModels",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_RentalProperties_ProviderModels_ProviderModelId",
                table: "RentalProperties",
                column: "ProviderModelId",
                principalTable: "ProviderModels",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_CompanyModule_Module_moduleId", table: "CompanyModule");
     migrationBuilder.DropForeignKey(name: "FK_Contact_Item_Contact_contactId", table: "Contact_Item");
     migrationBuilder.DropForeignKey(name: "FK_Ferias_Funcionario_funcionarioId", table: "Ferias");
     migrationBuilder.DropForeignKey(name: "FK_Ferias_Itens_Funcionario_funcionarioId", table: "Ferias_Itens");
     migrationBuilder.DropForeignKey(name: "FK_FuncFerias_Funcionario_funcionarioId", table: "FuncFerias");
     migrationBuilder.DropForeignKey(name: "FK_FuncInfFerias_Funcionario_funcionarioId", table: "FuncInfFerias");
     migrationBuilder.DropForeignKey(name: "FK_Funcionario_Departamento_departamentoId", table: "Funcionario");
     migrationBuilder.DropForeignKey(name: "FK_Historio_Ferias_Item_Ferias_Itens_ferias_item_id", table: "Historio_Ferias_Item");
     migrationBuilder.AddColumn <int>(
         name: "feriasInfFeriasId",
         table: "Ferias_Itens",
         nullable: true);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
         table: "AspNetUserLogins",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_CompanyModule_Module_moduleId",
         table: "CompanyModule",
         column: "moduleId",
         principalTable: "Module",
         principalColumn: "id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Contact_Item_Contact_contactId",
         table: "Contact_Item",
         column: "contactId",
         principalTable: "Contact",
         principalColumn: "id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Ferias_Funcionario_funcionarioId",
         table: "Ferias",
         column: "funcionarioId",
         principalTable: "Funcionario",
         principalColumn: "id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Ferias_Itens_FuncInfFerias_feriasInfFeriasId",
         table: "Ferias_Itens",
         column: "feriasInfFeriasId",
         principalTable: "FuncInfFerias",
         principalColumn: "id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_Ferias_Itens_Funcionario_funcionarioId",
         table: "Ferias_Itens",
         column: "funcionarioId",
         principalTable: "Funcionario",
         principalColumn: "id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_FuncFerias_Funcionario_funcionarioId",
         table: "FuncFerias",
         column: "funcionarioId",
         principalTable: "Funcionario",
         principalColumn: "id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_FuncInfFerias_Funcionario_funcionarioId",
         table: "FuncInfFerias",
         column: "funcionarioId",
         principalTable: "Funcionario",
         principalColumn: "id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Funcionario_Departamento_departamentoId",
         table: "Funcionario",
         column: "departamentoId",
         principalTable: "Departamento",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
     migrationBuilder.AddForeignKey(
         name: "FK_Historio_Ferias_Item_Ferias_Itens_ferias_item_id",
         table: "Historio_Ferias_Item",
         column: "ferias_item_id",
         principalTable: "Ferias_Itens",
         principalColumn: "id",
         onDelete: ReferentialAction.Cascade);
 }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Eventos_UnidadesSesi_UnidadeFavoritaId",
                table: "Eventos");

            migrationBuilder.DropForeignKey(
                name: "FK_FuncionariosUnidadesFavoritas_UnidadesSesi_UnidadeSesiId",
                table: "FuncionariosUnidadesFavoritas");

            migrationBuilder.DropForeignKey(
                name: "FK_Pesquisas_Empresas_EmpresaDomainId",
                table: "Pesquisas");

            migrationBuilder.DropColumn(
                name: "DataAlteracao",
                table: "Dicas");

            migrationBuilder.RenameColumn(
                name: "EmpresaDomainId",
                table: "Pesquisas",
                newName: "EmpresaId");

            migrationBuilder.RenameIndex(
                name: "IX_Pesquisas_EmpresaDomainId",
                table: "Pesquisas",
                newName: "IX_Pesquisas_EmpresaId");

            migrationBuilder.RenameColumn(
                name: "Permissao",
                table: "Permissoes",
                newName: "NomePermissao");

            migrationBuilder.RenameColumn(
                name: "Pergunta",
                table: "Perguntas",
                newName: "Descricao");

            migrationBuilder.RenameColumn(
                name: "UnidadeSesiId",
                table: "FuncionariosUnidadesFavoritas",
                newName: "UnidadeId");

            migrationBuilder.RenameIndex(
                name: "IX_FuncionariosUnidadesFavoritas_UnidadeSesiId",
                table: "FuncionariosUnidadesFavoritas",
                newName: "IX_FuncionariosUnidadesFavoritas_UnidadeId");

            migrationBuilder.RenameColumn(
                name: "UnidadeFavoritaId",
                table: "Eventos",
                newName: "UnidadeId");

            migrationBuilder.RenameIndex(
                name: "IX_Eventos_UnidadeFavoritaId",
                table: "Eventos",
                newName: "IX_Eventos_UnidadeId");

            migrationBuilder.RenameColumn(
                name: "Resposta",
                table: "Alternativas",
                newName: "Descricao");

            migrationBuilder.AddForeignKey(
                name: "FK_Eventos_UnidadesSesi_UnidadeId",
                table: "Eventos",
                column: "UnidadeId",
                principalTable: "UnidadesSesi",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_FuncionariosUnidadesFavoritas_UnidadesSesi_UnidadeId",
                table: "FuncionariosUnidadesFavoritas",
                column: "UnidadeId",
                principalTable: "UnidadesSesi",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Pesquisas_Empresas_EmpresaId",
                table: "Pesquisas",
                column: "EmpresaId",
                principalTable: "Empresas",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
Esempio n. 59
0
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ExchangeRates_Assets_AssetBaseAssetId_AssetBaseIsTypeCrypto",
                table: "ExchangeRates");

            migrationBuilder.DropForeignKey(
                name: "FK_ExchangeRates_Assets_AssetQuoteAssetId_AssetQuoteIsTypeCrypto",
                table: "ExchangeRates");

            migrationBuilder.DropIndex(
                name: "IX_ExchangeRates_AssetBaseAssetId_AssetBaseIsTypeCrypto",
                table: "ExchangeRates");

            migrationBuilder.DropIndex(
                name: "IX_ExchangeRates_AssetQuoteAssetId_AssetQuoteIsTypeCrypto",
                table: "ExchangeRates");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Assets",
                table: "Assets");

            migrationBuilder.DropColumn(
                name: "AssetBaseAssetId",
                table: "ExchangeRates");

            migrationBuilder.DropColumn(
                name: "AssetBaseIsTypeCrypto",
                table: "ExchangeRates");

            migrationBuilder.DropColumn(
                name: "AssetQuoteAssetId",
                table: "ExchangeRates");

            migrationBuilder.DropColumn(
                name: "AssetQuoteIsTypeCrypto",
                table: "ExchangeRates");

            migrationBuilder.AlterColumn <string>(
                name: "AssetQuoteId",
                table: "ExchangeRates",
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "AssetBaseId",
                table: "ExchangeRates",
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_Assets",
                table: "Assets",
                column: "AssetId");

            migrationBuilder.CreateIndex(
                name: "IX_ExchangeRates_AssetBaseId",
                table: "ExchangeRates",
                column: "AssetBaseId");

            migrationBuilder.CreateIndex(
                name: "IX_ExchangeRates_AssetQuoteId",
                table: "ExchangeRates",
                column: "AssetQuoteId");

            migrationBuilder.AddForeignKey(
                name: "FK_ExchangeRates_Assets_AssetBaseId",
                table: "ExchangeRates",
                column: "AssetBaseId",
                principalTable: "Assets",
                principalColumn: "AssetId",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ExchangeRates_Assets_AssetQuoteId",
                table: "ExchangeRates",
                column: "AssetQuoteId",
                principalTable: "Assets",
                principalColumn: "AssetId",
                onDelete: ReferentialAction.Restrict);
        }
Esempio n. 60
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "UserNameIndex",
                table: "AspNetUsers");

            migrationBuilder.DropIndex(
                name: "IX_AspNetUserRoles_UserId",
                table: "AspNetUserRoles");

            migrationBuilder.DropIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles");

            migrationBuilder.CreateTable(
                name: "Conversationses",
                columns: table => new
            {
                ConversationId = table.Column <int>(nullable: false)
                                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                FirstUserId  = table.Column <string>(nullable: true),
                SecondUserId = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Conversationses", x => x.ConversationId);
                table.ForeignKey(
                    name: "FK_Conversationses_AspNetUsers_FirstUserId",
                    column: x => x.FirstUserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Conversationses_AspNetUsers_SecondUserId",
                    column: x => x.SecondUserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateIndex(
                name: "UserNameIndex",
                table: "AspNetUsers",
                column: "NormalizedUserName",
                unique: true,
                filter: "[NormalizedUserName] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles",
                column: "NormalizedName",
                unique: true,
                filter: "[NormalizedName] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_Conversationses_FirstUserId",
                table: "Conversationses",
                column: "FirstUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Conversationses_SecondUserId",
                table: "Conversationses",
                column: "SecondUserId");

            migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserTokens_AspNetUsers_UserId",
                table: "AspNetUserTokens",
                column: "UserId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }