using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace SitePi.Migrations { public partial class _1 : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Profiles", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Profiles", x => x.Id); }); migrationBuilder.CreateTable( name: "Quizzes", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Quizzes", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(maxLength: 25, nullable: false), Email = table.Column(maxLength: 100, nullable: false), PasswordHash = table.Column(maxLength: 45, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Questions", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Text = table.Column(nullable: false), QuizId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Questions", x => x.Id); table.ForeignKey( name: "FK_Questions_Quizzes_QuizId", column: x => x.QuizId, principalTable: "Quizzes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Bots", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(nullable: false), UserId = table.Column(nullable: false), FileBytes = table.Column(nullable: true), FileName = table.Column(nullable: true), PercentageA = table.Column(nullable: false), PercentageB = table.Column(nullable: false), PercentageC = table.Column(nullable: false), PercentageD = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Bots", x => x.Id); table.ForeignKey( name: "FK_Bots_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Choices", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Text = table.Column(nullable: false), QuestionId = table.Column(nullable: false), ProfileId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Choices", x => x.Id); table.ForeignKey( name: "FK_Choices_Profiles_ProfileId", column: x => x.ProfileId, principalTable: "Profiles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Choices_Questions_QuestionId", column: x => x.QuestionId, principalTable: "Questions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Bots_UserId", table: "Bots", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Choices_ProfileId", table: "Choices", column: "ProfileId"); migrationBuilder.CreateIndex( name: "IX_Choices_QuestionId", table: "Choices", column: "QuestionId"); migrationBuilder.CreateIndex( name: "IX_Questions_QuizId", table: "Questions", column: "QuizId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Bots"); migrationBuilder.DropTable( name: "Choices"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "Profiles"); migrationBuilder.DropTable( name: "Questions"); migrationBuilder.DropTable( name: "Quizzes"); } } }