public override void Down(MigrationBuilder migration)
 {
     migration.DropSequence("DefaultSequence");
     migration.DropTable("Role");
     migration.DropTable("User");
     migration.DropTable("UserRole");
 }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Core_RoleClaim");

            migrationBuilder.DropTable(
                name: "Core_UserClaim");

            migrationBuilder.DropTable(
                name: "Core_UserLogin");

            migrationBuilder.DropTable(
                name: "Core_UserRole");

            migrationBuilder.DropTable(
                name: "Core_UserToken");

            migrationBuilder.DropTable(
                name: "Core_Product");

            migrationBuilder.DropTable(
                name: "ModuleA_Sample");

            migrationBuilder.DropTable(
                name: "ModuleB_Sample");

            migrationBuilder.DropTable(
                name: "Core_Role");

            migrationBuilder.DropTable(
                name: "Core_User");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "csids_PersistedGrants",
                columns: table => new
                {
                    Key = table.Column<string>(nullable: false),
                    Type = table.Column<string>(nullable: false),
                    ClientId = table.Column<string>(maxLength: 200, nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    Data = table.Column<string>(nullable: false),
                    Expiration = table.Column<DateTime>(nullable: false),
                    SiteId = table.Column<string>(maxLength: 36, nullable: false),
                    SubjectId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_csids_PersistedGrants", x => new { x.Key, x.Type });
                });

            migrationBuilder.CreateIndex(
                name: "IX_csids_PersistedGrants_SiteId",
                table: "csids_PersistedGrants",
                column: "SiteId");
        }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "Category",
         columns: table => new
         {
             CategoryId = table.Column<int>(nullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             CategoryName = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Category", x => x.CategoryId);
         });
     migrationBuilder.CreateTable(
         name: "Product",
         columns: table => new
         {
             ProductId = table.Column<int>(nullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             CategoryId = table.Column<int>(nullable: false),
             Price = table.Column<int>(nullable: false),
             ProductName = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Product", x => x.ProductId);
             table.ForeignKey(
                 name: "FK_Product_Category_CategoryId",
                 column: x => x.CategoryId,
                 principalTable: "Category",
                 principalColumn: "CategoryId",
                 onDelete: ReferentialAction.Cascade);
         });
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.AddColumn<string>(
         name: "PrivacyPolicyUrl",
         table: "Organization",
         nullable: true);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "Rating",
         columns: table => new
         {
             RateId = table.Column<int>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             Email = table.Column<string>(nullable: true),
             PostId = table.Column<int>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Rating", x => x.RateId);
             table.ForeignKey(
                 name: "FK_Rating_Post_PostId",
                 column: x => x.PostId,
                 principalTable: "Post",
                 principalColumn: "Id");
         });
     migrationBuilder.AlterColumn<string>(
         name: "Name",
         table: "Post",
         nullable: true);
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Products_ProductsWithMaintenance_MaintenanceId",
                table: "Products");

            migrationBuilder.DropIndex(
                name: "IX_Products_MaintenanceId",
                table: "Products");

            migrationBuilder.DropColumn(
                name: "MaintenanceId",
                table: "Products");

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

            migrationBuilder.CreateIndex(
                name: "IX_ProductsWithMaintenance_ProductId",
                table: "ProductsWithMaintenance",
                column: "ProductId",
                unique: true);

            migrationBuilder.AddForeignKey(
                name: "FK_ProductsWithMaintenance_Products_ProductId",
                table: "ProductsWithMaintenance",
                column: "ProductId",
                principalTable: "Products",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_TvChannelListingSource_TvChannel_TvChannelId", table: "TvChannelListingSource");
     migrationBuilder.DropForeignKey(name: "FK_TvChannelListingSource_TvListingSource_TvListingSourceId", table: "TvChannelListingSource");
     migrationBuilder.DropForeignKey(name: "FK_TvProgramBroadCastListing_TvChannel_TvChannelId", table: "TvProgramBroadCastListing");
     migrationBuilder.DropForeignKey(name: "FK_TvProgramBroadCastListing_TvProgramBroadCastListingImport_TvProgramBroadCastListingImportId", table: "TvProgramBroadCastListing");
     migrationBuilder.DropForeignKey(name: "FK_TvProgramBroadCastListing_TvProgram_TvProgramId", table: "TvProgramBroadCastListing");
     migrationBuilder.DropForeignKey(name: "FK_TvProgramBroadCastListingImport_TvListingSource_TvListingSourceId", table: "TvProgramBroadCastListingImport");
     migrationBuilder.DropForeignKey(name: "FK_TvProgramEpisode_TvProgram_TvProgramId", table: "TvProgramEpisode");
     migrationBuilder.DropColumn(name: "Language", table: "TvChannel");
     migrationBuilder.AddForeignKey(
         name: "FK_TvChannelListingSource_TvChannel_TvChannelId",
         table: "TvChannelListingSource",
         column: "TvChannelId",
         principalTable: "TvChannel",
         principalColumn: "TvChannelId",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_TvChannelListingSource_TvListingSource_TvListingSourceId",
         table: "TvChannelListingSource",
         column: "TvListingSourceId",
         principalTable: "TvListingSource",
         principalColumn: "TvListingSourceId",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_TvProgramBroadCastListing_TvChannel_TvChannelId",
         table: "TvProgramBroadCastListing",
         column: "TvChannelId",
         principalTable: "TvChannel",
         principalColumn: "TvChannelId",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_TvProgramBroadCastListing_TvProgramBroadCastListingImport_TvProgramBroadCastListingImportId",
         table: "TvProgramBroadCastListing",
         column: "TvProgramBroadCastListingImportId",
         principalTable: "TvProgramBroadCastListingImport",
         principalColumn: "TvProgramBroadCastListingImportId",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_TvProgramBroadCastListing_TvProgram_TvProgramId",
         table: "TvProgramBroadCastListing",
         column: "TvProgramId",
         principalTable: "TvProgram",
         principalColumn: "TvProgramId",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_TvProgramBroadCastListingImport_TvListingSource_TvListingSourceId",
         table: "TvProgramBroadCastListingImport",
         column: "TvListingSourceId",
         principalTable: "TvListingSource",
         principalColumn: "TvListingSourceId",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_TvProgramEpisode_TvProgram_TvProgramId",
         table: "TvProgramEpisode",
         column: "TvProgramId",
         principalTable: "TvProgram",
         principalColumn: "TvProgramId",
         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.Sql(@"Alter view HierarchyPosts as
                             WITH    cte ( Id, ParentPostId, Depth, RootId )
                                             AS ( SELECT   Id,
                                                         ReplyToPostId,
                                                         0 as TheLevel,
                                                         Id as RootId
                                                 FROM     posts
                                                 where ReplyToPostId is null
                                                 And IsDeleted = 0
                                                 UNION ALL
                                                 SELECT   pn.Id,
                                                         pn.ReplyToPostId,
                                                         p1.Depth +1,
                                                         p1.RootId
                                                 FROM    Posts pn
                                                 INNER JOIN cte AS p1 on p1.Id = pn.ReplyToPostId
                                                 Where   pn.IsDeleted = 0
                                                 )
                             select cte.Id as PostId, ReplyToPostId, Depth, ForumId, LastChangedDate, PublishDate, Title, Body, IsModified, U.UserName, u.Id as UserId, RootId, IsDeleted, IsImportantReply
                             from  cte
                             INNER JOIN POSTS P ON CTE.ID = P.ID
                             INNER JOIN USERS u ON U.id = p.UserId");
 }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "cs_Currency",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "newid()"),
                    Code = table.Column<string>(nullable: false),
                    CultureCode = table.Column<string>(nullable: false),
                    Title = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_cs_Currency", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_cs_Currency_Code",
                table: "cs_Currency",
                column: "Code");

            migrationBuilder.CreateIndex(
                name: "IX_cs_Currency_CultureCode",
                table: "cs_Currency",
                column: "CultureCode");
        }
 public override void Up(MigrationBuilder migration)
 {
     migration.DropColumn(name: "Logo", table: "Teams");
     migration.AddColumn(
         name: "CheerleaderImage",
         table: "Teams",
         type: "nvarchar(max)",
         nullable: true);
     migration.AddColumn(
         name: "CoachImage",
         table: "Teams",
         type: "nvarchar(max)",
         nullable: true);
     migration.AddColumn(
         name: "DivisionId",
         table: "Teams",
         type: "int",
         nullable: true);
     migration.AddColumn(
         name: "HeaderImage",
         table: "Teams",
         type: "nvarchar(max)",
         nullable: true);
     migration.AddColumn(
         name: "LogoImage",
         table: "Teams",
         type: "nvarchar(max)",
         nullable: true);
     migration.AddForeignKey(
         name: "FK_Team_Division_DivisionId",
         table: "Teams",
         column: "DivisionId",
         referencedTable: "Divisions",
         referencedColumn: "DivisionId");
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "Blog",
         columns: table => new
         {
             BlogId = table.Column<int>(nullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             Url = table.Column<string>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Blog", x => x.BlogId);
         });
     migrationBuilder.CreateTable(
         name: "Post",
         columns: table => new
         {
             PostId = table.Column<int>(nullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             BlogId = table.Column<int>(nullable: false),
             Content = table.Column<string>(nullable: true),
             Title = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Post", x => x.PostId);
             table.ForeignKey(
                 name: "FK_Post_Blog_BlogId",
                 column: x => x.BlogId,
                 principalTable: "Blog",
                 principalColumn: "BlogId",
                 onDelete: ReferentialAction.Cascade);
         });
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Toast",
                columns: table => new
                {
                    ToastId = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    BeerId = table.Column<int>(nullable: false),
                    DateTime = table.Column<DateTime>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    Grade = table.Column<double>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Toast", x => x.ToastId);
                    table.ForeignKey(
                        name: "FK_Toast_Beers_BeerId",
                        column: x => x.BeerId,
                        principalTable: "Beers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Toast_BeerId",
                table: "Toast",
                column: "BeerId");
        }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable("PostTag");
     migrationBuilder.DropTable("Post");
     migrationBuilder.DropTable("Tag");
     migrationBuilder.DropTable("Category");
 }
 public override void Up(MigrationBuilder migration)
 {
     migration.CreateTable(
         name: "Blog",
         columns: table => new
         {
             BlogId = table.Column(type: "int", nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", "IdentityColumn"),
             Url = table.Column(type: "nvarchar(max)", nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Blog", x => x.BlogId);
         });
     migration.CreateTable(
         name: "Post",
         columns: table => new
         {
             PostId = table.Column(type: "int", nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", "IdentityColumn"),
             BlogId = table.Column(type: "int", nullable: false),
             Content = table.Column(type: "nvarchar(max)", nullable: true),
             Title = table.Column(type: "nvarchar(max)", nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Post", x => x.PostId);
             table.ForeignKey(
                 name: "FK_Post_Blog_BlogId",
                 columns: x => x.BlogId,
                 referencedTable: "Blog",
                 referencedColumn: "BlogId");
         });
 }
 public override void Up(MigrationBuilder migration)
 {
     migration.CreateTable(
         name: "Categoria",
         columns: table => new
         {
             CategoriaID = table.Column(type: "int", nullable: false)
                 .Annotation("SqlServer:ValueGeneration", "Identity"),
             Descripcion = table.Column(type: "nvarchar(max)", nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Categoria", x => x.CategoriaID);
         });
     migration.AddColumn(
         name: "CategoriaID",
         table: "Cursos",
         type: "int",
         nullable: true);
     migration.AddForeignKey(
         name: "FK_Cursos_Categoria_CategoriaID",
         table: "Cursos",
         column: "CategoriaID",
         referencedTable: "Categoria",
         referencedColumn: "CategoriaID");
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable("BookMark");
     migrationBuilder.DropTable("Cover");
     migrationBuilder.DropTable("Book");
     migrationBuilder.DropTable("Source");
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "Item",
         columns: table => new
         {
             ItemId = table.Column<int>(isNullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             BotanicalName = table.Column<string>(isNullable: true),
             CompEase = table.Column<string>(isNullable: true),
             CostDate = table.Column<DateTime>(isNullable: false),
             Description = table.Column<string>(isNullable: true),
             Division = table.Column<string>(isNullable: true),
             ItemNumber = table.Column<string>(isNullable: true),
             LaborHours = table.Column<double>(isNullable: false),
             MaterialCost = table.Column<double>(isNullable: false),
             Name = table.Column<string>(isNullable: true),
             Price = table.Column<double>(isNullable: false),
             RoundedPrice = table.Column<double>(isNullable: false),
             Size = table.Column<string>(isNullable: true),
             Taxable = table.Column<bool>(isNullable: false),
             Warranty = table.Column<bool>(isNullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Item", x => x.ItemId);
         });
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_User_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_User_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_User_UserId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_Tag_TagColor_TagColorId", table: "Tag");
     migrationBuilder.DropForeignKey(name: "FK_Task_Tag_TagId", table: "Task");
     migrationBuilder.DropColumn(name: "Done", table: "Task");
     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>_User_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_User_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>_User_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_Tag_TagColor_TagColorId",
         table: "Tag",
         column: "TagColorId",
         principalTable: "TagColor",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_Task_Tag_TagId",
         table: "Task",
         column: "TagId",
         principalTable: "Tag",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.AddColumn<string>(
         name: "InformationLink",
         table: "Book",
         isNullable: true);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable("ActivitySignup");
     migrationBuilder.DropTable("ActivitySkill");
     migrationBuilder.DropTable("CampaignImpact");
     migrationBuilder.DropTable("CampaignSponsors");
     migrationBuilder.DropTable("Resource");
     migrationBuilder.DropTable("TaskSignup");
     migrationBuilder.DropTable("TaskSkill");
     migrationBuilder.DropTable("UserSkill");
     migrationBuilder.DropTable("AspNetRoleClaims");
     migrationBuilder.DropTable("AspNetUserClaims");
     migrationBuilder.DropTable("AspNetUserLogins");
     migrationBuilder.DropTable("AspNetUserRoles");
     migrationBuilder.DropTable("CampaignImpactType");
     migrationBuilder.DropTable("AllReadyTask");
     migrationBuilder.DropTable("Skill");
     migrationBuilder.DropTable("AspNetRoles");
     migrationBuilder.DropTable("Activity");
     migrationBuilder.DropTable("Campaign");
     migrationBuilder.DropTable("Location");
     migrationBuilder.DropTable("AspNetUsers");
     migrationBuilder.DropTable("PostalCodeGeo");
     migrationBuilder.DropTable("Tenant");
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "Employee",
         columns: table => new
         {
             EmpId = table.Column<int>(nullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             Age = table.Column<int>(nullable: false),
             FirstName = table.Column<string>(nullable: false),
             LastName = table.Column<string>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_EmployeeEntity", x => x.EmpId);
         });
     migrationBuilder.CreateTable(
         name: "Job",
         columns: table => new
         {
             JobId = table.Column<int>(nullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             JobDesc = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_JobEntity", x => x.JobId);
         });
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable("City");
     migrationBuilder.DropTable("Product");
     migrationBuilder.DropTable("Country");
     migrationBuilder.DropTable("Store");
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.EnsureSchema("mab");
     migrationBuilder.CreateTable(
         name: "MicroAggression",
         schema: "mab",
         columns: table => new
         {
             Aggression = table.Column<string>(nullable: false),
             Aggressiveness = table.Column<int>(nullable: false),
             Created = table.Column<DateTime>(nullable: false),
             _Alternatives = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_MicroAggression", x => x.Aggression);
         });
     migrationBuilder.CreateTable(
         name: "Offense",
         schema: "mab",
         columns: table => new
         {
             Id = table.Column<Guid>(nullable: false),
             Offenses = table.Column<int>(nullable: false),
             User = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Offense", x => x.Id);
         });
     migrationBuilder.CreateTable(
         name: "Correction",
         schema: "mab",
         columns: table => new
         {
             Id = table.Column<Guid>(nullable: false),
             Created = table.Column<DateTime>(nullable: false),
             MicroAggressionId = table.Column<string>(nullable: true),
             OffenseId = table.Column<Guid>(nullable: false),
             Tweet = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Correction", x => x.Id);
             table.ForeignKey(
                 name: "FK_Correction_MicroAggression_MicroAggressionId",
                 column: x => x.MicroAggressionId,
                 principalSchema: "mab",
                 principalTable: "MicroAggression",
                 principalColumn: "Aggression",
                 onDelete: ReferentialAction.Restrict);
             table.ForeignKey(
                 name: "FK_Correction_Offense_OffenseId",
                 column: x => x.OffenseId,
                 principalSchema: "mab",
                 principalTable: "Offense",
                 principalColumn: "Id",
                 onDelete: ReferentialAction.Restrict);
         });
 }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.AddColumn<string>(
         name: "LastName",
         table: "Follower",
         isNullable: true);
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.AddColumn<string>(
         name: "Name",
         table: "Uploads",
         nullable: true);
 }
        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 Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.AlterColumn<int>(
         name: "ClassSubmissionType",
         table: "Questions",
         nullable: true);
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Products_ProductCategories_ProjectCategoryProductCategoryId",
                table: "Products");

            migrationBuilder.AlterColumn<int>(
                name: "ProjectCategoryProductCategoryId",
                table: "Products",
                nullable: false);

            migrationBuilder.AlterColumn<string>(
                name: "ProductName",
                table: "Products",
                maxLength: 100,
                nullable: false);

            migrationBuilder.AlterColumn<string>(
                name: "ProductDescription",
                table: "Products",
                maxLength: 1000,
                nullable: false);

            migrationBuilder.AddForeignKey(
                name: "FK_Products_ProductCategories_ProjectCategoryProductCategoryId",
                table: "Products",
                column: "ProjectCategoryProductCategoryId",
                principalTable: "ProductCategories",
                principalColumn: "ProductCategoryId",
                onDelete: ReferentialAction.Cascade);
        }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable(
         name: "Models");
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {

        }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropColumn(
         name: "SnapHitCount",
         table: "EFClientStatistics");
 }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable(
         name: "RequestApprovals");
 }
Exemple #35
0
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable(
         name: "EmailConfirmation");
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Jobs",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ExtensionServiceJobsId = table.Column <int>(nullable: false),
                ExtensionServiceName   = table.Column <string>(nullable: true),
                ExtensionType          = table.Column <string>(nullable: true),
                LibraryName            = table.Column <string>(nullable: true),
                JobType              = table.Column <string>(nullable: true),
                JobState             = table.Column <string>(nullable: true),
                FinalStatus          = table.Column <string>(nullable: true),
                Retries              = table.Column <int>(nullable: false),
                QueueTime            = table.Column <DateTime>(nullable: false),
                StateLastChangedTime = table.Column <DateTime>(nullable: false),
                StartTime            = table.Column <DateTime>(nullable: false),
                EndTime              = table.Column <DateTime>(nullable: false),
                Messages             = table.Column <string>(nullable: true),
                OperationId          = table.Column <Guid>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Jobs", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Logs",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                TimeStamp  = table.Column <DateTime>(nullable: false),
                ThreadId   = table.Column <string>(nullable: true),
                LogMessage = table.Column <string>(nullable: true),
                LogContent = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Logs", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "MetricsModels",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                MachineName  = table.Column <string>(nullable: true),
                TimeStamp    = table.Column <DateTime>(nullable: false),
                Processor    = table.Column <string>(nullable: true),
                Memory       = table.Column <string>(nullable: true),
                PhysicalDisk = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_MetricsModels", x => x.Id);
            });
        }
