You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.4 KiB
84 lines
3.4 KiB
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using MySql.EntityFrameworkCore.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace ToDoApp.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterDatabase()
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
|
|
Name = table.Column<string>(type: "varchar(255)", nullable: false),
|
|
Password = table.Column<string>(type: "longtext", nullable: false),
|
|
Email = table.Column<string>(type: "longtext", nullable: false),
|
|
CreateDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Items",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
|
|
UserId = table.Column<int>(type: "int", nullable: false),
|
|
Title = table.Column<string>(type: "longtext", nullable: false),
|
|
Description = table.Column<string>(type: "longtext", nullable: true),
|
|
DueDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
IsToday = table.Column<bool>(type: "tinyint(1)", nullable: true),
|
|
IsCompleted = table.Column<bool>(type: "tinyint(1)", nullable: true),
|
|
CreateDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Items", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Items_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Items_UserId",
|
|
table: "Items",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_Name",
|
|
table: "Users",
|
|
column: "Name",
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Items");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
}
|
|
}
|
|
}
|
|
|