using System; using Microsoft.EntityFrameworkCore.Migrations; using MySql.EntityFrameworkCore.Metadata; #nullable disable namespace EmployeeManagmentDataBaseImplement.Migrations { /// public partial class InitialMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "PhysicalPersons", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "longtext", nullable: false), Surname = table.Column(type: "longtext", nullable: false), Patronymic = table.Column(type: "longtext", nullable: true), Birthday = table.Column(type: "datetime(6)", nullable: false), Gender = table.Column(type: "longtext", nullable: false), Address = table.Column(type: "longtext", nullable: false), Telephone = table.Column(type: "longtext", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PhysicalPersons", x => x.Id); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "Employees", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), NameJob = table.Column(type: "longtext", nullable: false), StartJob = table.Column(type: "datetime(6)", nullable: true), EndJob = table.Column(type: "datetime(6)", nullable: true), PartTimeJob = table.Column(type: "longtext", nullable: true), Bid = table.Column(type: "float", nullable: false), PhisicalPersonsId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Employees", x => x.Id); table.ForeignKey( name: "FK_Employees_PhysicalPersons_PhisicalPersonsId", column: x => x.PhisicalPersonsId, principalTable: "PhysicalPersons", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "Salaries", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), CountHours = table.Column(type: "int", nullable: false), PriceHour = table.Column(type: "float", nullable: false), Premium = table.Column(type: "float", nullable: true), Data = table.Column(type: "datetime(6)", nullable: true), Passed = table.Column(type: "tinyint(1)", nullable: false), EmployeesId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Salaries", x => x.Id); table.ForeignKey( name: "FK_Salaries_Employees_EmployeesId", column: x => x.EmployeesId, principalTable: "Employees", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "Vacations", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), StartData = table.Column(type: "datetime(6)", nullable: false), EndData = table.Column(type: "datetime(6)", nullable: false), Passed = table.Column(type: "tinyint(1)", nullable: false), EmployeesId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Vacations", x => x.Id); table.ForeignKey( name: "FK_Vacations_Employees_EmployeesId", column: x => x.EmployeesId, principalTable: "Employees", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Employees_PhisicalPersonsId", table: "Employees", column: "PhisicalPersonsId"); migrationBuilder.CreateIndex( name: "IX_Salaries_EmployeesId", table: "Salaries", column: "EmployeesId"); migrationBuilder.CreateIndex( name: "IX_Vacations_EmployeesId", table: "Vacations", column: "EmployeesId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Salaries"); migrationBuilder.DropTable( name: "Vacations"); migrationBuilder.DropTable( name: "Employees"); migrationBuilder.DropTable( name: "PhysicalPersons"); } } }