Exemple #37
0
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropColumn(
         name: "CompletedQuestionnaire",
         table: "Participants");
 }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Products_Brands_BrandId",
                table: "Products");

            migrationBuilder.DropForeignKey(
                name: "FK_Products_OS_OSId",
                table: "Products");

            migrationBuilder.DropTable(
                name: "Brands");

            migrationBuilder.DropTable(
                name: "Images");

            migrationBuilder.DropTable(
                name: "OS");

            migrationBuilder.DropTable(
                name: "ProductFeatures");

            migrationBuilder.DropTable(
                name: "ProductVariants");

            migrationBuilder.DropTable(
                name: "Features");

            migrationBuilder.DropTable(
                name: "Colours");

            migrationBuilder.DropTable(
                name: "Storage");

            migrationBuilder.DropIndex(
                name: "IX_Products_BrandId",
                table: "Products");

            migrationBuilder.DropIndex(
                name: "IX_Products_OSId",
                table: "Products");

            migrationBuilder.DropColumn(
                name: "BrandId",
                table: "Products");

            migrationBuilder.DropColumn(
                name: "OSId",
                table: "Products");

            migrationBuilder.DropColumn(
                name: "ScreenSize",
                table: "Products");

            migrationBuilder.DropColumn(
                name: "StandbyTime",
                table: "Products");

            migrationBuilder.DropColumn(
                name: "TalkTime",
                table: "Products");
        }
