mirror of
https://github.com/guilhermewerner/site-pi
synced 2025-06-16 13:54:20 +00:00
167 lines
6.6 KiB
C#
167 lines
6.6 KiB
C#
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<int>(nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
Name = table.Column<string>(nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Profiles", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Quizzes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
Name = table.Column<string>(nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Quizzes", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
Name = table.Column<string>(maxLength: 25, nullable: false),
|
|
Email = table.Column<string>(maxLength: 100, nullable: false),
|
|
PasswordHash = table.Column<string>(maxLength: 45, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Questions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
Text = table.Column<string>(nullable: false),
|
|
QuizId = table.Column<int>(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<int>(nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
Name = table.Column<string>(nullable: false),
|
|
UserId = table.Column<int>(nullable: false),
|
|
FileBytes = table.Column<string>(nullable: true),
|
|
FileName = table.Column<string>(nullable: true),
|
|
PercentageA = table.Column<float>(nullable: false),
|
|
PercentageB = table.Column<float>(nullable: false),
|
|
PercentageC = table.Column<float>(nullable: false),
|
|
PercentageD = table.Column<float>(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<int>(nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
Text = table.Column<string>(nullable: false),
|
|
QuestionId = table.Column<int>(nullable: false),
|
|
ProfileId = table.Column<int>(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");
|
|
}
|
|
}
|
|
}
|