protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "DisplayName",
                table: "TestClasses",
                nullable: true);

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

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

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

            migrationBuilder.AddForeignKey(
                name: "FK_Commits_Users_UserId",
                table: "Commits",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AspNetRoles_RoleGroups_RoleGroupId",
                table: "AspNetRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_RoleGroups_AspNetRoles_RoleId",
                table: "RoleGroups");

            migrationBuilder.DropIndex(
                name: "IX_RoleGroups_RoleId",
                table: "RoleGroups");

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

            migrationBuilder.DropColumn(
                name: "RoleId",
                table: "RoleGroups");

            migrationBuilder.DropColumn(
                name: "RoleGroupId",
                table: "AspNetRoles");

            migrationBuilder.CreateTable(
                name: "RoleRoleGroups",
                columns: table => new
                {
                    RoleId = table.Column<int>(nullable: false),
                    RoleGroupId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleRoleGroups", x => new { x.RoleId, x.RoleGroupId });
                    table.ForeignKey(
                        name: "FK_RoleRoleGroups_RoleGroups_RoleGroupId",
                        column: x => x.RoleGroupId,
                        principalTable: "RoleGroups",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_RoleRoleGroups_AspNetRoles_RoleId",
                        column: x => x.RoleId,
                        principalTable: "AspNetRoles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_RoleRoleGroups_RoleGroupId",
                table: "RoleRoleGroups",
                column: "RoleGroupId");

            migrationBuilder.CreateIndex(
                name: "IX_RoleRoleGroups_RoleId",
                table: "RoleRoleGroups",
                column: "RoleId");
        }
        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");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateIndex(
                name: "IX_UserQuestionData_QuestionId",
                table: "UserQuestionData",
                column: "QuestionId");

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

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

            migrationBuilder.AddForeignKey(
                name: "FK_UserQuestionData_Users_UserId",
                table: "UserQuestionData",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
示例#5
0
        /// <summary>
        /// Creates initial tables for navigation management.
        /// </summary>
        /// <param name="builder">Instance of <see cref="MigrationBuilder"/></param>
        protected override void Up(MigrationBuilder builder)
        {
            builder.CreateTable(
                name: "Menus",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false, type: "uniqueidentifier"),
                    Name = table.Column<string>(nullable: false, type: "nvarchar(256)"),
                    NormalizedName = table.Column<string>(nullable: false, type: "nvarchar(256)"),
                    Title = table.Column<string>(nullable: true, type: "nvarchar(256)")
                },
                constraints: table => 
                {
                    table.PrimaryKey("PK_Menu", x => x.Id);   
                });

            builder.CreateTable(
                name: "MenuItems",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false, type: "uniqueidentifier"),
                    MenuId = table.Column<Guid>(nullable: false, type: "uniqueidentifier"),
                    ParentId = table.Column<Guid>(nullable: true, type: "uniqueidentifier"),
                    Title = table.Column<string>(nullable: true, type: "nvarchar(256)"),
                    CssClass = table.Column<string>(nullable: true, type: "nvarchar(256)"),
                    Url = table.Column<string>(nullable: true, type: "nvarchar(1024)")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MenuItem", x => x.Id);

                    table.ForeignKey(
                        name: "FK_MenuItem_Menu_MenuId",
                        column: x => x.MenuId,
                        principalTable: "Menus",
                        principalColumn: "Id",
                        //cascade delete all menu items if menu deleted
                        onDelete: ReferentialAction.Cascade);

                    table.ForeignKey(
                        name: "FK_MenuItem_MenuItem_ParentId",
                        column: x => x.ParentId,
                        principalTable: "MenuItems",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.NoAction);
                });

            builder.CreateIndex(
                name: "MenuNameIndex",
                table: "Menus",
                column: "NormalizedName");

            builder.CreateIndex(
                name: "MenuItemMenuIdIndex",
                table: "MenuItems",
                column: "MenuId");
        }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "Content",
         columns: table => new
         {
             ContentGuid = table.Column<Guid>(nullable: false, defaultValueSql: "newsequentialid()"),
             InternalCaption = table.Column<string>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Content", x => x.ContentGuid);
         });
     migrationBuilder.CreateTable(
         name: "Translation",
         columns: table => new
         {
             Id = table.Column<int>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             ContentContentGuid = table.Column<Guid>(nullable: true),
             ContentId = table.Column<int>(nullable: false),
             ContentMarkup = table.Column<string>(nullable: false),
             Description = table.Column<string>(nullable: false),
             State = table.Column<int>(nullable: false),
             Title = table.Column<string>(nullable: false),
             UpdatedAt = table.Column<DateTime>(nullable: false),
             UrlName = table.Column<string>(nullable: false),
             Version = table.Column<int>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Translation", x => x.Id);
             table.ForeignKey(
                 name: "FK_Translation_Content_ContentContentGuid",
                 column: x => x.ContentContentGuid,
                 principalTable: "Content",
                 principalColumn: "ContentGuid");
         });
     migrationBuilder.CreateIndex(
         name: "IX_Translation_Version_ContentId",
         table: "Translation",
         columns: new[] { "Version", "ContentId" },
         unique: true);
     migrationBuilder.CreateIndex(
         name: "IX_Translation_Version_UrlName",
         table: "Translation",
         columns: new[] { "Version", "UrlName" },
         unique: true);
 }
示例#7
0
        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 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 Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TemperatureEntries",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreatedDateTime = table.Column<DateTime>(nullable: false),
                    DeviceId = table.Column<int>(nullable: false),
                    Humidity = table.Column<double>(nullable: false),
                    Presure = table.Column<double>(nullable: false),
                    TemperatureCelsius = table.Column<double>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TemperatureEntries", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TemperatureEntries_Devices_DeviceId",
                        column: x => x.DeviceId,
                        principalTable: "Devices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_TemperatureEntries_DeviceId",
                table: "TemperatureEntries",
                column: "DeviceId");
        }
        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: "CodeConstraints",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
                    CodeQuestionId = table.Column<int>(nullable: false),
                    ErrorMessage = table.Column<string>(nullable: false),
                    Frequency = table.Column<int>(nullable: false),
                    Order = table.Column<int>(nullable: false),
                    Regex = table.Column<string>(nullable: false),
                    Type = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CodeConstraints", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CodeConstraints_Questions_CodeQuestionId",
                        column: x => x.CodeQuestionId,
                        principalTable: "Questions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CodeConstraints_CodeQuestionId",
                table: "CodeConstraints",
                column: "CodeQuestionId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Tweets_Categories_CategoryId",
                table: "Tweets");

            migrationBuilder.DropIndex(
                name: "IX_Tweets_CategoryId",
                table: "Tweets");

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

            migrationBuilder.CreateIndex(
                name: "IX_Tweets_CategoryId",
                table: "Tweets",
                column: "CategoryId");

            migrationBuilder.AddForeignKey(
                name: "FK_Tweets_Categories_CategoryId",
                table: "Tweets",
                column: "CategoryId",
                principalTable: "Categories",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ProductsWithMaintenance",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false),
                    YearlyRate = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductsWithMaintenance", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProductsWithMaintenance_Products_Id",
                        column: x => x.Id,
                        principalTable: "Products",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_ProductsWithMaintenance_Id",
                table: "ProductsWithMaintenance",
                column: "Id",
                unique: true);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Categories",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Categories", x => x.Id);
                });

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

            migrationBuilder.CreateIndex(
                name: "IX_Tweets_CategoryId",
                table: "Tweets",
                column: "CategoryId");

            migrationBuilder.AddForeignKey(
                name: "FK_Tweets_Categories_CategoryId",
                table: "Tweets",
                column: "CategoryId",
                principalTable: "Categories",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ProductsWithMaintenance_Products_Id",
                table: "ProductsWithMaintenance");

            migrationBuilder.DropIndex(
                name: "IX_ProductsWithMaintenance_Id",
                table: "ProductsWithMaintenance");

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

            migrationBuilder.AlterColumn<int>(
                name: "Id",
                table: "ProductsWithMaintenance",
                nullable: false)
                .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

            migrationBuilder.CreateIndex(
                name: "IX_Products_MaintenanceId",
                table: "Products",
                column: "MaintenanceId",
                unique: true);

            migrationBuilder.AddForeignKey(
                name: "FK_Products_ProductsWithMaintenance_MaintenanceId",
                table: "Products",
                column: "MaintenanceId",
                principalTable: "ProductsWithMaintenance",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "Cliente",
         columns: table => new
         {
             Id = table.Column<int>(nullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             Cedula = table.Column<string>(nullable: false),
             FechaNacimiento = table.Column<DateTime>(nullable: false),
             PrimerApellido = table.Column<string>(nullable: false),
             PrimerNombre = table.Column<string>(nullable: false),
             SegundoApellido = table.Column<string>(nullable: true),
             SegundoNombre = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Cliente", x => x.Id);
         });
     migrationBuilder.CreateTable(
         name: "Prestamo",
         columns: table => new
         {
             Id = table.Column<int>(nullable: false)
                 .Annotation("Sqlite:Autoincrement", true),
             CantCuotas = table.Column<int>(nullable: false),
             CodeudorId = table.Column<int>(nullable: true),
             DeudorId = table.Column<int>(nullable: false),
             FechaDesembolso = table.Column<DateTime>(nullable: false),
             FechaFin = table.Column<DateTime>(nullable: false),
             FechaInicio = table.Column<DateTime>(nullable: false),
             FormaPago = table.Column<int>(nullable: false),
             Moneda = table.Column<int>(nullable: false),
             Monto = table.Column<decimal>(nullable: false),
             PorcMora = table.Column<int>(nullable: false),
             Porciento = table.Column<int>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Prestamo", x => x.Id);
             table.ForeignKey(
                 name: "FK_Prestamo_Cliente_CodeudorId",
                 column: x => x.CodeudorId,
                 principalTable: "Cliente",
                 principalColumn: "Id",
                 onDelete: ReferentialAction.Restrict);
             table.ForeignKey(
                 name: "FK_Prestamo_Cliente_DeudorId",
                 column: x => x.DeudorId,
                 principalTable: "Cliente",
                 principalColumn: "Id",
                 onDelete: ReferentialAction.Cascade);
         });
     migrationBuilder.CreateIndex(
         name: "IX_Cliente_Cedula",
         table: "Cliente",
         column: "Cedula",
         unique: true);
 }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Testators",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    FirstName = table.Column<string>(nullable: false),
                    LastName = table.Column<string>(nullable: false),
                    MiddleName = table.Column<string>(nullable: true),
                    Occupation = table.Column<string>(nullable: false),
                    PostCode = table.Column<int>(nullable: false),
                    State = table.Column<string>(nullable: true),
                    StreetName = table.Column<string>(nullable: true),
                    StreetNumber = table.Column<string>(nullable: true),
                    StreetType = table.Column<string>(nullable: true),
                    Suburb = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Testators", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Executors",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    FirstName = table.Column<string>(nullable: false),
                    LastName = table.Column<string>(nullable: false),
                    MiddleName = table.Column<string>(nullable: true),
                    PostCode = table.Column<int>(nullable: false),
                    Relationship = table.Column<string>(nullable: false),
                    State = table.Column<string>(nullable: true),
                    StreetName = table.Column<string>(nullable: true),
                    StreetNumber = table.Column<string>(nullable: true),
                    StreetType = table.Column<string>(nullable: true),
                    Suburb = table.Column<string>(nullable: true),
                    TestatorID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Executors", x => x.ID);
                    table.ForeignKey(
                        name: "FK_Executors_Testators_TestatorID",
                        column: x => x.TestatorID,
                        principalTable: "Testators",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Executors_TestatorID",
                table: "Executors",
                column: "TestatorID");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "CheckpointTestClasses",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
                    CheckpointId = table.Column<int>(nullable: false),
                    Required = table.Column<bool>(nullable: false),
                    TestClassId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CheckpointTestClasses", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CheckpointTestClasses_Checkpoints_CheckpointId",
                        column: x => x.CheckpointId,
                        principalTable: "Checkpoints",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_CheckpointTestClasses_TestClasses_TestClassId",
                        column: x => x.TestClassId,
                        principalTable: "TestClasses",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CheckpointTestClasses_CheckpointId",
                table: "CheckpointTestClasses",
                column: "CheckpointId");

            migrationBuilder.CreateIndex(
                name: "IX_CheckpointTestClasses_TestClassId",
                table: "CheckpointTestClasses",
                column: "TestClassId");

            migrationBuilder.CreateIndex(
                name: "IX_CheckpointTestClasses_CheckpointId_TestClassId",
                table: "CheckpointTestClasses",
                columns: new[] { "CheckpointId", "TestClassId" },
                unique: true);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Applicant",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Address = table.Column<string>(nullable: true),
                    Birthday = table.Column<DateTime>(type: "Date", nullable: false),
                    Email = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    Phone = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Applicant", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Project",
                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_Project", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Vacancy",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(nullable: true),
                    ProjectId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Vacancy", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Vacancy_Project_ProjectId",
                        column: x => x.ProjectId,
                        principalTable: "Project",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Vacancy_ProjectId",
                table: "Vacancy",
                column: "ProjectId");
        }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "EventSignup",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    AdditionalInfo = table.Column<string>(nullable: true),
                    CheckinDateTime = table.Column<DateTime>(nullable: true),
                    EventId = table.Column<int>(nullable: true),
                    PreferredEmail = table.Column<string>(nullable: true),
                    PreferredPhoneNumber = table.Column<string>(nullable: true),
                    SignupDateTime = table.Column<DateTime>(nullable: false),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EventSignup", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EventSignup_Event_EventId",
                        column: x => x.EventId,
                        principalTable: "Event",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EventSignup_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "ApplicationUser",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_EventSignup_EventId",
                table: "EventSignup",
                column: "EventId");

            migrationBuilder.CreateIndex(
                name: "IX_EventSignup_UserId",
                table: "EventSignup",
                column: "UserId");
        }
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "DbUserAccount",
         columns: table => new
         {
             DbUserAccountId = table.Column<string>(nullable: false),
             CreditHalfLife = table.Column<TimeSpan>(nullable: false),
             CreditLimit = table.Column<double>(nullable: false),
             EcPrivateAccountLogKeyEncryptedWithPasswordHashPhase1 = table.Column<byte[]>(nullable: true),
             EcPublicAccountLogKey = table.Column<byte[]>(nullable: true),
             NumberOfIterationsToUseForPhase1Hash = table.Column<int>(nullable: false),
             PasswordHashPhase1FunctionName = table.Column<string>(nullable: true),
             PasswordHashPhase2 = table.Column<string>(nullable: true),
             SaltUniqueToThisAccount = table.Column<byte[]>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_DbUserAccount", x => x.DbUserAccountId);
         });
     migrationBuilder.CreateTable(
         name: "DbUserAccountCreditBalance",
         columns: table => new
         {
             DbUserAccountId = table.Column<string>(nullable: false),
             ConsumedCreditsLastUpdatedUtc = table.Column<DateTime>(nullable: true),
             ConsumedCreditsLastValue = table.Column<double>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_DbUserAccountCreditBalance", x => x.DbUserAccountId);
         });
     migrationBuilder.CreateIndex(
         name: "IX_DbUserAccount_DbUserAccountId",
         table: "DbUserAccount",
         column: "DbUserAccountId",
         unique: true);
     migrationBuilder.CreateIndex(
         name: "IX_DbUserAccountCreditBalance_DbUserAccountId",
         table: "DbUserAccountCreditBalance",
         column: "DbUserAccountId",
         unique: true);
 }
示例#22
0
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "Messages",
         columns: table => new
         {
             Id = table.Column<int>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             Body = table.Column<string>(nullable: true),
             IsRead = table.Column<bool>(nullable: false),
             IsRecipientDeleted = table.Column<bool>(nullable: false),
             IsSenderDeleted = table.Column<bool>(nullable: false),
             RecipientId = table.Column<string>(nullable: false),
             SenderId = table.Column<string>(nullable: false),
             SentDate = table.Column<DateTime>(nullable: false, defaultValueSql: "getutcdate()"),
             Title = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Message", x => x.Id);
             table.ForeignKey(
                 name: "FK_Message_ApplicationUser_RecipientId",
                 column: x => x.RecipientId,
                 principalTable: "Users",
                 principalColumn: "Id",
                 onDelete: ReferentialAction.Restrict);
             table.ForeignKey(
                 name: "FK_Message_ApplicationUser_SenderId",
                 column: x => x.SenderId,
                 principalTable: "Users",
                 principalColumn: "Id",
                 onDelete: ReferentialAction.Restrict);
         });
     migrationBuilder.CreateIndex(
         name: "IX_Message_IsRecipientDeleted_RecipientId",
         table: "Messages",
         columns: new[] { "IsRecipientDeleted", "RecipientId" });
     migrationBuilder.CreateIndex(
         name: "IX_Message_IsSenderDeleted_SenderId",
         table: "Messages",
         columns: new[] { "IsSenderDeleted", "SenderId" });
 }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles");

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

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserRoles_UserId",
                table: "AspNetUserRoles",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles",
                column: "NormalizedName");
        }