Exemple #39
0
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable(
         name: "Customers");
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "BrandId",
                table: "Products",
                nullable: false,
                defaultValue: 0);

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

            migrationBuilder.AddColumn<decimal>(
                name: "ScreenSize",
                table: "Products",
                nullable: false,
                defaultValue: 0m);

            migrationBuilder.AddColumn<decimal>(
                name: "StandbyTime",
                table: "Products",
                nullable: false,
                defaultValue: 0m);

            migrationBuilder.AddColumn<decimal>(
                name: "TalkTime",
                table: "Products",
                nullable: false,
                defaultValue: 0m);

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

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

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

            migrationBuilder.CreateTable(
                name: "Images",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ProductId = table.Column<int>(nullable: false),
                    Url = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Images", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Images_Products_ProductId",
                        column: x => x.ProductId,
                        principalTable: "Products",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

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

            migrationBuilder.CreateTable(
                name: "Storage",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Capacity = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Storage", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ProductFeatures",
                columns: table => new
                {
                    ProductId = table.Column<int>(nullable: false),
                    FeatureId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductFeatures", x => new { x.ProductId, x.FeatureId });
                    table.ForeignKey(
                        name: "FK_ProductFeatures_Features_FeatureId",
                        column: x => x.FeatureId,
                        principalTable: "Features",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProductFeatures_Products_ProductId",
                        column: x => x.ProductId,
                        principalTable: "Products",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ProductVariants",
                columns: table => new
                {
                    ProductId = table.Column<int>(nullable: false),
                    ColourId = table.Column<int>(nullable: false),
                    StorageId = table.Column<int>(nullable: false),
                    Price = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductVariants", x => new { x.ProductId, x.ColourId, x.StorageId });
                    table.ForeignKey(
                        name: "FK_ProductVariants_Colours_ColourId",
                        column: x => x.ColourId,
                        principalTable: "Colours",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProductVariants_Products_ProductId",
                        column: x => x.ProductId,
                        principalTable: "Products",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProductVariants_Storage_StorageId",
                        column: x => x.StorageId,
                        principalTable: "Storage",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

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

            migrationBuilder.CreateIndex(
                name: "IX_Products_OSId",
                table: "Products",
                column: "OSId");

            migrationBuilder.CreateIndex(
                name: "IX_Images_ProductId",
                table: "Images",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductFeatures_FeatureId",
                table: "ProductFeatures",
                column: "FeatureId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductVariants_ColourId",
                table: "ProductVariants",
                column: "ColourId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductVariants_StorageId",
                table: "ProductVariants",
                column: "StorageId");

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

            migrationBuilder.AddForeignKey(
                name: "FK_Products_OS_OSId",
                table: "Products",
                column: "OSId",
                principalTable: "OS",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_order_oItem",
                table: "order_item");

            migrationBuilder.DropTable(
                name: "AspNetRoleClaims");

            migrationBuilder.DropTable(
                name: "AspNetUserClaims");

            migrationBuilder.DropTable(
                name: "AspNetUserLogins");

            migrationBuilder.DropTable(
                name: "AspNetUserRoles");

            migrationBuilder.DropTable(
                name: "AspNetUserTokens");

            migrationBuilder.DropIndex(
                name: "EmailIndex",
                table: "staff");

            migrationBuilder.DropIndex(
                name: "UserNameIndex",
                table: "staff");

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

            migrationBuilder.DropColumn(
                name: "AccessFailedCount",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "ConcurrencyStamp",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "EmailConfirmed",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "LockoutEnabled",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "LockoutEnd",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "NormalizedEmail",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "NormalizedUserName",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "PasswordHash",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "PhoneNumber",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "PhoneNumberConfirmed",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "SecurityStamp",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "TwoFactorEnabled",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "UserName",
                table: "staff");

            migrationBuilder.DropColumn(
                name: "ConcurrencyStamp",
                table: "role");

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

            migrationBuilder.DropColumn(
                name: "NormalizedName",
                table: "role");

            migrationBuilder.AddForeignKey(
                name: "FK_order_oItem",
                table: "order_item",
                column: "order_id",
                principalTable: "order",
                principalColumn: "id",
                onDelete: ReferentialAction.Restrict);
        }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable(
         name: "Activities");
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Course",
                columns: table => new
                {
                    CourseID = table.Column<int>(type: "int", nullable: false),
                    Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Credits = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Course", x => x.CourseID);
                });

            migrationBuilder.CreateTable(
                name: "Student",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    LastName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    FirstMidName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EnrollmentDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Student", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "sysUser",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    UserID = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sysUser", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Enrollment",
                columns: table => new
                {
                    EnrollmentID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CourseID = table.Column<int>(type: "int", nullable: false),
                    StudentID = table.Column<int>(type: "int", nullable: false),
                    Grade = table.Column<int>(type: "int", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Enrollment", x => x.EnrollmentID);
                    table.ForeignKey(
                        name: "FK_Enrollment_Course_CourseID",
                        column: x => x.CourseID,
                        principalTable: "Course",
                        principalColumn: "CourseID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Enrollment_Student_StudentID",
                        column: x => x.StudentID,
                        principalTable: "Student",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Enrollment_CourseID",
                table: "Enrollment",
                column: "CourseID");

            migrationBuilder.CreateIndex(
                name: "IX_Enrollment_StudentID",
                table: "Enrollment",
                column: "StudentID");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_order_oItem",
                table: "order_item");

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

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

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

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

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

            migrationBuilder.AddColumn<string>(
                name: "NormalizedEmail",
                table: "staff",
                maxLength: 256,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "NormalizedUserName",
                table: "staff",
                maxLength: 256,
                nullable: true);

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

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

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

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

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

            migrationBuilder.AddColumn<string>(
                name: "UserName",
                table: "staff",
                maxLength: 256,
                nullable: true);

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

            migrationBuilder.AddColumn<string>(
                name: "Name",
                table: "role",
                maxLength: 256,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "NormalizedName",
                table: "role",
                maxLength: 256,
                nullable: true);

            migrationBuilder.CreateTable(
                name: "AspNetRoleClaims",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    RoleId = table.Column<int>(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_role_RoleId",
                        column: x => x.RoleId,
                        principalTable: "role",
                        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<int>(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_staff_UserId",
                        column: x => x.UserId,
                        principalTable: "staff",
                        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<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
                    table.ForeignKey(
                        name: "FK_AspNetUserLogins_staff_UserId",
                        column: x => x.UserId,
                        principalTable: "staff",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "AspNetUserRoles",
                columns: table => new
                {
                    UserId = table.Column<int>(nullable: false),
                    RoleId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
                    table.ForeignKey(
                        name: "FK_AspNetUserRoles_role_RoleId",
                        column: x => x.RoleId,
                        principalTable: "role",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_AspNetUserRoles_staff_UserId",
                        column: x => x.UserId,
                        principalTable: "staff",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "AspNetUserTokens",
                columns: table => new
                {
                    UserId = table.Column<int>(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_staff_UserId",
                        column: x => x.UserId,
                        principalTable: "staff",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                });

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

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

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

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

            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.AddForeignKey(
                name: "FK_order_oItem",
                table: "order_item",
                column: "order_id",
                principalTable: "order",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);
        }
Exemple #45
0
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable(
         name: "RoomReview");
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.EnsureSchema(
                name: "dbo");

            migrationBuilder.CreateTable(
                name: "User",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Name       = table.Column <string>(nullable: true),
                LastName   = table.Column <string>(nullable: true),
                Role       = table.Column <string>(nullable: true),
                Password   = table.Column <string>(nullable: true),
                Email      = table.Column <string>(nullable: true),
                CreateTime = table.Column <DateTime>(nullable: false, defaultValue: new DateTime(2021, 11, 30, 20, 57, 20, 92, DateTimeKind.Local).AddTicks(1970)),
                Status     = table.Column <bool>(nullable: false, defaultValue: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_User", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Post",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Title        = table.Column <string>(nullable: true),
                Content      = table.Column <string>(nullable: true),
                Image        = table.Column <string>(nullable: true),
                CreateTime   = table.Column <DateTime>(nullable: false, defaultValue: new DateTime(2021, 11, 30, 20, 57, 20, 63, DateTimeKind.Local).AddTicks(1930)),
                UpdateTime   = table.Column <DateTime>(nullable: false),
                Status       = table.Column <bool>(nullable: false, defaultValue: true),
                AuthorId     = table.Column <int>(nullable: false),
                CategoryName = table.Column <string>(nullable: true),
                UserId       = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Post", x => x.Id);
                table.ForeignKey(
                    name: "FK_Post_User_UserId",
                    column: x => x.UserId,
                    principalSchema: "dbo",
                    principalTable: "User",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.InsertData(
                schema: "dbo",
                table: "User",
                columns: new[] { "Id", "Email", "LastName", "Name", "Password", "Role" },
                values: new object[] { 1, "123", "Admin", "Admin", "123", "Admin" });

            migrationBuilder.CreateIndex(
                name: "IX_Post_UserId",
                schema: "dbo",
                table: "Post",
                column: "UserId");
        }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable(
         name: "categories");
 }
Exemple #48
0
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropColumn(
         name: "Rating",
         table: "Movie");
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Pso2CsvFiles",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Timestamp = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Pso2CsvFiles", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Pso2CsvKeyKey1",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Value = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Pso2CsvKeyKey1", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Pso2CsvKeyKey2",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Value = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Pso2CsvKeyKey2", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Pso2CsvKeyKey3",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Value = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Pso2CsvKeyKey3", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Pso2CsvKeys",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Key1Id = table.Column<long>(nullable: false),
                    Key2Id = table.Column<long>(nullable: false),
                    Key3Id = table.Column<long>(nullable: false),
                    Key4 = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Pso2CsvKeys", x => x.Id);
                    table.UniqueConstraint("AK_Pso2CsvKeys_Key1Id_Key2Id_Key3Id_Key4", x => new { x.Key1Id, x.Key2Id, x.Key3Id, x.Key4 });
                    table.ForeignKey(
                        name: "FK_Pso2CsvKeys_Pso2CsvKeyKey1_Key1Id",
                        column: x => x.Key1Id,
                        principalTable: "Pso2CsvKeyKey1",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Pso2CsvKeys_Pso2CsvKeyKey2_Key2Id",
                        column: x => x.Key2Id,
                        principalTable: "Pso2CsvKeyKey2",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Pso2CsvKeys_Pso2CsvKeyKey3_Key3Id",
                        column: x => x.Key3Id,
                        principalTable: "Pso2CsvKeyKey3",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Pso2CsvFileItems",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false),
                    FileId = table.Column<int>(nullable: false),
                    KeyId = table.Column<long>(nullable: false),
                    State = table.Column<int>(nullable: false),
                    ValueId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Pso2CsvFileItems", x => new { x.Id, x.FileId });
                    table.ForeignKey(
                        name: "FK_Pso2CsvFileItems_Pso2CsvFiles_FileId",
                        column: x => x.FileId,
                        principalTable: "Pso2CsvFiles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Pso2CsvFileItems_Pso2CsvKeys_KeyId",
                        column: x => x.KeyId,
                        principalTable: "Pso2CsvKeys",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Pso2CsvValues",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false),
                    FileItemId = table.Column<int>(nullable: false),
                    FileId = table.Column<int>(nullable: false),
                    Timestamp = table.Column<DateTime>(nullable: false),
                    Value = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Pso2CsvValues", x => new { x.Id, x.FileItemId, x.FileId });
                    table.ForeignKey(
                        name: "FK_Pso2CsvValues_Pso2CsvFiles_FileId",
                        column: x => x.FileId,
                        principalTable: "Pso2CsvFiles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Pso2CsvValues_Pso2CsvFileItems_FileItemId_FileId",
                        columns: x => new { x.FileItemId, x.FileId },
                        principalTable: "Pso2CsvFileItems",
                        principalColumns: new[] { "Id", "FileId" },
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Pso2CsvFileItems_FileId",
                table: "Pso2CsvFileItems",
                column: "FileId");

            migrationBuilder.CreateIndex(
                name: "IX_Pso2CsvFileItems_KeyId",
                table: "Pso2CsvFileItems",
                column: "KeyId");

            migrationBuilder.CreateIndex(
                name: "IX_Pso2CsvKeys_Key2Id",
                table: "Pso2CsvKeys",
                column: "Key2Id");

            migrationBuilder.CreateIndex(
                name: "IX_Pso2CsvKeys_Key3Id",
                table: "Pso2CsvKeys",
                column: "Key3Id");

            migrationBuilder.CreateIndex(
                name: "IX_Pso2CsvValues_FileId",
                table: "Pso2CsvValues",
                column: "FileId");

            migrationBuilder.CreateIndex(
                name: "IX_Pso2CsvValues_FileItemId_FileId",
                table: "Pso2CsvValues",
                columns: new[] { "FileItemId", "FileId" });
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Faculties",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    name = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Faculties", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "IdentityRole",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    NormalizedName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IdentityRole", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Groups",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    name = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true),
                    facultyId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Groups", x => x.id);
                    table.ForeignKey(
                        name: "FK_Groups_Faculties_facultyId",
                        column: x => x.facultyId,
                        principalTable: "Faculties",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Students",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    firstName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    lastName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    groupId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Students", x => x.id);
                    table.ForeignKey(
                        name: "FK_Students_Groups_groupId",
                        column: x => x.groupId,
                        principalTable: "Groups",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.InsertData(
                table: "Faculties",
                columns: new[] { "id", "name" },
                values: new object[,]
                {
                    { new Guid("021c0363-5820-4a20-809a-74224a8e392c"), "Программирования" },
                    { new Guid("7c0c1dcd-3167-440b-8e90-8420dc6374e7"), "Администрирования" },
                    { new Guid("4147356e-a563-48af-a208-362b00cba5a9"), "Дизайна и графики" },
                    { new Guid("18bc5cc7-e97c-43a7-a70a-25f6f7ea93a2"), "Базовый" }
                });

            migrationBuilder.InsertData(
                table: "IdentityRole",
                columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
                values: new object[,]
                {
                    { "c8384e3e-161b-4e07-bfe7-9b477b7c8e1e", "c873cb04-810b-4740-81c9-fea834661131", "Administrators", "ADMINISTRATORS" },
                    { "840f1e08-eb20-4f17-8e75-6195b0d70970", "98be7ff8-731f-4a5a-8514-c12fb0e8c14c", "Moderators", "MODERATORS" }
                });

            migrationBuilder.CreateIndex(
                name: "IX_Groups_facultyId",
                table: "Groups",
                column: "facultyId");

            migrationBuilder.CreateIndex(
                name: "IX_Students_groupId",
                table: "Students",
                column: "groupId");
        }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable(
         name: "ResfreshTokens");
 }
Exemple #52
0
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable(
         name: "TicketCancelOperations");
 }
Exemple #53
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Post_Users_UserId",
                table: "Post");

            migrationBuilder.DropForeignKey(
                name: "FK_PostFeature_Feature_FeatureId",
                table: "PostFeature");

            migrationBuilder.DropForeignKey(
                name: "FK_PostFeature_Post_PostId",
                table: "PostFeature");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PostFeature",
                table: "PostFeature");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Post",
                table: "Post");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Feature",
                table: "Feature");

            migrationBuilder.RenameTable(
                name: "PostFeature",
                newName: "PostFeatures");

            migrationBuilder.RenameTable(
                name: "Post",
                newName: "Posts");

            migrationBuilder.RenameTable(
                name: "Feature",
                newName: "Features");

            migrationBuilder.RenameIndex(
                name: "IX_PostFeature_FeatureId",
                table: "PostFeatures",
                newName: "IX_PostFeatures_FeatureId");

            migrationBuilder.RenameIndex(
                name: "IX_Post_UserId",
                table: "Posts",
                newName: "IX_Posts_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_Feature_Name",
                table: "Features",
                newName: "IX_Features_Name");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PostFeatures",
                table: "PostFeatures",
                columns: new[] { "PostId", "FeatureId" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_Posts",
                table: "Posts",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Features",
                table: "Features",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "Fuels",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreatedAt  = table.Column <DateTime>(nullable: false, defaultValueSql: "GETDATE()"),
                ModifiedAt = table.Column <DateTime>(nullable: true),
                IsDeleted  = table.Column <bool>(nullable: false),
                Name       = table.Column <string>(maxLength: 20, nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Fuels", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Manufacturers",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreatedAt  = table.Column <DateTime>(nullable: false, defaultValueSql: "GETDATE()"),
                ModifiedAt = table.Column <DateTime>(nullable: true),
                IsDeleted  = table.Column <bool>(nullable: false),
                Name       = table.Column <string>(maxLength: 30, nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Manufacturers", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Models",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreatedAt      = table.Column <DateTime>(nullable: false, defaultValueSql: "GETDATE()"),
                ModifiedAt     = table.Column <DateTime>(nullable: true),
                IsDeleted      = table.Column <bool>(nullable: false),
                Name           = table.Column <string>(maxLength: 30, nullable: false),
                ManufacturerId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Models", x => x.Id);
                table.ForeignKey(
                    name: "FK_Models_Manufacturers_ManufacturerId",
                    column: x => x.ManufacturerId,
                    principalTable: "Manufacturers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Posts_FuelId",
                table: "Posts",
                column: "FuelId");

            migrationBuilder.CreateIndex(
                name: "IX_Fuels_Name",
                table: "Fuels",
                column: "Name",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Manufacturers_Name",
                table: "Manufacturers",
                column: "Name",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Models_ManufacturerId",
                table: "Models",
                column: "ManufacturerId");

            migrationBuilder.CreateIndex(
                name: "IX_Models_Name",
                table: "Models",
                column: "Name",
                unique: true);

            migrationBuilder.AddForeignKey(
                name: "FK_PostFeatures_Features_FeatureId",
                table: "PostFeatures",
                column: "FeatureId",
                principalTable: "Features",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PostFeatures_Posts_PostId",
                table: "PostFeatures",
                column: "PostId",
                principalTable: "Posts",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Posts_Fuels_FuelId",
                table: "Posts",
                column: "FuelId",
                principalTable: "Fuels",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Posts_Users_UserId",
                table: "Posts",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TextTypes",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(maxLength: 100, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TextTypes", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Types",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false),
                    Size = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 100, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Types", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "LabelSeries",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TypeId = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 100, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LabelSeries", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LabelSeries_Types_TypeId",
                        column: x => x.TypeId,
                        principalTable: "Types",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "RatioSeries",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TypeId = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 100, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RatioSeries", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RatioSeries_Types_TypeId",
                        column: x => x.TypeId,
                        principalTable: "Types",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "SequenceSeries",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TypeId = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 100, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SequenceSeries", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SequenceSeries_Types_TypeId",
                        column: x => x.TypeId,
                        principalTable: "Types",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TextSeries",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TypeId = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 100, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TextSeries", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TextSeries_Types_TypeId",
                        column: x => x.TypeId,
                        principalTable: "Types",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Values",
                columns: table => new
                {
                    TypeId = table.Column<int>(nullable: false),
                    ValueId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Values", x => new { x.TypeId, x.ValueId });
                    table.ForeignKey(
                        name: "FK_Values_Types_TypeId",
                        column: x => x.TypeId,
                        principalTable: "Types",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Labels",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TypeId = table.Column<int>(nullable: false),
                    ValueId = table.Column<int>(nullable: false),
                    LabelSeryId = table.Column<int>(nullable: false),
                    LabelData = table.Column<string>(maxLength: 100, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Labels", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Labels_LabelSeries_LabelSeryId",
                        column: x => x.LabelSeryId,
                        principalTable: "LabelSeries",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Labels_Types_TypeId",
                        column: x => x.TypeId,
                        principalTable: "Types",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Labels_Values_TypeId_ValueId",
                        columns: x => new { x.TypeId, x.ValueId },
                        principalTable: "Values",
                        principalColumns: new[] { "TypeId", "ValueId" },
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Ratios",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TypeId = table.Column<int>(nullable: false),
                    ValueId = table.Column<int>(nullable: false),
                    RatioSeryId = table.Column<int>(nullable: false),
                    RatioData = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Ratios", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Ratios_RatioSeries_RatioSeryId",
                        column: x => x.RatioSeryId,
                        principalTable: "RatioSeries",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Ratios_Types_TypeId",
                        column: x => x.TypeId,
                        principalTable: "Types",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Ratios_Values_TypeId_ValueId",
                        columns: x => new { x.TypeId, x.ValueId },
                        principalTable: "Values",
                        principalColumns: new[] { "TypeId", "ValueId" },
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Sequences",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TypeId = table.Column<int>(nullable: false),
                    ValueId = table.Column<int>(nullable: false),
                    SequenceSeryId = table.Column<int>(nullable: false),
                    SequenceData = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sequences", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Sequences_SequenceSeries_SequenceSeryId",
                        column: x => x.SequenceSeryId,
                        principalTable: "SequenceSeries",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Sequences_Types_TypeId",
                        column: x => x.TypeId,
                        principalTable: "Types",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Sequences_Values_TypeId_ValueId",
                        columns: x => new { x.TypeId, x.ValueId },
                        principalTable: "Values",
                        principalColumns: new[] { "TypeId", "ValueId" },
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Texts",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TypeId = table.Column<int>(nullable: false),
                    ValueId = table.Column<int>(nullable: false),
                    TextSeryId = table.Column<int>(nullable: false),
                    TextTypeId = table.Column<int>(nullable: false),
                    TextData = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Texts", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Texts_TextSeries_TextSeryId",
                        column: x => x.TextSeryId,
                        principalTable: "TextSeries",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Texts_TextTypes_TextTypeId",
                        column: x => x.TextTypeId,
                        principalTable: "TextTypes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Texts_Types_TypeId",
                        column: x => x.TypeId,
                        principalTable: "Types",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Texts_Values_TypeId_ValueId",
                        columns: x => new { x.TypeId, x.ValueId },
                        principalTable: "Values",
                        principalColumns: new[] { "TypeId", "ValueId" },
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Labels_LabelSeryId",
                table: "Labels",
                column: "LabelSeryId");

            migrationBuilder.CreateIndex(
                name: "IX_Labels_TypeId_ValueId",
                table: "Labels",
                columns: new[] { "TypeId", "ValueId" });

            migrationBuilder.CreateIndex(
                name: "IX_LabelSeries_TypeId",
                table: "LabelSeries",
                column: "TypeId");

            migrationBuilder.CreateIndex(
                name: "IX_Ratios_RatioSeryId",
                table: "Ratios",
                column: "RatioSeryId");

            migrationBuilder.CreateIndex(
                name: "IX_Ratios_TypeId_ValueId",
                table: "Ratios",
                columns: new[] { "TypeId", "ValueId" });

            migrationBuilder.CreateIndex(
                name: "IX_RatioSeries_TypeId",
                table: "RatioSeries",
                column: "TypeId");

            migrationBuilder.CreateIndex(
                name: "IX_Sequences_SequenceSeryId",
                table: "Sequences",
                column: "SequenceSeryId");

            migrationBuilder.CreateIndex(
                name: "IX_Sequences_TypeId_ValueId",
                table: "Sequences",
                columns: new[] { "TypeId", "ValueId" });

            migrationBuilder.CreateIndex(
                name: "IX_SequenceSeries_TypeId",
                table: "SequenceSeries",
                column: "TypeId");

            migrationBuilder.CreateIndex(
                name: "IX_Texts_TextSeryId",
                table: "Texts",
                column: "TextSeryId");

            migrationBuilder.CreateIndex(
                name: "IX_Texts_TextTypeId",
                table: "Texts",
                column: "TextTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_Texts_TypeId_ValueId",
                table: "Texts",
                columns: new[] { "TypeId", "ValueId" });

            migrationBuilder.CreateIndex(
                name: "IX_TextSeries_TypeId",
                table: "TextSeries",
                column: "TypeId");
        }
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropColumn(
         name: "DateCreated",
         table: "StaffPerformance");
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AspNetRoles",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
                    NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetRoles", x => x.Id);
                });

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

            migrationBuilder.CreateTable(
                name: "Forums",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ImageUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Title = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Forums", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AspNetRoleClaims",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false)
                },
                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>(type: "int", nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    UserId = table.Column<string>(type: "nvarchar(450)", nullable: false)
                },
                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>(type: "nvarchar(450)", nullable: false),
                    ProviderKey = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    ProviderDisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    UserId = table.Column<string>(type: "nvarchar(450)", 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>(type: "nvarchar(450)", nullable: false),
                    RoleId = table.Column<string>(type: "nvarchar(450)", 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>(type: "nvarchar(450)", nullable: false),
                    LoginProvider = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    Value = table.Column<string>(type: "nvarchar(max)", 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.CreateTable(
                name: "Posts",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Content = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ForumId = table.Column<int>(type: "int", nullable: true),
                    Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    UserId = table.Column<string>(type: "nvarchar(450)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Posts", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Posts_Forums_ForumId",
                        column: x => x.ForumId,
                        principalTable: "Forums",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Posts_AspNetUsers_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Replies",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Content = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    PostId = table.Column<int>(type: "int", nullable: true),
                    UserId = table.Column<string>(type: "nvarchar(450)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Replies", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Replies_Posts_PostId",
                        column: x => x.PostId,
                        principalTable: "Posts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Replies_AspNetUsers_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            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.CreateIndex(
                name: "IX_Posts_ForumId",
                table: "Posts",
                column: "ForumId");

            migrationBuilder.CreateIndex(
                name: "IX_Posts_UserId",
                table: "Posts",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_Replies_PostId",
                table: "Replies",
                column: "PostId");

            migrationBuilder.CreateIndex(
                name: "IX_Replies_UserId",
                table: "Replies",
                column: "UserId");
        }
Exemple #57
0
 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropColumn(
         name: "isUsed",
         table: "CarModel");
 }
Exemple #58
0
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_PostFeatures_Features_FeatureId",
                table: "PostFeatures");

            migrationBuilder.DropForeignKey(
                name: "FK_PostFeatures_Posts_PostId",
                table: "PostFeatures");

            migrationBuilder.DropForeignKey(
                name: "FK_Posts_Fuels_FuelId",
                table: "Posts");

            migrationBuilder.DropForeignKey(
                name: "FK_Posts_Users_UserId",
                table: "Posts");

            migrationBuilder.DropTable(
                name: "Fuels");

            migrationBuilder.DropTable(
                name: "Models");

            migrationBuilder.DropTable(
                name: "Manufacturers");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Posts",
                table: "Posts");

            migrationBuilder.DropIndex(
                name: "IX_Posts_FuelId",
                table: "Posts");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PostFeatures",
                table: "PostFeatures");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Features",
                table: "Features");

            migrationBuilder.RenameTable(
                name: "Posts",
                newName: "Post");

            migrationBuilder.RenameTable(
                name: "PostFeatures",
                newName: "PostFeature");

            migrationBuilder.RenameTable(
                name: "Features",
                newName: "Feature");

            migrationBuilder.RenameIndex(
                name: "IX_Posts_UserId",
                table: "Post",
                newName: "IX_Post_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PostFeatures_FeatureId",
                table: "PostFeature",
                newName: "IX_PostFeature_FeatureId");

            migrationBuilder.RenameIndex(
                name: "IX_Features_Name",
                table: "Feature",
                newName: "IX_Feature_Name");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Post",
                table: "Post",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PostFeature",
                table: "PostFeature",
                columns: new[] { "PostId", "FeatureId" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_Feature",
                table: "Feature",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Post_Users_UserId",
                table: "Post",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PostFeature_Feature_FeatureId",
                table: "PostFeature",
                column: "FeatureId",
                principalTable: "Feature",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PostFeature_Post_PostId",
                table: "PostFeature",
                column: "PostId",
                principalTable: "Post",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Book",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Title = table.Column<string>(nullable: true),
                    Author = table.Column<string>(nullable: true),
                    Price = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Book", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Customer",
                columns: table => new
                {
                    CustomerID = table.Column<int>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Adress = table.Column<string>(nullable: true),
                    BirthDate = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Customer", x => x.CustomerID);
                });

            migrationBuilder.CreateTable(
                name: "Publisher",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    PublisherName = table.Column<string>(maxLength: 50, nullable: false),
                    Adress = table.Column<string>(maxLength: 70, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Publisher", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Order",
                columns: table => new
                {
                    OrderID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CustomerID = table.Column<int>(nullable: false),
                    BookID = table.Column<int>(nullable: false),
                    OrderDate = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Order", x => x.OrderID);
                    table.ForeignKey(
                        name: "FK_Order_Book_BookID",
                        column: x => x.BookID,
                        principalTable: "Book",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Order_Customer_CustomerID",
                        column: x => x.CustomerID,
                        principalTable: "Customer",
                        principalColumn: "CustomerID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "PublishedBook",
                columns: table => new
                {
                    PublisherID = table.Column<int>(nullable: false),
                    BookID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PublishedBook", x => new { x.BookID, x.PublisherID });
                    table.ForeignKey(
                        name: "FK_PublishedBook_Book_BookID",
                        column: x => x.BookID,
                        principalTable: "Book",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PublishedBook_Publisher_PublisherID",
                        column: x => x.PublisherID,
                        principalTable: "Publisher",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Order_BookID",
                table: "Order",
                column: "BookID");

            migrationBuilder.CreateIndex(
                name: "IX_Order_CustomerID",
                table: "Order",
                column: "CustomerID");

            migrationBuilder.CreateIndex(
                name: "IX_PublishedBook_PublisherID",
                table: "PublishedBook",
                column: "PublisherID");
        }
Exemple #60
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Authors",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    FirstName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    DateOfBirth = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
                    MainCategory = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Authors", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Courses",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Title = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Description = table.Column<string>(type: "nvarchar(1500)", maxLength: 1500, nullable: true),
                    AuthorId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Courses", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Courses_Authors_AuthorId",
                        column: x => x.AuthorId,
                        principalTable: "Authors",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.InsertData(
                table: "Authors",
                columns: new[] { "Id", "DateOfBirth", "FirstName", "LastName", "MainCategory" },
                values: new object[,]
                {
                    { new Guid("d28888e9-2ba9-473a-a40f-e38cb54f9b35"), new DateTimeOffset(new DateTime(1650, 7, 23, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Berry", "Griffin Beak Eldritch", "Ships" },
                    { new Guid("da2fd609-d754-4feb-8acd-c4f9ff13ba96"), new DateTimeOffset(new DateTime(1668, 5, 21, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Nancy", "Swashbuckler Rye", "Rum" },
                    { new Guid("2902b665-1190-4c70-9915-b9c2d7680450"), new DateTimeOffset(new DateTime(1701, 12, 16, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Eli", "Ivory Bones Sweet", "Singing" },
                    { new Guid("102b566b-ba1f-404c-b2df-e2cde39ade09"), new DateTimeOffset(new DateTime(1702, 3, 6, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Arnold", "The Unseen Stafford", "Singing" },
                    { new Guid("5b3621c0-7b12-4e80-9c8b-3398cba7ee05"), new DateTimeOffset(new DateTime(1690, 11, 23, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Seabury", "Toxic Reyson", "Maps" },
                    { new Guid("2aadd2df-7caf-45ab-9355-7f6332985a87"), new DateTimeOffset(new DateTime(1723, 4, 5, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Rutherford", "Fearless Cloven", "General debauchery" },
                    { new Guid("2ee49fe3-edf2-4f91-8409-3eb25ce6ca51"), new DateTimeOffset(new DateTime(1721, 10, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Atherton", "Crow Ridley", "Rum" }
                });

            migrationBuilder.InsertData(
                table: "Courses",
                columns: new[] { "Id", "AuthorId", "Description", "Title" },
                values: new object[,]
                {
                    { new Guid("5b1c2b4d-48c7-402a-80c3-cc796ad49c6b"), new Guid("d28888e9-2ba9-473a-a40f-e38cb54f9b35"), "Commandeering a ship in rough waters isn't easy.  Commandeering it without getting caught is even harder.  In this course you'll learn how to sail away and avoid those pesky musketeers.", "Commandeering a Ship Without Getting Caught" },
                    { new Guid("d8663e5e-7494-4f81-8739-6e0de1bea7ee"), new Guid("d28888e9-2ba9-473a-a40f-e38cb54f9b35"), "In this course, the author provides tips to avoid, or, if needed, overthrow pirate mutiny.", "Overthrowing Mutiny" },
                    { new Guid("d173e20d-159e-4127-9ce9-b0ac2564ad97"), new Guid("da2fd609-d754-4feb-8acd-c4f9ff13ba96"), "Every good pirate loves rum, but it also has a tendency to get you into trouble.  In this course you'll learn how to avoid that.  This new exclusive edition includes an additional chapter on how to run fast without falling while drunk.", "Avoiding Brawls While Drinking as Much Rum as You Desire" },
                    { new Guid("40ff5488-fdab-45b5-bc3a-14302d59869a"), new Guid("2902b665-1190-4c70-9915-b9c2d7680450"), "In this course you'll learn how to sing all-time favourite pirate songs without sounding like you actually know the words or how to hold a note.", "Singalong Pirate Hits" }
                });

            migrationBuilder.CreateIndex(
                name: "IX_Courses_AuthorId",
                table: "Courses",
                column: "AuthorId");
        }