using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Ultimate.Migrations { /// public partial class DatabaseCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Companies", columns: table => new { CompanyId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Name = table.Column(type: "varchar(60)", maxLength: 60, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Address = table.Column(type: "varchar(60)", maxLength: 60, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Country = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Companies", x => x.CompanyId); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Employees", columns: table => new { EmployeeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Name = table.Column(type: "varchar(30)", maxLength: 30, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Age = table.Column(type: "int", nullable: false), Position = table.Column(type: "varchar(20)", maxLength: 20, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CompanyId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_Employees", x => x.EmployeeId); table.ForeignKey( name: "FK_Employees_Companies_CompanyId", column: x => x.CompanyId, principalTable: "Companies", principalColumn: "CompanyId", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Employees_CompanyId", table: "Employees", column: "CompanyId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Employees"); migrationBuilder.DropTable( name: "Companies"); } } }