示例#24
0
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "UserNameIndex",
                table: "AspNetUsers");

            migrationBuilder.CreateIndex(
                name: "UserNameIndex",
                table: "AspNetUsers",
                column: "NormalizedUserName");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Podcasts",
                columns: table => new
                {
                    PodcastId = table.Column<int>(nullable: false)
                        .Annotation("Autoincrement", true),
                    Author = table.Column<string>(nullable: true),
                    DateAdded = table.Column<DateTime>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    FeedUrl = table.Column<string>(nullable: true),
                    ImageUrl = table.Column<string>(nullable: true),
                    Title = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Podcasts", x => x.PodcastId);
                });

            migrationBuilder.CreateTable(
                name: "Episodes",
                columns: table => new
                {
                    EpisodeId = table.Column<int>(nullable: false)
                        .Annotation("Autoincrement", true),
                    Author = table.Column<string>(nullable: true),
                    Guid = table.Column<string>(nullable: true),
                    ImageUrl = table.Column<string>(nullable: true),
                    Path = table.Column<string>(nullable: true),
                    PodcastId = table.Column<int>(nullable: false),
                    Published = table.Column<DateTime>(nullable: false),
                    Subtitle = table.Column<string>(nullable: true),
                    Summary = table.Column<string>(nullable: true),
                    Title = table.Column<string>(nullable: true),
                    WebPath = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Episodes", x => x.EpisodeId);
                    table.ForeignKey(
                        name: "FK_Episodes_Podcasts_PodcastId",
                        column: x => x.PodcastId,
                        principalTable: "Podcasts",
                        principalColumn: "PodcastId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Episodes_PodcastId",
                table: "Episodes",
                column: "PodcastId");
        }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_Commits_ProjectId_UserId_Sha",
                table: "Commits");

            migrationBuilder.CreateIndex(
                name: "IX_Commits_ProjectId_Sha",
                table: "Commits",
                columns: new[] { "ProjectId", "Sha" },
                unique: true);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "PrerequisiteQuestions",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
                    FirstQuestionId = table.Column<int>(nullable: false),
                    Order = table.Column<int>(nullable: false),
                    SecondQuestionId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PrerequisiteQuestions", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PrerequisiteQuestions_Questions_FirstQuestionId",
                        column: x => x.FirstQuestionId,
                        principalTable: "Questions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PrerequisiteQuestions_Questions_SecondQuestionId",
                        column: x => x.SecondQuestionId,
                        principalTable: "Questions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_PrerequisiteQuestions_FirstQuestionId",
                table: "PrerequisiteQuestions",
                column: "FirstQuestionId");

            migrationBuilder.CreateIndex(
                name: "IX_PrerequisiteQuestions_SecondQuestionId",
                table: "PrerequisiteQuestions",
                column: "SecondQuestionId");
        }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "UserDocuments",
                columns: table => new
                {
                    DocumentId = table.Column<int>(nullable: false),
                    ApplicationUserId = table.Column<string>(nullable: false),
                    Permissions = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserDocuments", x => new { x.DocumentId, x.ApplicationUserId });
                    table.ForeignKey(
                        name: "FK_UserDocuments_AspNetUsers_ApplicationUserId",
                        column: x => x.ApplicationUserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_UserDocuments_Documents_DocumentId",
                        column: x => x.DocumentId,
                        principalTable: "Documents",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_UserDocuments_ApplicationUserId",
                table: "UserDocuments",
                column: "ApplicationUserId");

            migrationBuilder.CreateIndex(
                name: "IX_UserDocuments_DocumentId",
                table: "UserDocuments",
                column: "DocumentId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TestResults",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
                    BuildId = table.Column<int>(nullable: false),
                    ClassName = table.Column<string>(nullable: true),
                    FailureMessage = table.Column<string>(nullable: true),
                    FailureOutput = table.Column<string>(nullable: true),
                    FailureTrace = table.Column<string>(nullable: true),
                    TestName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TestResults", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TestResults_Build_BuildId",
                        column: x => x.BuildId,
                        principalTable: "Build",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_TestResults_BuildId",
                table: "TestResults",
                column: "BuildId");

            migrationBuilder.CreateIndex(
                name: "IX_TestResults_BuildId_ClassName_TestName",
                table: "TestResults",
                columns: new[] { "BuildId", "ClassName", "TestName" },
                unique: true);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Clientes",
                columns: table => new
                {
                    ClienteId = table.Column<Guid>(nullable: false),
                    Ativo = table.Column<bool>(nullable: false),
                    CPF = table.Column<string>(nullable: false),
                    DataCadastro = table.Column<DateTime>(nullable: false),
                    DataNascimento = table.Column<DateTime>(nullable: false),
                    Email = table.Column<string>(nullable: false),
                    Nome = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Clientes", x => x.ClienteId);
                });

            migrationBuilder.CreateTable(
                name: "Enderecos",
                columns: table => new
                {
                    EnderecoId = table.Column<Guid>(nullable: false),
                    Bairro = table.Column<string>(nullable: false),
                    CEP = table.Column<string>(nullable: false),
                    Cidade = table.Column<string>(nullable: true),
                    ClienteId = table.Column<Guid>(nullable: false),
                    Complemento = table.Column<string>(nullable: true),
                    Estado = table.Column<string>(nullable: true),
                    Logradouro = table.Column<string>(nullable: false),
                    Numero = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Enderecos", x => x.EnderecoId);
                    table.ForeignKey(
                        name: "FK_Enderecos_Clientes_ClienteId",
                        column: x => x.ClienteId,
                        principalTable: "Clientes",
                        principalColumn: "ClienteId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Enderecos_ClienteId",
                table: "Enderecos",
                column: "ClienteId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.EnsureSchema(
                name: "dbo");

            migrationBuilder.CreateTable(
                name: "AllPropertyTypesOptionals",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Id1                  = table.Column <int>(nullable: false),
                BinaryAttr           = table.Column <byte[]>(nullable: true),
                BooleanAttr          = table.Column <bool>(nullable: true),
                ByteAttr             = table.Column <byte>(nullable: true),
                DateTimeAttr         = table.Column <DateTime>(nullable: true),
                DateTimeOffsetAttr   = table.Column <DateTimeOffset>(nullable: true),
                DecimalAttr          = table.Column <decimal>(nullable: true),
                DoubleAttr           = table.Column <double>(nullable: true),
                GuidAttr             = table.Column <Guid>(nullable: true),
                Int16Attr            = table.Column <short>(nullable: true),
                Int32Attr            = table.Column <int>(nullable: true),
                Int64Attr            = table.Column <long>(nullable: true),
                SingleAttr           = table.Column <float>(nullable: true),
                StringAttr           = table.Column <string>(nullable: true),
                TimeAttr             = table.Column <TimeSpan>(nullable: true),
                Timestamp            = table.Column <byte[]>(rowVersion: true, nullable: true),
                OwnedType_SingleAttr = table.Column <float>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AllPropertyTypesOptionals", x => new { x.Id, x.Id1 });
            });

            migrationBuilder.CreateTable(
                name: "AllPropertyTypesRequireds",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                BinaryAttr         = table.Column <byte[]>(nullable: false),
                BooleanAttr        = table.Column <bool>(nullable: false),
                ByteAttr           = table.Column <byte>(nullable: false),
                DateTimeAttr       = table.Column <DateTime>(nullable: false),
                DateTimeOffsetAttr = table.Column <DateTimeOffset>(nullable: false),
                DecimalAttr        = table.Column <decimal>(nullable: false),
                DoubleAttr         = table.Column <double>(nullable: false),
                GuidAttr           = table.Column <Guid>(nullable: false),
                Int16Attr          = table.Column <short>(nullable: false),
                Int32Attr          = table.Column <int>(nullable: false),
                Int64Attr          = table.Column <long>(nullable: false),
                SingleAttr         = table.Column <float>(nullable: false),
                StringAttr         = table.Column <string>(nullable: false),
                TimeAttr           = table.Column <TimeSpan>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AllPropertyTypesRequireds", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "BaseClassWithRequiredProperties",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Property0       = table.Column <string>(nullable: false),
                Discriminator   = table.Column <string>(nullable: false),
                Property1       = table.Column <string>(nullable: true),
                PropertyInChild = table.Column <string>(nullable: true),
                ConcreteDerivedClassWithRequiredProperties_Property1 = table.Column <string>(nullable: true),
                DerivedClass_Property1       = table.Column <string>(nullable: true),
                DerivedClass_PropertyInChild = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_BaseClassWithRequiredProperties", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "BParentRequireds",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1")
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_BParentRequireds", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Masters",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1")
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Masters", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "ParserTests",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                name1  = table.Column <string>(nullable: true),
                name2  = table.Column <string>(nullable: true),
                name3  = table.Column <int>(nullable: true),
                name4  = table.Column <int>(nullable: true),
                name5  = table.Column <int>(nullable: true),
                name6  = table.Column <int>(nullable: true),
                name7  = table.Column <string>(nullable: true),
                name8  = table.Column <string>(nullable: true),
                name9  = table.Column <string>(nullable: true),
                name   = table.Column <string>(nullable: true),
                name11 = table.Column <int>(nullable: true),
                name12 = table.Column <int>(nullable: true),
                name13 = table.Column <int>(nullable: true),
                name14 = table.Column <int>(nullable: true),
                name15 = table.Column <string>(nullable: true),
                name16 = table.Column <string>(nullable: true),
                name17 = table.Column <string>(nullable: true),
                name18 = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ParserTests", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "RenamedColumns",
                schema: "dbo",
                columns: table => new
            {
                Foo = table.Column <int>(nullable: false)
                      .Annotation("SqlServer:Identity", "1, 1")
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_RenamedColumns", x => x.Foo);
            });

            migrationBuilder.CreateTable(
                name: "Children",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Parent_Id         = table.Column <int>(nullable: true),
                Child_Children_Id = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Children", x => x.Id);
                table.ForeignKey(
                    name: "FK_Children_Masters_Child_Children_Id",
                    column: x => x.Child_Children_Id,
                    principalSchema: "dbo",
                    principalTable: "Masters",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_Children_Children_Parent_Id",
                    column: x => x.Parent_Id,
                    principalSchema: "dbo",
                    principalTable: "Children",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "BParentCollections",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                BChildRequired_Id = table.Column <int>(nullable: false),
                BChildOptional_Id = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_BParentCollections", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "BParentOptionals",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                BChildRequired_Id = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_BParentOptionals", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "BChilds",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                BParentRequired_Id   = table.Column <int>(nullable: true),
                BParentRequired_1_Id = table.Column <int>(nullable: false),
                BParentRequired_2_Id = table.Column <int>(nullable: true),
                BParentOptional_1_Id = table.Column <int>(nullable: true),
                BParentOptional_2_Id = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_BChilds", x => x.Id);
                table.ForeignKey(
                    name: "FK_BChilds_BParentOptionals_BParentOptional_1_Id",
                    column: x => x.BParentOptional_1_Id,
                    principalSchema: "dbo",
                    principalTable: "BParentOptionals",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_BChilds_BParentOptionals_BParentOptional_2_Id",
                    column: x => x.BParentOptional_2_Id,
                    principalSchema: "dbo",
                    principalTable: "BParentOptionals",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_BChilds_BParentRequireds_BParentRequired_1_Id",
                    column: x => x.BParentRequired_1_Id,
                    principalSchema: "dbo",
                    principalTable: "BParentRequireds",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_BChilds_BParentRequireds_BParentRequired_2_Id",
                    column: x => x.BParentRequired_2_Id,
                    principalSchema: "dbo",
                    principalTable: "BParentRequireds",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_BChilds_BParentRequireds_BParentRequired_Id",
                    column: x => x.BParentRequired_Id,
                    principalSchema: "dbo",
                    principalTable: "BParentRequireds",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "UChilds",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                UChild_UChildCollection_Id = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_UChilds", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "HiddenEntities",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Property1                = table.Column <string>(nullable: true),
                Discriminator            = table.Column <string>(nullable: false),
                PropertyInChild          = table.Column <string>(nullable: true),
                UChild_UChildOptional_Id = table.Column <int>(nullable: true),
                UChildRequired_Id        = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_HiddenEntities", x => x.Id);
                table.ForeignKey(
                    name: "FK_HiddenEntities_UChilds_UChildRequired_Id",
                    column: x => x.UChildRequired_Id,
                    principalSchema: "dbo",
                    principalTable: "UChilds",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_HiddenEntities_UChilds_UChild_UChildOptional_Id",
                    column: x => x.UChild_UChildOptional_Id,
                    principalSchema: "dbo",
                    principalTable: "UChilds",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "UParentCollections",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                UChildRequired_Id = table.Column <int>(nullable: true),
                UChildOptional_Id = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_UParentCollections", x => x.Id);
                table.ForeignKey(
                    name: "FK_UParentCollections_UChilds_UChildOptional_Id",
                    column: x => x.UChildOptional_Id,
                    principalSchema: "dbo",
                    principalTable: "UChilds",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_UParentCollections_UChilds_UChildRequired_Id",
                    column: x => x.UChildRequired_Id,
                    principalSchema: "dbo",
                    principalTable: "UChilds",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "UParentRequireds",
                schema: "dbo",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                UChild_UChildRequired_Id = table.Column <int>(nullable: false),
                UChild_UChildOptional_Id = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_UParentRequireds", x => x.Id);
                table.ForeignKey(
                    name: "FK_UParentRequireds_UChilds_UChild_UChildOptional_Id",
                    column: x => x.UChild_UChildOptional_Id,
                    principalSchema: "dbo",
                    principalTable: "UChilds",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_UParentRequireds_UChilds_UChild_UChildRequired_Id",
                    column: x => x.UChild_UChildRequired_Id,
                    principalSchema: "dbo",
                    principalTable: "UChilds",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_BChilds_BParentOptional_1_Id",
                schema: "dbo",
                table: "BChilds",
                column: "BParentOptional_1_Id");

            migrationBuilder.CreateIndex(
                name: "IX_BChilds_BParentOptional_2_Id",
                schema: "dbo",
                table: "BChilds",
                column: "BParentOptional_2_Id",
                unique: true,
                filter: "[BParentOptional_2_Id] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_BChilds_BParentRequired_1_Id",
                schema: "dbo",
                table: "BChilds",
                column: "BParentRequired_1_Id",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_BChilds_BParentRequired_2_Id",
                schema: "dbo",
                table: "BChilds",
                column: "BParentRequired_2_Id");

            migrationBuilder.CreateIndex(
                name: "IX_BChilds_BParentRequired_Id",
                schema: "dbo",
                table: "BChilds",
                column: "BParentRequired_Id",
                unique: true,
                filter: "[BParentRequired_Id] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_BParentCollections_BChildOptional_Id",
                schema: "dbo",
                table: "BParentCollections",
                column: "BChildOptional_Id");

            migrationBuilder.CreateIndex(
                name: "IX_BParentCollections_BChildRequired_Id",
                schema: "dbo",
                table: "BParentCollections",
                column: "BChildRequired_Id");

            migrationBuilder.CreateIndex(
                name: "IX_BParentOptionals_BChildRequired_Id",
                schema: "dbo",
                table: "BParentOptionals",
                column: "BChildRequired_Id",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Children_Child_Children_Id",
                schema: "dbo",
                table: "Children",
                column: "Child_Children_Id");

            migrationBuilder.CreateIndex(
                name: "IX_Children_Parent_Id",
                schema: "dbo",
                table: "Children",
                column: "Parent_Id");

            migrationBuilder.CreateIndex(
                name: "IX_HiddenEntities_UChildRequired_Id",
                schema: "dbo",
                table: "HiddenEntities",
                column: "UChildRequired_Id",
                unique: true,
                filter: "[UChildRequired_Id] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_HiddenEntities_UChild_UChildOptional_Id",
                schema: "dbo",
                table: "HiddenEntities",
                column: "UChild_UChildOptional_Id",
                unique: true,
                filter: "[UChild_UChildOptional_Id] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_UChilds_UChild_UChildCollection_Id",
                schema: "dbo",
                table: "UChilds",
                column: "UChild_UChildCollection_Id");

            migrationBuilder.CreateIndex(
                name: "IX_UParentCollections_UChildOptional_Id",
                schema: "dbo",
                table: "UParentCollections",
                column: "UChildOptional_Id");

            migrationBuilder.CreateIndex(
                name: "IX_UParentCollections_UChildRequired_Id",
                schema: "dbo",
                table: "UParentCollections",
                column: "UChildRequired_Id");

            migrationBuilder.CreateIndex(
                name: "IX_UParentRequireds_UChild_UChildOptional_Id",
                schema: "dbo",
                table: "UParentRequireds",
                column: "UChild_UChildOptional_Id",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_UParentRequireds_UChild_UChildRequired_Id",
                schema: "dbo",
                table: "UParentRequireds",
                column: "UChild_UChildRequired_Id",
                unique: true);

            migrationBuilder.AddForeignKey(
                name: "FK_BParentCollections_BChilds_BChildOptional_Id",
                schema: "dbo",
                table: "BParentCollections",
                column: "BChildOptional_Id",
                principalSchema: "dbo",
                principalTable: "BChilds",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_BParentCollections_BChilds_BChildRequired_Id",
                schema: "dbo",
                table: "BParentCollections",
                column: "BChildRequired_Id",
                principalSchema: "dbo",
                principalTable: "BChilds",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BParentOptionals_BChilds_BChildRequired_Id",
                schema: "dbo",
                table: "BParentOptionals",
                column: "BChildRequired_Id",
                principalSchema: "dbo",
                principalTable: "BChilds",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_UChilds_HiddenEntities_UChild_UChildCollection_Id",
                schema: "dbo",
                table: "UChilds",
                column: "UChild_UChildCollection_Id",
                principalSchema: "dbo",
                principalTable: "HiddenEntities",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_UChilds_UParentRequireds_UChild_UChildCollection_Id",
                schema: "dbo",
                table: "UChilds",
                column: "UChild_UChildCollection_Id",
                principalSchema: "dbo",
                principalTable: "UParentRequireds",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
示例#32
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AspNetRoles",
                columns: table => new
            {
                Id = table.Column <string>(nullable: false),
                ConcurrencyStamp = table.Column <string>(nullable: true),
                Name             = table.Column <string>(maxLength: 256, nullable: true),
                NormalizedName   = table.Column <string>(maxLength: 256, nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetRoles", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUserTokens",
                columns: table => new
            {
                UserId        = table.Column <string>(nullable: false),
                LoginProvider = table.Column <string>(nullable: false),
                Name          = table.Column <string>(nullable: false),
                Value         = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
            });

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

            migrationBuilder.CreateTable(
                name: "Phases",
                columns: table => new
            {
                PhaseId = table.Column <int>(nullable: false)
                          .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Description = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Phases", x => x.PhaseId);
            });

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

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

            migrationBuilder.CreateTable(
                name: "AspNetRoleClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ClaimType  = table.Column <string>(nullable: true),
                ClaimValue = table.Column <string>(nullable: true),
                RoleId     = table.Column <string>(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>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ClaimType  = table.Column <string>(nullable: true),
                ClaimValue = table.Column <string>(nullable: true),
                UserId     = table.Column <string>(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>(nullable: false),
                ProviderKey         = table.Column <string>(nullable: false),
                ProviderDisplayName = table.Column <string>(nullable: true),
                UserId = table.Column <string>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
                table.ForeignKey(
                    name: "FK_AspNetUserLogins_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

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

            migrationBuilder.CreateTable(
                name: "Projects",
                columns: table => new
            {
                ProjectId = table.Column <int>(nullable: false)
                            .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Description = table.Column <string>(nullable: true),
                EndDate     = table.Column <DateTime>(nullable: false),
                StartDate   = table.Column <DateTime>(nullable: false),
                Title       = table.Column <string>(nullable: true),
                userId      = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Projects", x => x.ProjectId);
                table.ForeignKey(
                    name: "FK_Projects_AspNetUsers_userId",
                    column: x => x.userId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Tools",
                columns: table => new
            {
                ToolId = table.Column <int>(nullable: false)
                         .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Description   = table.Column <string>(nullable: true),
                Documentation = table.Column <string>(nullable: true),
                Name          = table.Column <string>(nullable: true),
                ToolTypeId    = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Tools", x => x.ToolId);
                table.ForeignKey(
                    name: "FK_Tools_ToolTypes_ToolTypeId",
                    column: x => x.ToolTypeId,
                    principalTable: "ToolTypes",
                    principalColumn: "ToolTypeId",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Sprints",
                columns: table => new
            {
                SprintId = table.Column <int>(nullable: false)
                           .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Done       = table.Column <bool>(nullable: false),
                EndDate    = table.Column <DateTime>(nullable: false),
                Goal       = table.Column <string>(nullable: true),
                InProgress = table.Column <bool>(nullable: false),
                Name       = table.Column <string>(nullable: true),
                ProjectId  = table.Column <int>(nullable: true),
                StartDate  = table.Column <DateTime>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Sprints", x => x.SprintId);
                table.ForeignKey(
                    name: "FK_Sprints_Projects_ProjectId",
                    column: x => x.ProjectId,
                    principalTable: "Projects",
                    principalColumn: "ProjectId",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "UserProjects",
                columns: table => new
            {
                UserProjectId = table.Column <int>(nullable: false)
                                .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ProjectId = table.Column <int>(nullable: false),
                UserId    = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_UserProjects", x => x.UserProjectId);
                table.ForeignKey(
                    name: "FK_UserProjects_Projects_ProjectId",
                    column: x => x.ProjectId,
                    principalTable: "Projects",
                    principalColumn: "ProjectId",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_UserProjects_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "UserStories",
                columns: table => new
            {
                UserStoryId = table.Column <int>(nullable: false)
                              .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ProjectId = table.Column <int>(nullable: true),
                Spec      = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_UserStories", x => x.UserStoryId);
                table.ForeignKey(
                    name: "FK_UserStories_Projects_ProjectId",
                    column: x => x.ProjectId,
                    principalTable: "Projects",
                    principalColumn: "ProjectId",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "ProjectTools",
                columns: table => new
            {
                ProjectId = table.Column <int>(nullable: false),
                ToolId    = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ProjectTools", x => new { x.ProjectId, x.ToolId });
                table.ForeignKey(
                    name: "FK_ProjectTools_Projects_ProjectId",
                    column: x => x.ProjectId,
                    principalTable: "Projects",
                    principalColumn: "ProjectId",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ProjectTools_Tools_ToolId",
                    column: x => x.ToolId,
                    principalTable: "Tools",
                    principalColumn: "ToolId",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Tasks",
                columns: table => new
            {
                TaskId = table.Column <int>(nullable: false)
                         .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Complete    = table.Column <bool>(nullable: false),
                Description = table.Column <string>(nullable: true),
                InProgress  = table.Column <bool>(nullable: false),
                PhaseId     = table.Column <int>(nullable: false),
                Priority    = table.Column <string>(nullable: true),
                SprintId    = table.Column <int>(nullable: true),
                UserId      = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Tasks", x => x.TaskId);
                table.ForeignKey(
                    name: "FK_Tasks_Phases_PhaseId",
                    column: x => x.PhaseId,
                    principalTable: "Phases",
                    principalColumn: "PhaseId",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_Tasks_Sprints_SprintId",
                    column: x => x.SprintId,
                    principalTable: "Sprints",
                    principalColumn: "SprintId",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Tasks_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Updates",
                columns: table => new
            {
                UpdateId = table.Column <int>(nullable: false)
                           .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Note         = table.Column <string>(nullable: true),
                ProjectId    = table.Column <int>(nullable: true),
                SprintId     = table.Column <int>(nullable: true),
                TimeStamp    = table.Column <DateTime>(nullable: false),
                UpdateTypeId = table.Column <int>(nullable: false),
                UserId       = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Updates", x => x.UpdateId);
                table.ForeignKey(
                    name: "FK_Updates_Projects_ProjectId",
                    column: x => x.ProjectId,
                    principalTable: "Projects",
                    principalColumn: "ProjectId",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Updates_Sprints_SprintId",
                    column: x => x.SprintId,
                    principalTable: "Sprints",
                    principalColumn: "SprintId",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Updates_UpdateTypes_UpdateTypeId",
                    column: x => x.UpdateTypeId,
                    principalTable: "UpdateTypes",
                    principalColumn: "UpdateTypeId",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_Updates_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles",
                column: "NormalizedName");

            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.CreateIndex(
                name: "IX_AspNetUserRoles_UserId",
                table: "AspNetUserRoles",
                column: "UserId");

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

            migrationBuilder.CreateIndex(
                name: "UserNameIndex",
                table: "AspNetUsers",
                column: "NormalizedUserName",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Projects_userId",
                table: "Projects",
                column: "userId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectTools_ProjectId",
                table: "ProjectTools",
                column: "ProjectId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectTools_ToolId",
                table: "ProjectTools",
                column: "ToolId");

            migrationBuilder.CreateIndex(
                name: "IX_Sprints_ProjectId",
                table: "Sprints",
                column: "ProjectId");

            migrationBuilder.CreateIndex(
                name: "IX_Tasks_PhaseId",
                table: "Tasks",
                column: "PhaseId");

            migrationBuilder.CreateIndex(
                name: "IX_Tasks_SprintId",
                table: "Tasks",
                column: "SprintId");

            migrationBuilder.CreateIndex(
                name: "IX_Tasks_UserId",
                table: "Tasks",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_Tools_ToolTypeId",
                table: "Tools",
                column: "ToolTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_Updates_ProjectId",
                table: "Updates",
                column: "ProjectId");

            migrationBuilder.CreateIndex(
                name: "IX_Updates_SprintId",
                table: "Updates",
                column: "SprintId");

            migrationBuilder.CreateIndex(
                name: "IX_Updates_UpdateTypeId",
                table: "Updates",
                column: "UpdateTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_Updates_UserId",
                table: "Updates",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_UserProjects_ProjectId",
                table: "UserProjects",
                column: "ProjectId");

            migrationBuilder.CreateIndex(
                name: "IX_UserProjects_UserId",
                table: "UserProjects",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_UserStories_ProjectId",
                table: "UserStories",
                column: "ProjectId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateSequence(
                name: "catalog_brand_hilo",
                incrementBy: 10);

            migrationBuilder.CreateSequence(
                name: "catalog_hilo",
                incrementBy: 10);

            migrationBuilder.CreateSequence(
                name: "catalog_type_hilo",
                incrementBy: 10);

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

            migrationBuilder.CreateTable(
                name: "CatalogBrand",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false),
                    Brand = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CatalogBrand", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CatalogType",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false),
                    Type = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CatalogType", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Orders",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false),
                        //.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    BuyerId = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    OrderDate = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
                    ShipToAddress_City = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ShipToAddress_Country = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ShipToAddress_State = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ShipToAddress_Street = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ShipToAddress_ZipCode = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Orders", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "BasketItem",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false),
                    BasketId = table.Column<int>(type: "int", nullable: true),
                    CatalogItemId = table.Column<int>(type: "int", nullable: false),
                    Quantity = table.Column<int>(type: "int", nullable: false),
                    UnitPrice = table.Column<decimal>(type: "decimal(18, 2)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BasketItem", x => x.Id);
                    table.ForeignKey(
                        name: "FK_BasketItem_Baskets_BasketId",
                        column: x => x.BasketId,
                        principalTable: "Baskets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Catalog",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false),
                    CatalogBrandId = table.Column<int>(type: "int", nullable: false),
                    CatalogTypeId = table.Column<int>(type: "int", nullable: false),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    PictureUri = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Price = table.Column<decimal>(type: "decimal(18, 2)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Catalog", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Catalog_CatalogBrand_CatalogBrandId",
                        column: x => x.CatalogBrandId,
                        principalTable: "CatalogBrand",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Catalog_CatalogType_CatalogTypeId",
                        column: x => x.CatalogTypeId,
                        principalTable: "CatalogType",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "OrderItems",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false),
                    OrderId = table.Column<int>(type: "int", nullable: true),
                    UnitPrice = table.Column<decimal>(type: "decimal(18, 2)", nullable: false),
                    Units = table.Column<int>(type: "int", nullable: false),
                    ItemOrdered_CatalogItemId = table.Column<int>(type: "int", nullable: false),
                    ItemOrdered_PictureUri = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ItemOrdered_ProductName = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OrderItems", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OrderItems_Orders_OrderId",
                        column: x => x.OrderId,
                        principalTable: "Orders",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_BasketItem_BasketId",
                table: "BasketItem",
                column: "BasketId");

            migrationBuilder.CreateIndex(
                name: "IX_Catalog_CatalogBrandId",
                table: "Catalog",
                column: "CatalogBrandId");

            migrationBuilder.CreateIndex(
                name: "IX_Catalog_CatalogTypeId",
                table: "Catalog",
                column: "CatalogTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_OrderItems_OrderId",
                table: "OrderItems",
                column: "OrderId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Character_LocationDTO_CurrentLocationId",
                table: "Character");

            migrationBuilder.DropForeignKey(
                name: "FK_Character_Weapon_WeaponId",
                table: "Character");

            migrationBuilder.DropForeignKey(
                name: "FK_EnemyInLocation_LocationDTO_LocationDTOId",
                table: "EnemyInLocation");

            migrationBuilder.DropForeignKey(
                name: "FK_EnemyLoot_Character_CharacterId",
                table: "EnemyLoot");

            migrationBuilder.DropTable(
                name: "LocationDTO");

            migrationBuilder.DropPrimaryKey(
                name: "PK_EnemyLoot",
                table: "EnemyLoot");

            migrationBuilder.DropIndex(
                name: "IX_EnemyInLocation_LocationDTOId",
                table: "EnemyInLocation");

            migrationBuilder.DropIndex(
                name: "IX_Character_CurrentLocationId",
                table: "Character");

            migrationBuilder.DropIndex(
                name: "IX_Character_WeaponId",
                table: "Character");

            migrationBuilder.DropColumn(
                name: "LocationDTOId",
                table: "EnemyInLocation");

            migrationBuilder.DropColumn(
                name: "CurrentLocationId",
                table: "Character");

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

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

            migrationBuilder.AddPrimaryKey(
                name: "PK_EnemyLoot",
                table: "EnemyLoot",
                columns: new[] { "EnemyId", "ItemId" });

            migrationBuilder.CreateIndex(
                name: "IX_EnemyLoot_CharacterId",
                table: "EnemyLoot",
                column: "CharacterId");

            migrationBuilder.AddForeignKey(
                name: "FK_EnemyLoot_Character_CharacterId",
                table: "EnemyLoot",
                column: "CharacterId",
                principalTable: "Character",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_EnemyLoot_Enemy_EnemyId",
                table: "EnemyLoot",
                column: "EnemyId",
                principalTable: "Enemy",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
示例#35
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn <int>(
                name: "TiposViviendatblId",
                table: "Propietariostbls",
                nullable: true);

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

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

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

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

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

            migrationBuilder.CreateTable(
                name: "Negociostbls",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Neg_Nombre        = table.Column <string>(nullable: true),
                Neg_Descripcion   = table.Column <string>(nullable: true),
                Neg_Telefono      = table.Column <string>(nullable: true),
                Neg_Direccion     = table.Column <string>(nullable: true),
                Neg_Email         = table.Column <string>(nullable: true),
                Neg_FechaCreacion = table.Column <DateTime>(nullable: false),
                Neg_Estado        = table.Column <string>(nullable: false),
                PropietariosId    = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Negociostbls", x => x.Id);
                table.ForeignKey(
                    name: "FK_Negociostbls_Propietariostbls_PropietariosId",
                    column: x => x.PropietariosId,
                    principalTable: "Propietariostbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

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

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

            migrationBuilder.CreateTable(
                name: "Valorestbls",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Val_Valor         = table.Column <string>(nullable: true),
                Val_FechaCreacion = table.Column <DateTime>(nullable: false),
                Val_Estado        = table.Column <string>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Valorestbls", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Vehiculostbls",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Veh_Codigo       = table.Column <string>(maxLength: 5, nullable: false),
                Veh_Placa        = table.Column <string>(maxLength: 4, nullable: false),
                ImageUrl         = table.Column <string>(nullable: true),
                Veh_Estado       = table.Column <string>(nullable: true),
                Veh_Born         = table.Column <DateTime>(nullable: false),
                Veh_Detalles     = table.Column <string>(nullable: true),
                PropietarioId    = table.Column <int>(nullable: true),
                MarcasAutostblId = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Vehiculostbls", x => x.Id);
                table.ForeignKey(
                    name: "FK_Vehiculostbls_MarcasAutostbls_MarcasAutostblId",
                    column: x => x.MarcasAutostblId,
                    principalTable: "MarcasAutostbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Vehiculostbls_Propietariostbls_PropietarioId",
                    column: x => x.PropietarioId,
                    principalTable: "Propietariostbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Productostbls",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Pro_Nombre        = table.Column <string>(nullable: true),
                Pro_Precio        = table.Column <string>(nullable: true),
                Pro_FechaCreacion = table.Column <DateTime>(nullable: false),
                Pro_Estado        = table.Column <string>(nullable: false),
                NegocioId         = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Productostbls", x => x.Id);
                table.ForeignKey(
                    name: "FK_Productostbls_Negociostbls_NegocioId",
                    column: x => x.NegocioId,
                    principalTable: "Negociostbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Userstbl",
                columns: table => new
            {
                Id                     = table.Column <string>(nullable: false),
                UserName               = table.Column <string>(nullable: true),
                NormalizedUserName     = table.Column <string>(nullable: true),
                Email                  = table.Column <string>(nullable: true),
                NormalizedEmail        = table.Column <string>(nullable: true),
                EmailConfirmed         = table.Column <bool>(nullable: false),
                PasswordHash           = table.Column <string>(nullable: true),
                SecurityStamp          = table.Column <string>(nullable: true),
                ConcurrencyStamp       = table.Column <string>(nullable: true),
                PhoneNumber            = table.Column <string>(nullable: true),
                PhoneNumberConfirmed   = table.Column <bool>(nullable: false),
                TwoFactorEnabled       = table.Column <bool>(nullable: false),
                LockoutEnd             = table.Column <DateTimeOffset>(nullable: true),
                LockoutEnabled         = table.Column <bool>(nullable: false),
                AccessFailedCount      = table.Column <int>(nullable: false),
                Pro_Lote               = table.Column <string>(maxLength: 4, nullable: false),
                Pro_TipoViviendaId     = table.Column <int>(nullable: true),
                Pro_Nombres            = table.Column <string>(maxLength: 50, nullable: false),
                Pro_Apellidos          = table.Column <string>(maxLength: 50, nullable: false),
                Pro_Observaciones      = table.Column <string>(nullable: true),
                Pro_Telefono           = table.Column <string>(maxLength: 10, nullable: false),
                Pro_TipoIdentificacion = table.Column <string>(nullable: false),
                Pro_Identificacion     = table.Column <string>(maxLength: 10, nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Userstbl", x => x.Id);
                table.ForeignKey(
                    name: "FK_Userstbl_TiposViviendatbls_Pro_TipoViviendaId",
                    column: x => x.Pro_TipoViviendaId,
                    principalTable: "TiposViviendatbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Pagostbls",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                PAG_FECHAPAGADO   = table.Column <DateTime>(nullable: false),
                PAG_FECHACREACION = table.Column <DateTime>(nullable: false),
                PAG_ESTADO        = table.Column <string>(nullable: false),
                PropietarioId     = table.Column <int>(nullable: true),
                AnioId            = table.Column <int>(nullable: true),
                MesId             = table.Column <int>(nullable: true),
                ValId             = table.Column <int>(nullable: true),
                PuntodePagoId     = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Pagostbls", x => x.Id);
                table.ForeignKey(
                    name: "FK_Pagostbls_Aniostbls_AnioId",
                    column: x => x.AnioId,
                    principalTable: "Aniostbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Pagostbls_Mesestbls_MesId",
                    column: x => x.MesId,
                    principalTable: "Mesestbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Pagostbls_Propietariostbls_PropietarioId",
                    column: x => x.PropietarioId,
                    principalTable: "Propietariostbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Pagostbls_PuntosPagotbls_PuntodePagoId",
                    column: x => x.PuntodePagoId,
                    principalTable: "PuntosPagotbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Pagostbls_Valorestbls_ValId",
                    column: x => x.ValId,
                    principalTable: "Valorestbls",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Propietariostbls_TiposViviendatblId",
                table: "Propietariostbls",
                column: "TiposViviendatblId");

            migrationBuilder.CreateIndex(
                name: "IX_Propietariostbls_UserId",
                table: "Propietariostbls",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_Negociostbls_PropietariosId",
                table: "Negociostbls",
                column: "PropietariosId");

            migrationBuilder.CreateIndex(
                name: "IX_Pagostbls_AnioId",
                table: "Pagostbls",
                column: "AnioId");

            migrationBuilder.CreateIndex(
                name: "IX_Pagostbls_MesId",
                table: "Pagostbls",
                column: "MesId");

            migrationBuilder.CreateIndex(
                name: "IX_Pagostbls_PropietarioId",
                table: "Pagostbls",
                column: "PropietarioId");

            migrationBuilder.CreateIndex(
                name: "IX_Pagostbls_PuntodePagoId",
                table: "Pagostbls",
                column: "PuntodePagoId");

            migrationBuilder.CreateIndex(
                name: "IX_Pagostbls_ValId",
                table: "Pagostbls",
                column: "ValId");

            migrationBuilder.CreateIndex(
                name: "IX_Productostbls_NegocioId",
                table: "Productostbls",
                column: "NegocioId");

            migrationBuilder.CreateIndex(
                name: "IX_Userstbl_Pro_TipoViviendaId",
                table: "Userstbl",
                column: "Pro_TipoViviendaId");

            migrationBuilder.CreateIndex(
                name: "IX_Vehiculostbls_MarcasAutostblId",
                table: "Vehiculostbls",
                column: "MarcasAutostblId");

            migrationBuilder.CreateIndex(
                name: "IX_Vehiculostbls_PropietarioId",
                table: "Vehiculostbls",
                column: "PropietarioId");

            migrationBuilder.AddForeignKey(
                name: "FK_Propietariostbls_TiposViviendatbls_TiposViviendatblId",
                table: "Propietariostbls",
                column: "TiposViviendatblId",
                principalTable: "TiposViviendatbls",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Propietariostbls_Userstbl_UserId",
                table: "Propietariostbls",
                column: "UserId",
                principalTable: "Userstbl",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
示例#36
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Region",
                columns: table => new
            {
                Id       = table.Column <Guid>(nullable: false),
                RegionId = table.Column <int>(nullable: false)
                           .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Region", x => x.RegionId);
            });

            migrationBuilder.CreateTable(
                name: "District",
                columns: table => new
            {
                Id         = table.Column <Guid>(nullable: false),
                DistrictId = table.Column <int>(nullable: false)
                             .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name     = table.Column <string>(nullable: true),
                RegionId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_District", x => x.DistrictId);
                table.ForeignKey(
                    name: "FK_District_Region_RegionId",
                    column: x => x.RegionId,
                    principalTable: "Region",
                    principalColumn: "RegionId",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Building",
                columns: table => new
            {
                Id         = table.Column <Guid>(nullable: false),
                BuildingId = table.Column <int>(nullable: false)
                             .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name       = table.Column <string>(nullable: true),
                Queue      = table.Column <int>(nullable: false),
                Housing    = table.Column <string>(nullable: true),
                DistrictId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Building", x => x.BuildingId);
                table.ForeignKey(
                    name: "FK_Building_District_DistrictId",
                    column: x => x.DistrictId,
                    principalTable: "District",
                    principalColumn: "DistrictId",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Flat",
                columns: table => new
            {
                Id     = table.Column <Guid>(nullable: false),
                FlatId = table.Column <int>(nullable: false)
                         .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                RoomsCount  = table.Column <int>(nullable: false),
                TotalArea   = table.Column <decimal>(type: "decimal(18,2)", nullable: false),
                KitchenArea = table.Column <decimal>(type: "decimal(18,2)", nullable: false),
                Floor       = table.Column <int>(nullable: false),
                BuildingId  = table.Column <int>(nullable: false),
                Price       = table.Column <decimal>(type: "decimal(18,2)", nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Flat", x => x.FlatId);
                table.ForeignKey(
                    name: "FK_Flat_Building_BuildingId",
                    column: x => x.BuildingId,
                    principalTable: "Building",
                    principalColumn: "BuildingId",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "Index_BuildingId",
                table: "Building",
                column: "BuildingId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Building_DistrictId",
                table: "Building",
                column: "DistrictId");

            migrationBuilder.CreateIndex(
                name: "Index_DistrictId",
                table: "District",
                column: "DistrictId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_District_RegionId",
                table: "District",
                column: "RegionId");

            migrationBuilder.CreateIndex(
                name: "IX_Flat_BuildingId",
                table: "Flat",
                column: "BuildingId");

            migrationBuilder.CreateIndex(
                name: "Index_FlatId",
                table: "Flat",
                column: "FlatId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "Index_RegionId",
                table: "Region",
                column: "RegionId",
                unique: true);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_AbpOrganizationUnits_TenantId_Code",
                table: "AbpOrganizationUnits");

            migrationBuilder.CreateTable(
                name: "AbpDynamicParameters",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                ParameterName = table.Column <string>(nullable: true),
                InputType     = table.Column <string>(nullable: true),
                Permission    = table.Column <string>(nullable: true),
                TenantId      = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AbpDynamicParameters", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "AbpDynamicParameterValues",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Value              = table.Column <string>(nullable: false),
                TenantId           = table.Column <int>(nullable: true),
                DynamicParameterId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AbpDynamicParameterValues", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpDynamicParameterValues_AbpDynamicParameters_DynamicParameterId",
                    column: x => x.DynamicParameterId,
                    principalTable: "AbpDynamicParameters",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AbpEntityDynamicParameters",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                EntityFullName     = table.Column <string>(nullable: true),
                DynamicParameterId = table.Column <int>(nullable: false),
                TenantId           = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AbpEntityDynamicParameters", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpEntityDynamicParameters_AbpDynamicParameters_DynamicParameterId",
                    column: x => x.DynamicParameterId,
                    principalTable: "AbpDynamicParameters",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AbpEntityDynamicParameterValues",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Value    = table.Column <string>(nullable: false),
                EntityId = table.Column <string>(nullable: true),
                EntityDynamicParameterId = table.Column <int>(nullable: false),
                TenantId = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AbpEntityDynamicParameterValues", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpEntityDynamicParameterValues_AbpEntityDynamicParameters_EntityDynamicParameterId",
                    column: x => x.EntityDynamicParameterId,
                    principalTable: "AbpEntityDynamicParameters",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_AbpOrganizationUnits_TenantId_Code",
                table: "AbpOrganizationUnits",
                columns: new[] { "TenantId", "Code" },
                unique: true,
                filter: "[TenantId] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_AbpDynamicParameters_ParameterName_TenantId",
                table: "AbpDynamicParameters",
                columns: new[] { "ParameterName", "TenantId" },
                unique: true,
                filter: "[ParameterName] IS NOT NULL AND [TenantId] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_AbpDynamicParameterValues_DynamicParameterId",
                table: "AbpDynamicParameterValues",
                column: "DynamicParameterId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpEntityDynamicParameters_DynamicParameterId",
                table: "AbpEntityDynamicParameters",
                column: "DynamicParameterId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpEntityDynamicParameters_EntityFullName_DynamicParameterId_TenantId",
                table: "AbpEntityDynamicParameters",
                columns: new[] { "EntityFullName", "DynamicParameterId", "TenantId" },
                unique: true,
                filter: "[EntityFullName] IS NOT NULL AND [TenantId] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_AbpEntityDynamicParameterValues_EntityDynamicParameterId",
                table: "AbpEntityDynamicParameterValues",
                column: "EntityDynamicParameterId");
        }
示例#38
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Categories",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Categories", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Products",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name        = table.Column <string>(nullable: true),
                Description = table.Column <string>(nullable: true),
                Unit        = table.Column <string>(nullable: true),
                Quantity    = table.Column <int>(nullable: false),
                Price       = table.Column <decimal>(nullable: false),
                CategoryId  = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Products", x => x.Id);
                table.ForeignKey(
                    name: "FK_Products_Categories_CategoryId",
                    column: x => x.CategoryId,
                    principalTable: "Categories",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.InsertData(
                table: "Categories",
                columns: new[] { "Id", "Name" },
                values: new object[] { 1, "Books" });

            migrationBuilder.InsertData(
                table: "Categories",
                columns: new[] { "Id", "Name" },
                values: new object[] { 2, "Sports Appliances" });

            migrationBuilder.InsertData(
                table: "Categories",
                columns: new[] { "Id", "Name" },
                values: new object[] { 3, "Musical Instruments" });

            migrationBuilder.InsertData(
                table: "Products",
                columns: new[] { "Id", "CategoryId", "Description", "Name", "Price", "Quantity", "Unit" },
                values: new object[] { 1, 1, "LoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsum", "Harry Potter", 20m, 20, "Piece" });

            migrationBuilder.InsertData(
                table: "Products",
                columns: new[] { "Id", "CategoryId", "Description", "Name", "Price", "Quantity", "Unit" },
                values: new object[] { 2, 1, "LoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsum", "Harry Potter 2", 20m, 20, "Piece" });

            migrationBuilder.CreateIndex(
                name: "IX_Products_CategoryId",
                table: "Products",
                column: "CategoryId");
        }
示例#39
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn <string>(
                name: "Name",
                table: "AspNetUserTokens",
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 128);

            migrationBuilder.AlterColumn <string>(
                name: "LoginProvider",
                table: "AspNetUserTokens",
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 128);

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

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

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

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

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

            migrationBuilder.AlterColumn <string>(
                name: "ProviderKey",
                table: "AspNetUserLogins",
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 128);

            migrationBuilder.AlterColumn <string>(
                name: "LoginProvider",
                table: "AspNetUserLogins",
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 128);

            migrationBuilder.CreateTable(
                name: "Doctor",
                columns: table => new
            {
                Id          = table.Column <string>(nullable: false),
                Gender      = table.Column <string>(nullable: true),
                Speciality  = table.Column <string>(nullable: true),
                Availabilty = table.Column <DateTime>(nullable: false),
                Address     = table.Column <string>(nullable: true),
                About       = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Doctor", x => x.Id);
                table.ForeignKey(
                    name: "FK_Doctor_AspNetUsers_Id",
                    column: x => x.Id,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "InsuranceCompany",
                columns: table => new
            {
                Id      = table.Column <string>(nullable: false),
                Address = table.Column <string>(nullable: true),
                Fax     = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_InsuranceCompany", x => x.Id);
                table.ForeignKey(
                    name: "FK_InsuranceCompany_AspNetUsers_Id",
                    column: x => x.Id,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Assistant",
                columns: table => new
            {
                Id       = table.Column <string>(nullable: false),
                DoctorId = table.Column <string>(nullable: true),
                Gender   = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Assistant", x => x.Id);
                table.ForeignKey(
                    name: "FK_Assistant_Doctor_DoctorId",
                    column: x => x.DoctorId,
                    principalTable: "Doctor",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Assistant_AspNetUsers_Id",
                    column: x => x.Id,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Patient",
                columns: table => new
            {
                Id = table.Column <string>(nullable: false),
                InsuranceCompanyId = table.Column <string>(nullable: true),
                Gender             = table.Column <string>(nullable: true),
                Birthdate          = table.Column <DateTime>(nullable: false),
                Address            = table.Column <string>(nullable: true),
                BloodType          = table.Column <string>(nullable: true),
                Picture            = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Patient", x => x.Id);
                table.ForeignKey(
                    name: "FK_Patient_AspNetUsers_Id",
                    column: x => x.Id,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_Patient_InsuranceCompany_InsuranceCompanyId",
                    column: x => x.InsuranceCompanyId,
                    principalTable: "InsuranceCompany",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Assistant_DoctorId",
                table: "Assistant",
                column: "DoctorId");

            migrationBuilder.CreateIndex(
                name: "IX_Patient_InsuranceCompanyId",
                table: "Patient",
                column: "InsuranceCompanyId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                "Categories",
                table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy",
                            SqlServerValueGenerationStrategy.IdentityColumn),
                    Guid = table.Column<Guid>(nullable: false),
                    Name = table.Column<string>(nullable: true)
                },
                constraints: table => { table.PrimaryKey("PK_Categories", x => x.Id); });

            migrationBuilder.CreateTable(
                "Products",
                table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy",
                            SqlServerValueGenerationStrategy.IdentityColumn),
                    Guid = table.Column<Guid>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Price = table.Column<decimal>(nullable: false),
                    CategoryId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Products", x => x.Id);
                    table.ForeignKey(
                        "FK_Products_Categories_CategoryId",
                        x => x.CategoryId,
                        "Categories",
                        "Id",
                        onDelete: ReferentialAction.NoAction);
                });

            migrationBuilder.CreateTable(
                "Specifications",
                table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy",
                            SqlServerValueGenerationStrategy.IdentityColumn),
                    Guid = table.Column<Guid>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    CategoryId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Specifications", x => x.Id);
                    table.ForeignKey(
                        "FK_Specifications_Categories_CategoryId",
                        x => x.CategoryId,
                        "Categories",
                        "Id",
                        onDelete: ReferentialAction.NoAction);
                });

            migrationBuilder.CreateTable(
                "ProductSpecifications",
                table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy",
                            SqlServerValueGenerationStrategy.IdentityColumn),
                    Guid = table.Column<Guid>(nullable: false),
                    ProductId = table.Column<long>(nullable: false),
                    SpecificationId = table.Column<long>(nullable: false),
                    ValueAsJson = table.Column<string>(nullable: true),
                    TypeOfSerializedJson = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductSpecifications", x => x.Id);
                    table.ForeignKey(
                        "FK_ProductSpecifications_Products_ProductId",
                        x => x.ProductId,
                        "Products",
                        "Id",
                        onDelete: ReferentialAction.NoAction);
                    table.ForeignKey(
                        "FK_ProductSpecifications_Specifications_SpecificationId",
                        x => x.SpecificationId,
                        "Specifications",
                        "Id",
                        onDelete: ReferentialAction.NoAction);
                });

            migrationBuilder.CreateIndex(
                "IX_Products_CategoryId",
                "Products",
                "CategoryId");

            migrationBuilder.CreateIndex(
                "IX_ProductSpecifications_ProductId",
                "ProductSpecifications",
                "ProductId");

            migrationBuilder.CreateIndex(
                "IX_ProductSpecifications_SpecificationId",
                "ProductSpecifications",
                "SpecificationId");

            migrationBuilder.CreateIndex(
                "IX_Specifications_CategoryId",
                "Specifications",
                "CategoryId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Student",
                columns: table => new
            {
                RollNumber = table.Column <string>(nullable: false),
                FirstName  = table.Column <string>(nullable: true),
                LastName   = table.Column <string>(nullable: true),
                Email      = table.Column <string>(nullable: true),
                CreatedAt  = table.Column <DateTime>(nullable: false),
                UpdatedAt  = table.Column <DateTime>(nullable: false),
                Status     = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Student", x => x.RollNumber);
            });

            migrationBuilder.CreateTable(
                name: "Mark",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                SubjectName       = table.Column <string>(nullable: true),
                SubjectMark       = table.Column <int>(nullable: false),
                StudentRollNumber = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Mark", x => x.Id);
                table.ForeignKey(
                    name: "FK_Mark_Student_StudentRollNumber",
                    column: x => x.StudentRollNumber,
                    principalTable: "Student",
                    principalColumn: "RollNumber",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.InsertData(
                table: "Student",
                columns: new[] { "RollNumber", "CreatedAt", "Email", "FirstName", "LastName", "Status", "UpdatedAt" },
                values: new object[] { "A001", new DateTime(2018, 11, 7, 22, 47, 25, 431, DateTimeKind.Local), "*****@*****.**", "Giang", "Tinh", 0, new DateTime(2018, 11, 7, 22, 47, 25, 432, DateTimeKind.Local) });

            migrationBuilder.InsertData(
                table: "Student",
                columns: new[] { "RollNumber", "CreatedAt", "Email", "FirstName", "LastName", "Status", "UpdatedAt" },
                values: new object[] { "A002", new DateTime(2018, 11, 7, 22, 47, 25, 433, DateTimeKind.Local), "*****@*****.**", "Huong", "Ly", 0, new DateTime(2018, 11, 7, 22, 47, 25, 433, DateTimeKind.Local) });

            migrationBuilder.InsertData(
                table: "Student",
                columns: new[] { "RollNumber", "CreatedAt", "Email", "FirstName", "LastName", "Status", "UpdatedAt" },
                values: new object[] { "A003", new DateTime(2018, 11, 7, 22, 47, 25, 433, DateTimeKind.Local), "*****@*****.**", "Thanh", "Tung", 0, new DateTime(2018, 11, 7, 22, 47, 25, 433, DateTimeKind.Local) });

            migrationBuilder.InsertData(
                table: "Mark",
                columns: new[] { "Id", "StudentRollNumber", "SubjectMark", "SubjectName" },
                values: new object[] { 1, "A001", 20, "Java" });

            migrationBuilder.InsertData(
                table: "Mark",
                columns: new[] { "Id", "StudentRollNumber", "SubjectMark", "SubjectName" },
                values: new object[] { 2, "A002", 20, "C#" });

            migrationBuilder.InsertData(
                table: "Mark",
                columns: new[] { "Id", "StudentRollNumber", "SubjectMark", "SubjectName" },
                values: new object[] { 3, "A003", 20, "PHP" });

            migrationBuilder.CreateIndex(
                name: "IX_Mark_StudentRollNumber",
                table: "Mark",
                column: "StudentRollNumber");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TeamMembers",
                columns: table => new
            {
                Id   = table.Column <string>(nullable: false),
                Name = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_TeamMembers", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "IncomingMessages",
                columns: table => new
            {
                Id             = table.Column <string>(nullable: false),
                ChannelId      = table.Column <string>(nullable: true),
                FromId         = table.Column <string>(nullable: true),
                LocalTimestamp = table.Column <DateTime>(type: "date", nullable: false),
                ServiceUrl     = table.Column <string>(nullable: true),
                Text           = table.Column <string>(nullable: true),
                Type           = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_IncomingMessages", x => x.Id);
                table.ForeignKey(
                    name: "FK_IncomingMessages_TeamMembers_FromId",
                    column: x => x.FromId,
                    principalTable: "TeamMembers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Entity",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("Sqlite:Autoincrement", true),
                IncomingMessageId = table.Column <string>(nullable: true),
                MentionedId       = table.Column <string>(nullable: true),
                Text = table.Column <string>(nullable: true),
                Type = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Entity", x => x.Id);
                table.ForeignKey(
                    name: "FK_Entity_IncomingMessages_IncomingMessageId",
                    column: x => x.IncomingMessageId,
                    principalTable: "IncomingMessages",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Entity_TeamMembers_MentionedId",
                    column: x => x.MentionedId,
                    principalTable: "TeamMembers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Punishments",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("Sqlite:Autoincrement", true),
                AuthorId    = table.Column <string>(nullable: true),
                CreatedAt   = table.Column <DateTime>(type: "date", nullable: false),
                FromId      = table.Column <string>(nullable: true),
                Reason      = table.Column <string>(nullable: true),
                RecipientId = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Punishments", x => x.Id);
                table.ForeignKey(
                    name: "FK_Punishments_TeamMembers_AuthorId",
                    column: x => x.AuthorId,
                    principalTable: "TeamMembers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Punishments_IncomingMessages_FromId",
                    column: x => x.FromId,
                    principalTable: "IncomingMessages",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Punishments_TeamMembers_RecipientId",
                    column: x => x.RecipientId,
                    principalTable: "TeamMembers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Entity_IncomingMessageId",
                table: "Entity",
                column: "IncomingMessageId");

            migrationBuilder.CreateIndex(
                name: "IX_Entity_MentionedId",
                table: "Entity",
                column: "MentionedId");

            migrationBuilder.CreateIndex(
                name: "IX_IncomingMessages_FromId",
                table: "IncomingMessages",
                column: "FromId");

            migrationBuilder.CreateIndex(
                name: "IX_Punishments_AuthorId",
                table: "Punishments",
                column: "AuthorId");

            migrationBuilder.CreateIndex(
                name: "IX_Punishments_FromId",
                table: "Punishments",
                column: "FromId");

            migrationBuilder.CreateIndex(
                name: "IX_Punishments_RecipientId",
                table: "Punishments",
                column: "RecipientId");
        }
示例#43
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.EnsureSchema(
                name: "Store");

            migrationBuilder.CreateTable(
                name: "Categories",
                schema: "Store",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                TimeStamp    = table.Column <byte[]>(rowVersion: true, nullable: true),
                CategoryName = table.Column <string>(maxLength: 50, nullable: true)
            },
                constraints: table => { table.PrimaryKey("PK_Categories", x => x.Id); });

            migrationBuilder.CreateTable(
                name: "Customers",
                schema: "Store",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                TimeStamp    = table.Column <byte[]>(rowVersion: true, nullable: true),
                FullName     = table.Column <string>(maxLength: 50, nullable: true),
                EmailAddress = table.Column <string>(maxLength: 50, nullable: false),
                Password     = table.Column <string>(maxLength: 50, nullable: false)
            },
                constraints: table => { table.PrimaryKey("PK_Customers", x => x.Id); });

            migrationBuilder.CreateTable(
                name: "Products",
                schema: "Store",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                TimeStamp         = table.Column <byte[]>(rowVersion: true, nullable: true),
                Description       = table.Column <string>(maxLength: 3800, nullable: true),
                ModelNumber       = table.Column <string>(maxLength: 50, nullable: true),
                ModelName         = table.Column <string>(maxLength: 50, nullable: true),
                ProductImage      = table.Column <string>(maxLength: 150, nullable: true),
                ProductImageLarge = table.Column <string>(maxLength: 150, nullable: true),
                ProductImageThumb = table.Column <string>(maxLength: 150, nullable: true),
                IsFeatured        = table.Column <bool>(nullable: false),
                UnitCost          = table.Column <decimal>(type: "money", nullable: false),
                CurrentPrice      = table.Column <decimal>(type: "money", nullable: false),
                UnitsInStock      = table.Column <int>(nullable: false),
                CategoryId        = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Products", x => x.Id);
                table.ForeignKey(
                    name: "FK_Products_Categories_CategoryId",
                    column: x => x.CategoryId,
                    principalSchema: "Store",
                    principalTable: "Categories",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Orders",
                schema: "Store",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                TimeStamp  = table.Column <byte[]>(rowVersion: true, nullable: true),
                OrderDate  = table.Column <DateTime>(type: "datetime", nullable: false, defaultValueSql: "getdate()"),
                ShipDate   = table.Column <DateTime>(type: "datetime", nullable: false, defaultValueSql: "getdate()"),
                CustomerId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Orders", x => x.Id);
                table.ForeignKey(
                    name: "FK_Orders_Customers_CustomerId",
                    column: x => x.CustomerId,
                    principalSchema: "Store",
                    principalTable: "Customers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ShoppingCartRecords",
                schema: "Store",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                TimeStamp   = table.Column <byte[]>(rowVersion: true, nullable: true),
                DateCreated =
                    table.Column <DateTime>(type: "datetime", nullable: true, defaultValueSql: "getdate()"),
                CustomerId    = table.Column <int>(nullable: false),
                Quantity      = table.Column <int>(nullable: false, defaultValue: 1),
                LineItemTotal = table.Column <decimal>(nullable: false),
                ProductId     = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ShoppingCartRecords", x => x.Id);
                table.ForeignKey(
                    name: "FK_ShoppingCartRecords_Customers_CustomerId",
                    column: x => x.CustomerId,
                    principalSchema: "Store",
                    principalTable: "Customers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ShoppingCartRecords_Products_ProductId",
                    column: x => x.ProductId,
                    principalSchema: "Store",
                    principalTable: "Products",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "OrderDetails",
                schema: "Store",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                TimeStamp = table.Column <byte[]>(rowVersion: true, nullable: true),
                OrderId   = table.Column <int>(nullable: false),
                ProductId = table.Column <int>(nullable: false),
                Quantity  = table.Column <int>(nullable: false),
                UnitCost  = table.Column <decimal>(type: "money", nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_OrderDetails", x => x.Id);
                table.ForeignKey(
                    name: "FK_OrderDetails_Orders_OrderId",
                    column: x => x.OrderId,
                    principalSchema: "Store",
                    principalTable: "Orders",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_OrderDetails_Products_ProductId",
                    column: x => x.ProductId,
                    principalSchema: "Store",
                    principalTable: "Products",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Customers",
                schema: "Store",
                table: "Customers",
                column: "EmailAddress",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_OrderDetails_OrderId",
                schema: "Store",
                table: "OrderDetails",
                column: "OrderId");

            migrationBuilder.CreateIndex(
                name: "IX_OrderDetails_ProductId",
                schema: "Store",
                table: "OrderDetails",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_Orders_CustomerId",
                schema: "Store",
                table: "Orders",
                column: "CustomerId");

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

            migrationBuilder.CreateIndex(
                name: "IX_ShoppingCartRecords_CustomerId",
                schema: "Store",
                table: "ShoppingCartRecords",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_ShoppingCartRecords_ProductId",
                schema: "Store",
                table: "ShoppingCartRecords",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_ShoppingCart",
                schema: "Store",
                table: "ShoppingCartRecords",
                columns: new[] { "Id", "ProductId", "CustomerId" },
                unique: true);
        }
示例#44
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AspNetRoles",
                columns: table => new
            {
                Id = table.Column <string>(nullable: false),
                ConcurrencyStamp = table.Column <string>(nullable: true),
                Name             = table.Column <string>(maxLength: 256, nullable: true),
                NormalizedName   = table.Column <string>(maxLength: 256, nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetRoles", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUserTokens",
                columns: table => new
            {
                UserId        = table.Column <string>(nullable: false),
                LoginProvider = table.Column <string>(nullable: false),
                Name          = table.Column <string>(nullable: false),
                Value         = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
            });

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

            migrationBuilder.CreateTable(
                name: "AspNetRoleClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ClaimType  = table.Column <string>(nullable: true),
                ClaimValue = table.Column <string>(nullable: true),
                RoleId     = table.Column <string>(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>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ClaimType  = table.Column <string>(nullable: true),
                ClaimValue = table.Column <string>(nullable: true),
                UserId     = table.Column <string>(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>(nullable: false),
                ProviderKey         = table.Column <string>(nullable: false),
                ProviderDisplayName = table.Column <string>(nullable: true),
                UserId = table.Column <string>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
                table.ForeignKey(
                    name: "FK_AspNetUserLogins_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

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

            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles",
                column: "NormalizedName");

            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.CreateIndex(
                name: "IX_AspNetUserRoles_UserId",
                table: "AspNetUserRoles",
                column: "UserId");

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

            migrationBuilder.CreateIndex(
                name: "UserNameIndex",
                table: "AspNetUsers",
                column: "NormalizedUserName",
                unique: true);
        }
示例#45
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "CommonJourneyItem");

            migrationBuilder.CreateTable(
                name: "EventItems",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Date      = table.Column <DateTime>(nullable: false),
                UserId    = table.Column <string>(nullable: true),
                JourneyId = table.Column <int>(nullable: false),
                Name      = table.Column <string>(nullable: true),
                Address   = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_EventItems", x => x.Id);
                table.ForeignKey(
                    name: "FK_EventItems_Journeys_JourneyId",
                    column: x => x.JourneyId,
                    principalTable: "Journeys",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_EventItems_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "HotelItems",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Date      = table.Column <DateTime>(nullable: false),
                UserId    = table.Column <string>(nullable: true),
                JourneyId = table.Column <int>(nullable: false),
                Name      = table.Column <string>(nullable: true),
                Address   = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_HotelItems", x => x.Id);
                table.ForeignKey(
                    name: "FK_HotelItems_Journeys_JourneyId",
                    column: x => x.JourneyId,
                    principalTable: "Journeys",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_HotelItems_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "ReservationItems",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Date      = table.Column <DateTime>(nullable: false),
                UserId    = table.Column <string>(nullable: true),
                JourneyId = table.Column <int>(nullable: false),
                Name      = table.Column <string>(nullable: true),
                Address   = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ReservationItems", x => x.Id);
                table.ForeignKey(
                    name: "FK_ReservationItems_Journeys_JourneyId",
                    column: x => x.JourneyId,
                    principalTable: "Journeys",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ReservationItems_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateIndex(
                name: "IX_EventItems_JourneyId",
                table: "EventItems",
                column: "JourneyId");

            migrationBuilder.CreateIndex(
                name: "IX_EventItems_UserId",
                table: "EventItems",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_HotelItems_JourneyId",
                table: "HotelItems",
                column: "JourneyId");

            migrationBuilder.CreateIndex(
                name: "IX_HotelItems_UserId",
                table: "HotelItems",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_ReservationItems_JourneyId",
                table: "ReservationItems",
                column: "JourneyId");

            migrationBuilder.CreateIndex(
                name: "IX_ReservationItems_UserId",
                table: "ReservationItems",
                column: "UserId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Categories",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                ParentCategoryId = table.Column <int>(nullable: true),
                Name             = table.Column <string>(maxLength: 100, nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Categories", x => x.Id);
                table.ForeignKey(
                    name: "FK_Categories_Categories_ParentCategoryId",
                    column: x => x.ParentCategoryId,
                    principalTable: "Categories",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "CategoryBundle",
                columns: table => new
            {
                CategoryId = table.Column <int>(nullable: false),
                IsRequired = table.Column <bool>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_CategoryBundle", x => x.CategoryId);
                table.ForeignKey(
                    name: "FK_CategoryBundle_Categories_CategoryId",
                    column: x => x.CategoryId,
                    principalTable: "Categories",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Products",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Name        = table.Column <string>(maxLength: 150, nullable: false),
                Description = table.Column <string>(maxLength: 2000, nullable: false),
                ImagePath   = table.Column <string>(nullable: false),
                Price       = table.Column <decimal>(type: "decimal(18, 2)", nullable: false),
                CategoryId  = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Products", x => x.Id);
                table.ForeignKey(
                    name: "FK_Products_Categories_CategoryId",
                    column: x => x.CategoryId,
                    principalTable: "Categories",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Categories_ParentCategoryId",
                table: "Categories",
                column: "ParentCategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_Products_CategoryId",
                table: "Products",
                column: "CategoryId");
        }
示例#47
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AspNetRoles",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("Sqlite:Autoincrement", true),
                Name             = table.Column <string>(maxLength: 256, nullable: true),
                NormalizedName   = table.Column <string>(maxLength: 256, nullable: true),
                ConcurrencyStamp = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetRoles", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUsers",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("Sqlite:Autoincrement", true),
                UserName           = table.Column <string>(maxLength: 256, nullable: true),
                NormalizedUserName = table.Column <string>(maxLength: 256, nullable: true),
                Email                = table.Column <string>(maxLength: 256, nullable: true),
                NormalizedEmail      = table.Column <string>(maxLength: 256, nullable: true),
                EmailConfirmed       = table.Column <bool>(nullable: false),
                PasswordHash         = table.Column <string>(nullable: true),
                SecurityStamp        = table.Column <string>(nullable: true),
                ConcurrencyStamp     = table.Column <string>(nullable: true),
                PhoneNumber          = table.Column <string>(nullable: true),
                PhoneNumberConfirmed = table.Column <bool>(nullable: false),
                TwoFactorEnabled     = table.Column <bool>(nullable: false),
                LockoutEnd           = table.Column <DateTimeOffset>(nullable: true),
                LockoutEnabled       = table.Column <bool>(nullable: false),
                AccessFailedCount    = table.Column <int>(nullable: false),
                gender               = table.Column <string>(nullable: true),
                DateOfBirth          = table.Column <DateTime>(nullable: false),
                KnownAs              = table.Column <string>(nullable: true),
                Created              = table.Column <DateTime>(nullable: false),
                LastActive           = table.Column <DateTime>(nullable: false),
                Introduction         = table.Column <string>(nullable: true),
                LookingFor           = table.Column <string>(nullable: true),
                Interest             = table.Column <string>(nullable: true),
                City    = table.Column <string>(nullable: true),
                Country = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUsers", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Values",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("Sqlite:Autoincrement", true),
                Name = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Values", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "AspNetRoleClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("Sqlite:Autoincrement", true),
                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_AspNetRoles_RoleId",
                    column: x => x.RoleId,
                    principalTable: "AspNetRoles",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUserClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("Sqlite:Autoincrement", true),
                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_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AspNetUserLogins",
                columns: table => new
            {
                LoginProvider       = table.Column <string>(nullable: false),
                ProviderKey         = table.Column <string>(nullable: false),
                ProviderDisplayName = table.Column <string>(nullable: true),
                UserId = table.Column <int>(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 <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_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 <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_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Likes",
                columns: table => new
            {
                LikerId = table.Column <int>(nullable: false),
                LikeeId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Likes", x => new { x.LikeeId, x.LikerId });
                table.ForeignKey(
                    name: "FK_Likes_AspNetUsers_LikeeId",
                    column: x => x.LikeeId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Likes_AspNetUsers_LikerId",
                    column: x => x.LikerId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Messages",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("Sqlite:Autoincrement", true),
                SenderId        = table.Column <int>(nullable: false),
                RecipientId     = table.Column <int>(nullable: false),
                Content         = table.Column <string>(nullable: true),
                isRead          = table.Column <bool>(nullable: false),
                dateRead        = table.Column <DateTime>(nullable: true),
                DateSent        = table.Column <DateTime>(nullable: false),
                senderDelete    = table.Column <bool>(nullable: false),
                recipientDelete = table.Column <bool>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Messages", x => x.Id);
                table.ForeignKey(
                    name: "FK_Messages_AspNetUsers_RecipientId",
                    column: x => x.RecipientId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Messages_AspNetUsers_SenderId",
                    column: x => x.SenderId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Photos",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("Sqlite:Autoincrement", true),
                Url         = table.Column <string>(nullable: true),
                Description = table.Column <string>(nullable: true),
                DateAdded   = table.Column <DateTime>(nullable: false),
                isMain      = table.Column <bool>(nullable: false),
                PublicId    = table.Column <string>(nullable: true),
                UserId      = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Photos", x => x.Id);
                table.ForeignKey(
                    name: "FK_Photos_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

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

            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles",
                column: "NormalizedName",
                unique: true);

            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);

            migrationBuilder.CreateIndex(
                name: "IX_Likes_LikerId",
                table: "Likes",
                column: "LikerId");

            migrationBuilder.CreateIndex(
                name: "IX_Messages_RecipientId",
                table: "Messages",
                column: "RecipientId");

            migrationBuilder.CreateIndex(
                name: "IX_Messages_SenderId",
                table: "Messages",
                column: "SenderId");

            migrationBuilder.CreateIndex(
                name: "IX_Photos_UserId",
                table: "Photos",
                column: "UserId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Categories",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                CreatedAt = table.Column <DateTime>(nullable: true),
                DeletedAt = table.Column <DateTime>(nullable: true),
                IsMenu    = table.Column <bool>(nullable: false),
                Name      = table.Column <string>(maxLength: 200, nullable: false),
                Slug      = table.Column <string>(maxLength: 200, nullable: false),
                UpdatedAt = table.Column <DateTime>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Categories", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "CrawlLinks",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                BaseLink   = table.Column <string>(nullable: true),
                CreatedAt  = table.Column <DateTime>(nullable: true),
                DeletedAt  = table.Column <DateTime>(nullable: true),
                Finished   = table.Column <int>(nullable: true),
                FromPage   = table.Column <int>(nullable: true),
                IsCircle   = table.Column <bool>(nullable: false),
                IsFinished = table.Column <bool>(nullable: false),
                ToPage     = table.Column <int>(nullable: true),
                UpdatedAt  = table.Column <DateTime>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_CrawlLinks", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "ImageServers",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                CreatedAt  = table.Column <DateTime>(nullable: true),
                DeletedAt  = table.Column <DateTime>(nullable: true),
                Password   = table.Column <string>(maxLength: 50, nullable: false),
                Patch      = table.Column <string>(maxLength: 50, nullable: false),
                Port       = table.Column <int>(nullable: false),
                ServerFtp  = table.Column <string>(maxLength: 50, nullable: false),
                ServerName = table.Column <string>(maxLength: 50, nullable: false),
                ServerUrl  = table.Column <string>(maxLength: 50, nullable: false),
                UpdatedAt  = table.Column <DateTime>(nullable: true),
                UserName   = table.Column <string>(maxLength: 50, nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ImageServers", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Tags",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                CreatedAt = table.Column <DateTime>(nullable: true),
                DeletedAt = table.Column <DateTime>(nullable: true),
                Name      = table.Column <string>(maxLength: 50, nullable: false),
                Slug      = table.Column <string>(maxLength: 50, nullable: false),
                UpdatedAt = table.Column <DateTime>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Tags", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Matchs",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                CategoryId    = table.Column <int>(nullable: true),
                CreatedAt     = table.Column <DateTime>(nullable: true),
                DeletedAt     = table.Column <DateTime>(nullable: true),
                ImageName     = table.Column <string>(nullable: true),
                ImageServerId = table.Column <int>(nullable: true),
                MatchDate     = table.Column <DateTime>(nullable: false),
                Slug          = table.Column <string>(maxLength: 500, nullable: false),
                Title         = table.Column <string>(maxLength: 500, nullable: false),
                UpdatedAt     = table.Column <DateTime>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Matchs", x => x.Id);
                table.ForeignKey(
                    name: "FK_Matchs_Categories_CategoryId",
                    column: x => x.CategoryId,
                    principalTable: "Categories",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_Matchs_ImageServers_ImageServerId",
                    column: x => x.ImageServerId,
                    principalTable: "ImageServers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Clips",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                ClipType  = table.Column <int>(nullable: true),
                CreatedAt = table.Column <DateTime>(nullable: true),
                DeletedAt = table.Column <DateTime>(nullable: true),
                LinkType  = table.Column <int>(nullable: true),
                MatchId   = table.Column <int>(nullable: true),
                Name      = table.Column <string>(maxLength: 50, nullable: false),
                UpdatedAt = table.Column <DateTime>(nullable: true),
                Url       = table.Column <string>(maxLength: 1000, nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Clips", x => x.Id);
                table.ForeignKey(
                    name: "FK_Clips_Matchs_MatchId",
                    column: x => x.MatchId,
                    principalTable: "Matchs",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "Formations",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                CreatedAt = table.Column <DateTime>(nullable: true),
                DeletedAt = table.Column <DateTime>(nullable: true),
                MatchId   = table.Column <int>(nullable: true),
                Name      = table.Column <string>(nullable: true),
                Number    = table.Column <int>(nullable: true),
                UpdatedAt = table.Column <DateTime>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Formations", x => x.Id);
                table.ForeignKey(
                    name: "FK_Formations_Matchs_MatchId",
                    column: x => x.MatchId,
                    principalTable: "Matchs",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateTable(
                name: "TagAssignments",
                columns: table => new
            {
                MatchId = table.Column <int>(nullable: false),
                TagId   = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_TagAssignments", x => new { x.MatchId, x.TagId });
                table.ForeignKey(
                    name: "FK_TagAssignments_Matchs_MatchId",
                    column: x => x.MatchId,
                    principalTable: "Matchs",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_TagAssignments_Tags_TagId",
                    column: x => x.TagId,
                    principalTable: "Tags",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Substitutions",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                CreatedAt   = table.Column <DateTime>(nullable: true),
                DeletedAt   = table.Column <DateTime>(nullable: true),
                FormationId = table.Column <int>(nullable: true),
                Minutes     = table.Column <int>(nullable: true),
                Name        = table.Column <string>(nullable: true),
                Number      = table.Column <int>(nullable: true),
                UpdatedAt   = table.Column <DateTime>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Substitutions", x => x.Id);
                table.ForeignKey(
                    name: "FK_Substitutions_Formations_FormationId",
                    column: x => x.FormationId,
                    principalTable: "Formations",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Clips_MatchId",
                table: "Clips",
                column: "MatchId");

            migrationBuilder.CreateIndex(
                name: "IX_Formations_MatchId",
                table: "Formations",
                column: "MatchId");

            migrationBuilder.CreateIndex(
                name: "IX_Matchs_CategoryId",
                table: "Matchs",
                column: "CategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_Matchs_ImageServerId",
                table: "Matchs",
                column: "ImageServerId");

            migrationBuilder.CreateIndex(
                name: "IX_Substitutions_FormationId",
                table: "Substitutions",
                column: "FormationId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_TagAssignments_TagId",
                table: "TagAssignments",
                column: "TagId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ApiResources",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Enabled      = table.Column <bool>(nullable: false),
                Name         = table.Column <string>(maxLength: 200, nullable: false),
                DisplayName  = table.Column <string>(maxLength: 200, nullable: true),
                Description  = table.Column <string>(maxLength: 1000, nullable: true),
                Created      = table.Column <DateTime>(nullable: false),
                Updated      = table.Column <DateTime>(nullable: true),
                LastAccessed = table.Column <DateTime>(nullable: true),
                NonEditable  = table.Column <bool>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ApiResources", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Clients",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Enabled                           = table.Column <bool>(nullable: false),
                ClientId                          = table.Column <string>(maxLength: 200, nullable: false),
                ProtocolType                      = table.Column <string>(maxLength: 200, nullable: false),
                RequireClientSecret               = table.Column <bool>(nullable: false),
                ClientName                        = table.Column <string>(maxLength: 200, nullable: true),
                Description                       = table.Column <string>(maxLength: 1000, nullable: true),
                ClientUri                         = table.Column <string>(maxLength: 2000, nullable: true),
                LogoUri                           = table.Column <string>(maxLength: 2000, nullable: true),
                RequireConsent                    = table.Column <bool>(nullable: false),
                AllowRememberConsent              = table.Column <bool>(nullable: false),
                AlwaysIncludeUserClaimsInIdToken  = table.Column <bool>(nullable: false),
                RequirePkce                       = table.Column <bool>(nullable: false),
                AllowPlainTextPkce                = table.Column <bool>(nullable: false),
                AllowAccessTokensViaBrowser       = table.Column <bool>(nullable: false),
                FrontChannelLogoutUri             = table.Column <string>(maxLength: 2000, nullable: true),
                FrontChannelLogoutSessionRequired = table.Column <bool>(nullable: false),
                BackChannelLogoutUri              = table.Column <string>(maxLength: 2000, nullable: true),
                BackChannelLogoutSessionRequired  = table.Column <bool>(nullable: false),
                AllowOfflineAccess                = table.Column <bool>(nullable: false),
                IdentityTokenLifetime             = table.Column <int>(nullable: false),
                AccessTokenLifetime               = table.Column <int>(nullable: false),
                AuthorizationCodeLifetime         = table.Column <int>(nullable: false),
                ConsentLifetime                   = table.Column <int>(nullable: true),
                AbsoluteRefreshTokenLifetime      = table.Column <int>(nullable: false),
                SlidingRefreshTokenLifetime       = table.Column <int>(nullable: false),
                RefreshTokenUsage                 = table.Column <int>(nullable: false),
                UpdateAccessTokenClaimsOnRefresh  = table.Column <bool>(nullable: false),
                RefreshTokenExpiration            = table.Column <int>(nullable: false),
                AccessTokenType                   = table.Column <int>(nullable: false),
                EnableLocalLogin                  = table.Column <bool>(nullable: false),
                IncludeJwtId                      = table.Column <bool>(nullable: false),
                AlwaysSendClientClaims            = table.Column <bool>(nullable: false),
                ClientClaimsPrefix                = table.Column <string>(maxLength: 200, nullable: true),
                PairWiseSubjectSalt               = table.Column <string>(maxLength: 200, nullable: true),
                Created                           = table.Column <DateTime>(nullable: false),
                Updated                           = table.Column <DateTime>(nullable: true),
                LastAccessed                      = table.Column <DateTime>(nullable: true),
                UserSsoLifetime                   = table.Column <int>(nullable: true),
                UserCodeType                      = table.Column <string>(maxLength: 100, nullable: true),
                DeviceCodeLifetime                = table.Column <int>(nullable: false),
                NonEditable                       = table.Column <bool>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Clients", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "IdentityResources",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Enabled                 = table.Column <bool>(nullable: false),
                Name                    = table.Column <string>(maxLength: 200, nullable: false),
                DisplayName             = table.Column <string>(maxLength: 200, nullable: true),
                Description             = table.Column <string>(maxLength: 1000, nullable: true),
                Required                = table.Column <bool>(nullable: false),
                Emphasize               = table.Column <bool>(nullable: false),
                ShowInDiscoveryDocument = table.Column <bool>(nullable: false),
                Created                 = table.Column <DateTime>(nullable: false),
                Updated                 = table.Column <DateTime>(nullable: true),
                NonEditable             = table.Column <bool>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_IdentityResources", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "ApiClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Type          = table.Column <string>(maxLength: 200, nullable: false),
                ApiResourceId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ApiClaims", x => x.Id);
                table.ForeignKey(
                    name: "FK_ApiClaims_ApiResources_ApiResourceId",
                    column: x => x.ApiResourceId,
                    principalTable: "ApiResources",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ApiProperties",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Key           = table.Column <string>(maxLength: 250, nullable: false),
                Value         = table.Column <string>(maxLength: 2000, nullable: false),
                ApiResourceId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ApiProperties", x => x.Id);
                table.ForeignKey(
                    name: "FK_ApiProperties_ApiResources_ApiResourceId",
                    column: x => x.ApiResourceId,
                    principalTable: "ApiResources",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ApiScopes",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name                    = table.Column <string>(maxLength: 200, nullable: false),
                DisplayName             = table.Column <string>(maxLength: 200, nullable: true),
                Description             = table.Column <string>(maxLength: 1000, nullable: true),
                Required                = table.Column <bool>(nullable: false),
                Emphasize               = table.Column <bool>(nullable: false),
                ShowInDiscoveryDocument = table.Column <bool>(nullable: false),
                ApiResourceId           = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ApiScopes", x => x.Id);
                table.ForeignKey(
                    name: "FK_ApiScopes_ApiResources_ApiResourceId",
                    column: x => x.ApiResourceId,
                    principalTable: "ApiResources",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ApiSecrets",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Description   = table.Column <string>(maxLength: 1000, nullable: true),
                Value         = table.Column <string>(maxLength: 4000, nullable: false),
                Expiration    = table.Column <DateTime>(nullable: true),
                Type          = table.Column <string>(maxLength: 250, nullable: false),
                Created       = table.Column <DateTime>(nullable: false),
                ApiResourceId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ApiSecrets", x => x.Id);
                table.ForeignKey(
                    name: "FK_ApiSecrets_ApiResources_ApiResourceId",
                    column: x => x.ApiResourceId,
                    principalTable: "ApiResources",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ClientClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Type     = table.Column <string>(maxLength: 250, nullable: false),
                Value    = table.Column <string>(maxLength: 250, nullable: false),
                ClientId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ClientClaims", x => x.Id);
                table.ForeignKey(
                    name: "FK_ClientClaims_Clients_ClientId",
                    column: x => x.ClientId,
                    principalTable: "Clients",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ClientCorsOrigins",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Origin   = table.Column <string>(maxLength: 150, nullable: false),
                ClientId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ClientCorsOrigins", x => x.Id);
                table.ForeignKey(
                    name: "FK_ClientCorsOrigins_Clients_ClientId",
                    column: x => x.ClientId,
                    principalTable: "Clients",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ClientGrantTypes",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                GrantType = table.Column <string>(maxLength: 250, nullable: false),
                ClientId  = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ClientGrantTypes", x => x.Id);
                table.ForeignKey(
                    name: "FK_ClientGrantTypes_Clients_ClientId",
                    column: x => x.ClientId,
                    principalTable: "Clients",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ClientIdPRestrictions",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Provider = table.Column <string>(maxLength: 200, nullable: false),
                ClientId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ClientIdPRestrictions", x => x.Id);
                table.ForeignKey(
                    name: "FK_ClientIdPRestrictions_Clients_ClientId",
                    column: x => x.ClientId,
                    principalTable: "Clients",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ClientPostLogoutRedirectUris",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                PostLogoutRedirectUri = table.Column <string>(maxLength: 2000, nullable: false),
                ClientId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ClientPostLogoutRedirectUris", x => x.Id);
                table.ForeignKey(
                    name: "FK_ClientPostLogoutRedirectUris_Clients_ClientId",
                    column: x => x.ClientId,
                    principalTable: "Clients",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ClientProperties",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Key      = table.Column <string>(maxLength: 250, nullable: false),
                Value    = table.Column <string>(maxLength: 2000, nullable: false),
                ClientId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ClientProperties", x => x.Id);
                table.ForeignKey(
                    name: "FK_ClientProperties_Clients_ClientId",
                    column: x => x.ClientId,
                    principalTable: "Clients",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ClientRedirectUris",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                RedirectUri = table.Column <string>(maxLength: 2000, nullable: false),
                ClientId    = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ClientRedirectUris", x => x.Id);
                table.ForeignKey(
                    name: "FK_ClientRedirectUris_Clients_ClientId",
                    column: x => x.ClientId,
                    principalTable: "Clients",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ClientScopes",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Scope    = table.Column <string>(maxLength: 200, nullable: false),
                ClientId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ClientScopes", x => x.Id);
                table.ForeignKey(
                    name: "FK_ClientScopes_Clients_ClientId",
                    column: x => x.ClientId,
                    principalTable: "Clients",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ClientSecrets",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Description = table.Column <string>(maxLength: 2000, nullable: true),
                Value       = table.Column <string>(maxLength: 4000, nullable: false),
                Expiration  = table.Column <DateTime>(nullable: true),
                Type        = table.Column <string>(maxLength: 250, nullable: false),
                Created     = table.Column <DateTime>(nullable: false),
                ClientId    = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ClientSecrets", x => x.Id);
                table.ForeignKey(
                    name: "FK_ClientSecrets_Clients_ClientId",
                    column: x => x.ClientId,
                    principalTable: "Clients",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "IdentityClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Type = table.Column <string>(maxLength: 200, nullable: false),
                IdentityResourceId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_IdentityClaims", x => x.Id);
                table.ForeignKey(
                    name: "FK_IdentityClaims_IdentityResources_IdentityResourceId",
                    column: x => x.IdentityResourceId,
                    principalTable: "IdentityResources",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "IdentityProperties",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Key   = table.Column <string>(maxLength: 250, nullable: false),
                Value = table.Column <string>(maxLength: 2000, nullable: false),
                IdentityResourceId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_IdentityProperties", x => x.Id);
                table.ForeignKey(
                    name: "FK_IdentityProperties_IdentityResources_IdentityResourceId",
                    column: x => x.IdentityResourceId,
                    principalTable: "IdentityResources",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ApiScopeClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Type       = table.Column <string>(maxLength: 200, nullable: false),
                ApiScopeId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ApiScopeClaims", x => x.Id);
                table.ForeignKey(
                    name: "FK_ApiScopeClaims_ApiScopes_ApiScopeId",
                    column: x => x.ApiScopeId,
                    principalTable: "ApiScopes",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_ApiClaims_ApiResourceId",
                table: "ApiClaims",
                column: "ApiResourceId");

            migrationBuilder.CreateIndex(
                name: "IX_ApiProperties_ApiResourceId",
                table: "ApiProperties",
                column: "ApiResourceId");

            migrationBuilder.CreateIndex(
                name: "IX_ApiResources_Name",
                table: "ApiResources",
                column: "Name",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_ApiScopeClaims_ApiScopeId",
                table: "ApiScopeClaims",
                column: "ApiScopeId");

            migrationBuilder.CreateIndex(
                name: "IX_ApiScopes_ApiResourceId",
                table: "ApiScopes",
                column: "ApiResourceId");

            migrationBuilder.CreateIndex(
                name: "IX_ApiScopes_Name",
                table: "ApiScopes",
                column: "Name",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_ApiSecrets_ApiResourceId",
                table: "ApiSecrets",
                column: "ApiResourceId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientClaims_ClientId",
                table: "ClientClaims",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientCorsOrigins_ClientId",
                table: "ClientCorsOrigins",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientGrantTypes_ClientId",
                table: "ClientGrantTypes",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientIdPRestrictions_ClientId",
                table: "ClientIdPRestrictions",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientPostLogoutRedirectUris_ClientId",
                table: "ClientPostLogoutRedirectUris",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientProperties_ClientId",
                table: "ClientProperties",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientRedirectUris_ClientId",
                table: "ClientRedirectUris",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_Clients_ClientId",
                table: "Clients",
                column: "ClientId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_ClientScopes_ClientId",
                table: "ClientScopes",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientSecrets_ClientId",
                table: "ClientSecrets",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_IdentityClaims_IdentityResourceId",
                table: "IdentityClaims",
                column: "IdentityResourceId");

            migrationBuilder.CreateIndex(
                name: "IX_IdentityProperties_IdentityResourceId",
                table: "IdentityProperties",
                column: "IdentityResourceId");

            migrationBuilder.CreateIndex(
                name: "IX_IdentityResources_Name",
                table: "IdentityResources",
                column: "Name",
                unique: true);
        }
示例#50
0
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_IdentityUser_Locations_LocationId",
                table: "IdentityUser");

            migrationBuilder.DropForeignKey(
                name: "FK_Invoices_IdentityUser_CreatorId",
                table: "Invoices");

            migrationBuilder.DropForeignKey(
                name: "FK_Invoices_IdentityUser_UpdaterId",
                table: "Invoices");

            migrationBuilder.DropForeignKey(
                name: "FK_Purchases_IdentityUser_CreatorId",
                table: "Purchases");

            migrationBuilder.DropForeignKey(
                name: "FK_Purchases_IdentityUser_UpdaterId",
                table: "Purchases");

            migrationBuilder.DropForeignKey(
                name: "FK_Sales_IdentityUser_CreatorId",
                table: "Sales");

            migrationBuilder.DropForeignKey(
                name: "FK_Sales_IdentityUser_UpdaterId",
                table: "Sales");

            migrationBuilder.DropForeignKey(
                name: "FK_Supplies_IdentityUser_CreatorId",
                table: "Supplies");

            migrationBuilder.DropForeignKey(
                name: "FK_Supplies_IdentityUser_UpdaterId",
                table: "Supplies");

            migrationBuilder.DropForeignKey(
                name: "FK_Transfers_IdentityUser_CreatorId",
                table: "Transfers");

            migrationBuilder.DropForeignKey(
                name: "FK_Transfers_IdentityUser_UpdaterId",
                table: "Transfers");

            migrationBuilder.DropPrimaryKey(
                name: "PK_IdentityUser",
                table: "IdentityUser");

            migrationBuilder.RenameTable(
                name: "IdentityUser",
                newName: "AspNetUsers");

            migrationBuilder.RenameIndex(
                name: "IX_IdentityUser_LocationId",
                table: "AspNetUsers",
                newName: "IX_AspNetUsers_LocationId");

            migrationBuilder.AlterColumn <string>(
                name: "UserName",
                table: "AspNetUsers",
                maxLength: 256,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "NormalizedUserName",
                table: "AspNetUsers",
                maxLength: 256,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "NormalizedEmail",
                table: "AspNetUsers",
                maxLength: 256,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "Email",
                table: "AspNetUsers",
                maxLength: 256,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_AspNetUsers",
                table: "AspNetUsers",
                column: "Id");

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

            migrationBuilder.CreateTable(
                name: "AspNetUserClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ClaimType  = table.Column <string>(nullable: true),
                ClaimValue = table.Column <string>(nullable: true),
                UserId     = table.Column <string>(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>(maxLength: 128, nullable: false),
                ProviderKey         = table.Column <string>(maxLength: 128, nullable: false),
                ProviderDisplayName = table.Column <string>(nullable: true),
                UserId = table.Column <string>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
                table.ForeignKey(
                    name: "FK_AspNetUserLogins_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

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

            migrationBuilder.CreateTable(
                name: "AspNetRoleClaims",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ClaimType  = table.Column <string>(nullable: true),
                ClaimValue = table.Column <string>(nullable: true),
                RoleId     = table.Column <string>(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: "AspNetUserRoles",
                columns: table => new
            {
                UserId = table.Column <string>(nullable: false),
                RoleId = table.Column <string>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
                table.ForeignKey(
                    name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
                    column: x => x.RoleId,
                    principalTable: "AspNetRoles",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AspNetUserRoles_AspNetUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AspNetUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.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_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.AddForeignKey(
                name: "FK_AspNetUsers_Locations_LocationId",
                table: "AspNetUsers",
                column: "LocationId",
                principalTable: "Locations",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Invoices_AspNetUsers_CreatorId",
                table: "Invoices",
                column: "CreatorId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Invoices_AspNetUsers_UpdaterId",
                table: "Invoices",
                column: "UpdaterId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Purchases_AspNetUsers_CreatorId",
                table: "Purchases",
                column: "CreatorId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Purchases_AspNetUsers_UpdaterId",
                table: "Purchases",
                column: "UpdaterId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Sales_AspNetUsers_CreatorId",
                table: "Sales",
                column: "CreatorId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Sales_AspNetUsers_UpdaterId",
                table: "Sales",
                column: "UpdaterId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Supplies_AspNetUsers_CreatorId",
                table: "Supplies",
                column: "CreatorId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Supplies_AspNetUsers_UpdaterId",
                table: "Supplies",
                column: "UpdaterId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Transfers_AspNetUsers_CreatorId",
                table: "Transfers",
                column: "CreatorId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Transfers_AspNetUsers_UpdaterId",
                table: "Transfers",
                column: "UpdaterId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_EnemyLoot_Character_CharacterId",
                table: "EnemyLoot");

            migrationBuilder.DropForeignKey(
                name: "FK_EnemyLoot_Enemy_EnemyId",
                table: "EnemyLoot");

            migrationBuilder.DropPrimaryKey(
                name: "PK_EnemyLoot",
                table: "EnemyLoot");

            migrationBuilder.DropIndex(
                name: "IX_EnemyLoot_CharacterId",
                table: "EnemyLoot");

            migrationBuilder.DropColumn(
                name: "EnemyId",
                table: "EnemyLoot");

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

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

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

            migrationBuilder.AddPrimaryKey(
                name: "PK_EnemyLoot",
                table: "EnemyLoot",
                columns: new[] { "CharacterId", "ItemId" });

            migrationBuilder.CreateTable(
                name: "LocationDTO",
                columns: table => new
            {
                Id = table.Column <int>(type: "int", nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Description = table.Column <string>(type: "nvarchar(max)", nullable: true),
                Name        = table.Column <string>(type: "nvarchar(max)", nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_LocationDTO", x => x.Id);
            });

            migrationBuilder.CreateIndex(
                name: "IX_EnemyInLocation_LocationDTOId",
                table: "EnemyInLocation",
                column: "LocationDTOId");

            migrationBuilder.CreateIndex(
                name: "IX_Character_CurrentLocationId",
                table: "Character",
                column: "CurrentLocationId");

            migrationBuilder.CreateIndex(
                name: "IX_Character_WeaponId",
                table: "Character",
                column: "WeaponId");

            migrationBuilder.AddForeignKey(
                name: "FK_Character_LocationDTO_CurrentLocationId",
                table: "Character",
                column: "CurrentLocationId",
                principalTable: "LocationDTO",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Character_Weapon_WeaponId",
                table: "Character",
                column: "WeaponId",
                principalTable: "Weapon",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_EnemyInLocation_LocationDTO_LocationDTOId",
                table: "EnemyInLocation",
                column: "LocationDTOId",
                principalTable: "LocationDTO",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_EnemyLoot_Character_CharacterId",
                table: "EnemyLoot",
                column: "CharacterId",
                principalTable: "Character",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
示例#52
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn <string>(
                name: "Description",
                table: "Tours",
                nullable: true);

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

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

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

            migrationBuilder.AddColumn <double>(
                name: "Review",
                table: "Tours",
                nullable: true);

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

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

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

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

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

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

            migrationBuilder.CreateIndex(
                name: "IX_Customers_CityId",
                table: "Customers",
                column: "CityId");

            migrationBuilder.CreateIndex(
                name: "IX_Customers_UserId",
                table: "Customers",
                column: "UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_Customers_City_CityId",
                table: "Customers",
                column: "CityId",
                principalTable: "City",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Customers_Users_UserId",
                table: "Customers",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
示例#53
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Courses_Enrollment_EnrollmentID",
                table: "Courses");

            migrationBuilder.DropForeignKey(
                name: "FK_Enrollment_Users_InstructorUserID",
                table: "Enrollment");

            migrationBuilder.DropForeignKey(
                name: "FK_Users_Enrollment_EnrollmentID",
                table: "Users");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Enrollment",
                table: "Enrollment");

            migrationBuilder.RenameTable(
                name: "Enrollment",
                newName: "Enrollments");

            migrationBuilder.RenameIndex(
                name: "IX_Enrollment_InstructorUserID",
                table: "Enrollments",
                newName: "IX_Enrollments_InstructorUserID");

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

            migrationBuilder.AddPrimaryKey(
                name: "PK_Enrollments",
                table: "Enrollments",
                column: "EnrollmentID");

            migrationBuilder.CreateIndex(
                name: "IX_Evaluations_StudentUserID",
                table: "Evaluations",
                column: "StudentUserID");

            migrationBuilder.AddForeignKey(
                name: "FK_Courses_Enrollments_EnrollmentID",
                table: "Courses",
                column: "EnrollmentID",
                principalTable: "Enrollments",
                principalColumn: "EnrollmentID",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Enrollments_Users_InstructorUserID",
                table: "Enrollments",
                column: "InstructorUserID",
                principalTable: "Users",
                principalColumn: "UserID",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Evaluations_Users_StudentUserID",
                table: "Evaluations",
                column: "StudentUserID",
                principalTable: "Users",
                principalColumn: "UserID",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Users_Enrollments_EnrollmentID",
                table: "Users",
                column: "EnrollmentID",
                principalTable: "Enrollments",
                principalColumn: "EnrollmentID",
                onDelete: ReferentialAction.Restrict);
        }
示例#54
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Artists",
                columns: table => new
            {
                ID = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Artists", x => x.ID);
            });

            migrationBuilder.CreateTable(
                name: "Songs",
                columns: table => new
            {
                ID = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Title    = table.Column <string>(nullable: true),
                ArtistID = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Songs", x => x.ID);
                table.ForeignKey(
                    name: "FK_Songs_Artists_ArtistID",
                    column: x => x.ArtistID,
                    principalTable: "Artists",
                    principalColumn: "ID",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.InsertData(
                table: "Artists",
                columns: new[] { "ID", "Name" },
                values: new object[] { 1, "Taylor Swift" });

            migrationBuilder.InsertData(
                table: "Artists",
                columns: new[] { "ID", "Name" },
                values: new object[] { 2, "Arianna Grande" });

            migrationBuilder.InsertData(
                table: "Songs",
                columns: new[] { "ID", "ArtistID", "Title" },
                values: new object[, ]
            {
                { 1, 1, "Shake it Off" },
                { 2, 1, "Gorgeous" },
                { 3, 1, "22" },
                { 4, 2, "Thank You, Next" },
                { 5, 2, "7 Rings" }
            });

            migrationBuilder.CreateIndex(
                name: "IX_Songs_ArtistID",
                table: "Songs",
                column: "ArtistID");
        }
示例#55
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "EFAliasLinks",
                columns: table => new
                {
                    AliasLinkId = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Active = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFAliasLinks", x => x.AliasLinkId);
                });

            migrationBuilder.CreateTable(
                name: "EFServers",
                columns: table => new
                {
                    ServerId = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Active = table.Column<bool>(nullable: false),
                    Port = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFServers", x => x.ServerId);
                });

            migrationBuilder.CreateTable(
                name: "Vector3",
                columns: table => new
                {
                    Vector3Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    X = table.Column<float>(nullable: false),
                    Y = table.Column<float>(nullable: false),
                    Z = table.Column<float>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Vector3", x => x.Vector3Id);
                });

            migrationBuilder.CreateTable(
                name: "EFAlias",
                columns: table => new
                {
                    AliasId = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Active = table.Column<bool>(nullable: false),
                    DateAdded = table.Column<DateTime>(nullable: false),
                    IPAddress = table.Column<int>(nullable: false),
                    LinkId = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 128, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFAlias", x => x.AliasId);
                    table.ForeignKey(
                        name: "FK_EFAlias_EFAliasLinks_LinkId",
                        column: x => x.LinkId,
                        principalTable: "EFAliasLinks",
                        principalColumn: "AliasLinkId",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "EFServerStatistics",
                columns: table => new
                {
                    StatisticId = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Active = table.Column<bool>(nullable: false),
                    ServerId = table.Column<int>(nullable: false),
                    TotalKills = table.Column<long>(nullable: false),
                    TotalPlayTime = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFServerStatistics", x => x.StatisticId);
                    table.ForeignKey(
                        name: "FK_EFServerStatistics_EFServers_ServerId",
                        column: x => x.ServerId,
                        principalTable: "EFServers",
                        principalColumn: "ServerId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EFClients",
                columns: table => new
                {
                    ClientId = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Active = table.Column<bool>(nullable: false),
                    AliasLinkId = table.Column<int>(nullable: false),
                    Connections = table.Column<int>(nullable: false),
                    CurrentAliasId = table.Column<int>(nullable: false),
                    FirstConnection = table.Column<DateTime>(nullable: false),
                    LastConnection = table.Column<DateTime>(nullable: false),
                    Level = table.Column<int>(nullable: false),
                    Masked = table.Column<bool>(nullable: false),
                    NetworkId = table.Column<long>(nullable: false),
                    Password = table.Column<string>(nullable: true),
                    PasswordSalt = table.Column<string>(nullable: true),
                    TotalConnectionTime = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFClients", x => x.ClientId);
                    table.ForeignKey(
                        name: "FK_EFClients_EFAliasLinks_AliasLinkId",
                        column: x => x.AliasLinkId,
                        principalTable: "EFAliasLinks",
                        principalColumn: "AliasLinkId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EFClients_EFAlias_CurrentAliasId",
                        column: x => x.CurrentAliasId,
                        principalTable: "EFAlias",
                        principalColumn: "AliasId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EFClientKills",
                columns: table => new
                {
                    KillId = table.Column<long>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true).
                        Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Active = table.Column<bool>(nullable: false),
                    AttackerId = table.Column<int>(nullable: false),
                    Damage = table.Column<int>(nullable: false),
                    DeathOriginVector3Id = table.Column<int>(nullable: true),
                    DeathType = table.Column<int>(nullable: false),
                    HitLoc = table.Column<int>(nullable: false),
                    KillOriginVector3Id = table.Column<int>(nullable: true),
                    Map = table.Column<int>(nullable: false),
                    ServerId = table.Column<int>(nullable: false),
                    VictimId = table.Column<int>(nullable: false),
                    ViewAnglesVector3Id = table.Column<int>(nullable: true),
                    Weapon = table.Column<int>(nullable: false),
                    When = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFClientKills", x => x.KillId);
                    table.ForeignKey(
                        name: "FK_EFClientKills_EFClients_AttackerId",
                        column: x => x.AttackerId,
                        principalTable: "EFClients",
                        principalColumn: "ClientId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EFClientKills_Vector3_DeathOriginVector3Id",
                        column: x => x.DeathOriginVector3Id,
                        principalTable: "Vector3",
                        principalColumn: "Vector3Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_EFClientKills_Vector3_KillOriginVector3Id",
                        column: x => x.KillOriginVector3Id,
                        principalTable: "Vector3",
                        principalColumn: "Vector3Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_EFClientKills_EFServers_ServerId",
                        column: x => x.ServerId,
                        principalTable: "EFServers",
                        principalColumn: "ServerId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EFClientKills_EFClients_VictimId",
                        column: x => x.VictimId,
                        principalTable: "EFClients",
                        principalColumn: "ClientId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EFClientKills_Vector3_ViewAnglesVector3Id",
                        column: x => x.ViewAnglesVector3Id,
                        principalTable: "Vector3",
                        principalColumn: "Vector3Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "EFClientMessages",
                columns: table => new
                {
                    MessageId = table.Column<long>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Active = table.Column<bool>(nullable: false),
                    ClientId = table.Column<int>(nullable: false),
                    Message = table.Column<string>(nullable: true),
                    ServerId = table.Column<int>(nullable: false),
                    TimeSent = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFClientMessages", x => x.MessageId);
                    table.ForeignKey(
                        name: "FK_EFClientMessages_EFClients_ClientId",
                        column: x => x.ClientId,
                        principalTable: "EFClients",
                        principalColumn: "ClientId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EFClientMessages_EFServers_ServerId",
                        column: x => x.ServerId,
                        principalTable: "EFServers",
                        principalColumn: "ServerId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EFClientStatistics",
                columns: table => new
                {
                    ClientId = table.Column<int>(nullable: false),
                    ServerId = table.Column<int>(nullable: false),
                    Active = table.Column<bool>(nullable: false),
                    Deaths = table.Column<int>(nullable: false),
                    Kills = table.Column<int>(nullable: false),
                    SPM = table.Column<double>(nullable: false),
                    Skill = table.Column<double>(nullable: false),
                    TimePlayed = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFClientStatistics", x => new { x.ClientId, x.ServerId });
                    table.ForeignKey(
                        name: "FK_EFClientStatistics_EFClients_ClientId",
                        column: x => x.ClientId,
                        principalTable: "EFClients",
                        principalColumn: "ClientId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EFClientStatistics_EFServers_ServerId",
                        column: x => x.ServerId,
                        principalTable: "EFServers",
                        principalColumn: "ServerId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EFPenalties",
                columns: table => new
                {
                    PenaltyId = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Active = table.Column<bool>(nullable: false),
                    Expires = table.Column<DateTime>(nullable: false),
                    LinkId = table.Column<int>(nullable: false),
                    OffenderId = table.Column<int>(nullable: false),
                    Offense = table.Column<string>(nullable: false),
                    PunisherId = table.Column<int>(nullable: false),
                    Type = table.Column<int>(nullable: false),
                    When = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFPenalties", x => x.PenaltyId);
                    table.ForeignKey(
                        name: "FK_EFPenalties_EFAliasLinks_LinkId",
                        column: x => x.LinkId,
                        principalTable: "EFAliasLinks",
                        principalColumn: "AliasLinkId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EFPenalties_EFClients_OffenderId",
                        column: x => x.OffenderId,
                        principalTable: "EFClients",
                        principalColumn: "ClientId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_EFPenalties_EFClients_PunisherId",
                        column: x => x.PunisherId,
                        principalTable: "EFClients",
                        principalColumn: "ClientId",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "EFHitLocationCounts",
                columns: table => new
                {
                    HitLocationCountId = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true).
                        Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn).
                        Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Active = table.Column<bool>(nullable: false),
                    EFClientStatistics_ClientId = table.Column<int>(nullable: false),
                    HitCount = table.Column<int>(nullable: false),
                    HitOffsetAverage = table.Column<float>(nullable: false),
                    Location = table.Column<int>(nullable: false),
                    EFClientStatistics_ServerId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EFHitLocationCounts", x => x.HitLocationCountId);
                    table.ForeignKey(
                        name: "FK_EFHitLocationCounts_EFClients_EFClientStatistics_ClientId",
                        column: x => x.EFClientStatistics_ClientId,
                        principalTable: "EFClients",
                        principalColumn: "ClientId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EFHitLocationCounts_EFServers_EFClientStatistics_ServerId",
                        column: x => x.EFClientStatistics_ServerId,
                        principalTable: "EFServers",
                        principalColumn: "ServerId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EFHitLocationCounts_EFClientStatistics_EFClientStatistics_ClientId_EFClientStatistics_ServerId",
                        columns: x => new { x.EFClientStatistics_ClientId, x.EFClientStatistics_ServerId },
                        principalTable: "EFClientStatistics",
                        principalColumns: new[] { "ClientId", "ServerId" },
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_EFAlias_LinkId",
                table: "EFAlias",
                column: "LinkId");

            migrationBuilder.CreateIndex(
                name: "IX_EFClientKills_AttackerId",
                table: "EFClientKills",
                column: "AttackerId");

            migrationBuilder.CreateIndex(
                name: "IX_EFClientKills_DeathOriginVector3Id",
                table: "EFClientKills",
                column: "DeathOriginVector3Id");

            migrationBuilder.CreateIndex(
                name: "IX_EFClientKills_KillOriginVector3Id",
                table: "EFClientKills",
                column: "KillOriginVector3Id");

            migrationBuilder.CreateIndex(
                name: "IX_EFClientKills_ServerId",
                table: "EFClientKills",
                column: "ServerId");

            migrationBuilder.CreateIndex(
                name: "IX_EFClientKills_VictimId",
                table: "EFClientKills",
                column: "VictimId");

            migrationBuilder.CreateIndex(
                name: "IX_EFClientKills_ViewAnglesVector3Id",
                table: "EFClientKills",
                column: "ViewAnglesVector3Id");

            migrationBuilder.CreateIndex(
                name: "IX_EFClientMessages_ClientId",
                table: "EFClientMessages",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_EFClientMessages_ServerId",
                table: "EFClientMessages",
                column: "ServerId");

            migrationBuilder.CreateIndex(
                name: "IX_EFClients_AliasLinkId",
                table: "EFClients",
                column: "AliasLinkId");

            migrationBuilder.CreateIndex(
                name: "IX_EFClients_CurrentAliasId",
                table: "EFClients",
                column: "CurrentAliasId");

            migrationBuilder.CreateIndex(
                name: "IX_EFClients_NetworkId",
                table: "EFClients",
                column: "NetworkId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_EFClientStatistics_ServerId",
                table: "EFClientStatistics",
                column: "ServerId");

            migrationBuilder.CreateIndex(
                name: "IX_EFHitLocationCounts_EFClientStatistics_ServerId",
                table: "EFHitLocationCounts",
                column: "EFClientStatistics_ServerId");

            migrationBuilder.CreateIndex(
                name: "IX_EFHitLocationCounts_EFClientStatistics_ClientId_EFClientStatistics_ServerId",
                table: "EFHitLocationCounts",
                columns: new[] { "EFClientStatistics_ClientId", "EFClientStatistics_ServerId" });

            migrationBuilder.CreateIndex(
                name: "IX_EFPenalties_LinkId",
                table: "EFPenalties",
                column: "LinkId");

            migrationBuilder.CreateIndex(
                name: "IX_EFPenalties_OffenderId",
                table: "EFPenalties",
                column: "OffenderId");

            migrationBuilder.CreateIndex(
                name: "IX_EFPenalties_PunisherId",
                table: "EFPenalties",
                column: "PunisherId");

            migrationBuilder.CreateIndex(
                name: "IX_EFServerStatistics_ServerId",
                table: "EFServerStatistics",
                column: "ServerId");
        }
示例#56
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Members",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Name = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Members", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Prices",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Type  = table.Column <int>(nullable: false),
                Price = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Prices", x => x.Id);
            });

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

            migrationBuilder.CreateTable(
                name: "Vehicles",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                RegNr              = table.Column <string>(maxLength: 6, nullable: false),
                Color              = table.Column <string>(maxLength: 20, nullable: false),
                Brand              = table.Column <string>(maxLength: 40, nullable: false),
                Model              = table.Column <string>(maxLength: 20, nullable: false),
                NoWheels           = table.Column <int>(nullable: false),
                ParkedIn           = table.Column <DateTime>(nullable: false),
                MemberId           = table.Column <int>(nullable: false),
                VehicleTypeClassId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Vehicles", x => x.Id);
                table.ForeignKey(
                    name: "FK_Vehicles_Members_MemberId",
                    column: x => x.MemberId,
                    principalTable: "Members",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_Vehicles_VehicleTypeClass_VehicleTypeClassId",
                    column: x => x.VehicleTypeClassId,
                    principalTable: "VehicleTypeClass",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Vehicles_MemberId",
                table: "Vehicles",
                column: "MemberId");

            migrationBuilder.CreateIndex(
                name: "IX_Vehicles_VehicleTypeClassId",
                table: "Vehicles",
                column: "VehicleTypeClassId");
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Categories",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                CategoryName = table.Column <string>(nullable: false),
                Description  = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Categories", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Tags",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Name        = table.Column <string>(nullable: true),
                Description = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Tags", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "Products",
                columns: table => new
            {
                Id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                Name        = table.Column <string>(nullable: true),
                Description = table.Column <string>(nullable: true),
                Stock       = table.Column <int>(nullable: false),
                Price       = table.Column <decimal>(nullable: false),
                ImageUrl    = table.Column <string>(nullable: true),
                CategoryId  = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Products", x => x.Id);
                table.ForeignKey(
                    name: "FK_Products_Categories_CategoryId",
                    column: x => x.CategoryId,
                    principalTable: "Categories",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ProductTag",
                columns: table => new
            {
                ProductId = table.Column <int>(nullable: false),
                TagId     = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ProductTag", x => new { x.ProductId, x.TagId });
                table.ForeignKey(
                    name: "FK_ProductTag_Products_ProductId",
                    column: x => x.ProductId,
                    principalTable: "Products",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ProductTag_Tags_TagId",
                    column: x => x.TagId,
                    principalTable: "Tags",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.InsertData(
                table: "Categories",
                columns: new[] { "Id", "CategoryName", "Description" },
                values: new object[, ]
            {
                { 1, "Gạo", null },
                { 2, "Thịt", null },
                { 3, "Hoa Quả", null }
            });

            migrationBuilder.InsertData(
                table: "Tags",
                columns: new[] { "Id", "Description", "Name" },
                values: new object[, ]
            {
                { 1, null, "Re" },
                { 2, null, "Ngon" },
                { 3, null, "Bo Khoe" }
            });

            migrationBuilder.InsertData(
                table: "Products",
                columns: new[] { "Id", "CategoryId", "Description", "ImageUrl", "Name", "Price", "Stock" },
                values: new object[, ]
            {
                { 1, 1, "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", "https://cf.shopee.vn/file/92704e5d399d6852fd0eb96f37399459", "Gạo Lứt Huế", 15.5m, 500 },
                { 2, 2, "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", "https://daotaobeptruong.vn/wp-content/uploads/2019/11/mon-ngon-tu-thit-ba-chi.jpg", "Thịt ba chỉ Huế", 15.5m, 500 },
                { 5, 2, "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", "https://thucthan.com/media/2019/08/cha-que/cha-que.jpg", "Chả Huế", 15.5m, 500 },
                { 3, 3, "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", "https://icdn.dantri.com.vn/zoom/1200_630/2017/20170920172246-tao-tay-1506037544989.jpg", "Táo Trung Quốc", 15.5m, 500 },
                { 4, 3, "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", "https://cdn.muabannhanh.com/asset/frontend/img/gallery/2019/06/26/5d133b04e12ab_1561541380.jpg", "Mít Sáy Huế", 15.5m, 500 }
            });

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

            migrationBuilder.CreateIndex(
                name: "IX_ProductTag_TagId",
                table: "ProductTag",
                column: "TagId");
        }
示例#58
0
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_FoodAmountPerMeal_Foods_FoodID",
                table: "FoodAmountPerMeal");

            migrationBuilder.DropForeignKey(
                name: "FK_FoodAmountPerMeal_Meals_MealsID",
                table: "FoodAmountPerMeal");

            migrationBuilder.DropPrimaryKey(
                name: "PK_FoodAmountPerMeal",
                table: "FoodAmountPerMeal");

            migrationBuilder.RenameTable(
                name: "FoodAmountPerMeal",
                newName: "FoodAmountPerMeals");

            migrationBuilder.RenameColumn(
                name: "MealsID",
                table: "FoodAmountPerMeals",
                newName: "MealID");

            migrationBuilder.RenameIndex(
                name: "IX_FoodAmountPerMeal_MealsID",
                table: "FoodAmountPerMeals",
                newName: "IX_FoodAmountPerMeals_MealID");

            migrationBuilder.RenameIndex(
                name: "IX_FoodAmountPerMeal_FoodID",
                table: "FoodAmountPerMeals",
                newName: "IX_FoodAmountPerMeals_FoodID");

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

            migrationBuilder.AddPrimaryKey(
                name: "PK_FoodAmountPerMeals",
                table: "FoodAmountPerMeals",
                column: "ID");

            migrationBuilder.CreateIndex(
                name: "IX_Meals_FoodID",
                table: "Meals",
                column: "FoodID");

            migrationBuilder.AddForeignKey(
                name: "FK_FoodAmountPerMeals_Foods_FoodID",
                table: "FoodAmountPerMeals",
                column: "FoodID",
                principalTable: "Foods",
                principalColumn: "ID",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_FoodAmountPerMeals_Meals_MealID",
                table: "FoodAmountPerMeals",
                column: "MealID",
                principalTable: "Meals",
                principalColumn: "ID",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Meals_Foods_FoodID",
                table: "Meals",
                column: "FoodID",
                principalTable: "Foods",
                principalColumn: "ID",
                onDelete: ReferentialAction.Restrict);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn <string>(
                name: "ClaimType",
                table: "AbpUserClaims",
                maxLength: 256,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "UserName",
                table: "AbpUserAccounts",
                maxLength: 32,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "EmailAddress",
                table: "AbpUserAccounts",
                maxLength: 256,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn <string>(
                name: "ClaimType",
                table: "AbpRoleClaims",
                maxLength: 256,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.CreateTable(
                name: "AbpEntityChangeSets",
                columns: table => new
            {
                Id = table.Column <long>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                BrowserInfo          = table.Column <string>(maxLength: 256, nullable: true),
                ClientIpAddress      = table.Column <string>(maxLength: 64, nullable: true),
                ClientName           = table.Column <string>(maxLength: 128, nullable: true),
                CreationTime         = table.Column <DateTime>(nullable: false),
                ExtensionData        = table.Column <string>(nullable: true),
                ImpersonatorTenantId = table.Column <int>(nullable: true),
                ImpersonatorUserId   = table.Column <long>(nullable: true),
                Reason   = table.Column <string>(maxLength: 256, nullable: true),
                TenantId = table.Column <int>(nullable: true),
                UserId   = table.Column <long>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AbpEntityChangeSets", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "AbpEntityChanges",
                columns: table => new
            {
                Id = table.Column <long>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ChangeTime         = table.Column <DateTime>(nullable: false),
                ChangeType         = table.Column <byte>(nullable: false),
                EntityChangeSetId  = table.Column <long>(nullable: false),
                EntityId           = table.Column <string>(maxLength: 48, nullable: true),
                EntityTypeFullName = table.Column <string>(maxLength: 192, nullable: true),
                TenantId           = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AbpEntityChanges", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpEntityChanges_AbpEntityChangeSets_EntityChangeSetId",
                    column: x => x.EntityChangeSetId,
                    principalTable: "AbpEntityChangeSets",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AbpEntityPropertyChanges",
                columns: table => new
            {
                Id = table.Column <long>(nullable: false)
                     .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                EntityChangeId       = table.Column <long>(nullable: false),
                NewValue             = table.Column <string>(maxLength: 512, nullable: true),
                OriginalValue        = table.Column <string>(maxLength: 512, nullable: true),
                PropertyName         = table.Column <string>(maxLength: 96, nullable: true),
                PropertyTypeFullName = table.Column <string>(maxLength: 192, nullable: true),
                TenantId             = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId",
                    column: x => x.EntityChangeId,
                    principalTable: "AbpEntityChanges",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_AbpEntityChanges_EntityChangeSetId",
                table: "AbpEntityChanges",
                column: "EntityChangeSetId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpEntityChanges_EntityTypeFullName_EntityId",
                table: "AbpEntityChanges",
                columns: new[] { "EntityTypeFullName", "EntityId" });

            migrationBuilder.CreateIndex(
                name: "IX_AbpEntityChangeSets_TenantId_CreationTime",
                table: "AbpEntityChangeSets",
                columns: new[] { "TenantId", "CreationTime" });

            migrationBuilder.CreateIndex(
                name: "IX_AbpEntityChangeSets_TenantId_Reason",
                table: "AbpEntityChangeSets",
                columns: new[] { "TenantId", "Reason" });

            migrationBuilder.CreateIndex(
                name: "IX_AbpEntityChangeSets_TenantId_UserId",
                table: "AbpEntityChangeSets",
                columns: new[] { "TenantId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_AbpEntityPropertyChanges_EntityChangeId",
                table: "AbpEntityPropertyChanges",
                column: "EntityChangeId");
        }
示例#60
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn <string>(
                name: "Title",
                table: "Course",
                type: "nvarchar(50)",
                maxLength: 50,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

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

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

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

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

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

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

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

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

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

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

            migrationBuilder.AddForeignKey(
                name: "FK_Course_Department_DepartmentID",
                table: "Course",
                column: "DepartmentID",
                principalTable: "Department",
                principalColumn: "DepartmentID",
                onDelete: ReferentialAction.Cascade);
        }