using System; using Microsoft.EntityFrameworkCore.Migrations; using MySql.EntityFrameworkCore.Metadata; #nullable disable namespace ToDoApp.Migrations { /// public partial class init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "varchar(255)", nullable: false), Password = table.Column(type: "longtext", nullable: false), Email = table.Column(type: "longtext", nullable: false), CreateDate = table.Column(type: "datetime(6)", nullable: false), Status = table.Column(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(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), UserId = table.Column(type: "int", nullable: false), Title = table.Column(type: "longtext", nullable: false), Description = table.Column(type: "longtext", nullable: true), DueDate = table.Column(type: "datetime(6)", nullable: true), IsToday = table.Column(type: "tinyint(1)", nullable: true), IsCompleted = table.Column(type: "tinyint(1)", nullable: true), CreateDate = table.Column(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); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Items"); migrationBuilder.DropTable( name: "Users"); } } }