using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marco.Pms.DataAccess.Migrations
{
///
public partial class attend : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AttendanceLogs_Attendances_AttendanceId",
table: "AttendanceLogs");
migrationBuilder.DropForeignKey(
name: "FK_Attendances_Employees_EmployeeID",
table: "Attendances");
migrationBuilder.DropForeignKey(
name: "FK_Attendances_Tenants_TenantId",
table: "Attendances");
migrationBuilder.DropPrimaryKey(
name: "PK_Attendances",
table: "Attendances");
migrationBuilder.RenameTable(
name: "Attendances",
newName: "Attendance");
migrationBuilder.RenameIndex(
name: "IX_Attendances_TenantId",
table: "Attendance",
newName: "IX_Attendance_TenantId");
migrationBuilder.RenameIndex(
name: "IX_Attendances_EmployeeID",
table: "Attendance",
newName: "IX_Attendance_EmployeeID");
migrationBuilder.AddColumn(
name: "RoleId",
table: "Employees",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci");
migrationBuilder.AddPrimaryKey(
name: "PK_Attendance",
table: "Attendance",
column: "Id");
migrationBuilder.CreateTable(
name: "Attendes",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Comment = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
EmployeeID = table.Column(type: "int", nullable: false),
Date = table.Column(type: "datetime(6)", nullable: false),
ProjectID = table.Column(type: "int", nullable: false),
AttendanceDate = table.Column(type: "datetime(6)", nullable: false),
InTime = table.Column(type: "datetime(6)", nullable: true),
OutTime = table.Column(type: "datetime(6)", nullable: true),
IsApproved = table.Column(type: "tinyint(1)", nullable: false),
Activity = table.Column(type: "int", nullable: false),
ApprovedBy = table.Column(type: "int", nullable: true),
TenantId = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Attendes", x => x.Id);
table.ForeignKey(
name: "FK_Attendes_Employees_EmployeeID",
column: x => x.EmployeeID,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Attendes_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 1,
column: "Key",
value: "c66df186-3191-4286-b5ef-c6a4adc3a65b");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 2,
column: "Key",
value: "5efb0b4b-03ab-480c-a2fd-d5a8be9e5f96");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 3,
column: "Key",
value: "43e0fb8a-3d42-451c-9899-24bb033b4e70");
migrationBuilder.CreateIndex(
name: "IX_Attendes_EmployeeID",
table: "Attendes",
column: "EmployeeID");
migrationBuilder.CreateIndex(
name: "IX_Attendes_TenantId",
table: "Attendes",
column: "TenantId");
migrationBuilder.AddForeignKey(
name: "FK_Attendance_Employees_EmployeeID",
table: "Attendance",
column: "EmployeeID",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Attendance_Tenants_TenantId",
table: "Attendance",
column: "TenantId",
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AttendanceLogs_Attendance_AttendanceId",
table: "AttendanceLogs",
column: "AttendanceId",
principalTable: "Attendance",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Attendance_Employees_EmployeeID",
table: "Attendance");
migrationBuilder.DropForeignKey(
name: "FK_Attendance_Tenants_TenantId",
table: "Attendance");
migrationBuilder.DropForeignKey(
name: "FK_AttendanceLogs_Attendance_AttendanceId",
table: "AttendanceLogs");
migrationBuilder.DropTable(
name: "Attendes");
migrationBuilder.DropPrimaryKey(
name: "PK_Attendance",
table: "Attendance");
migrationBuilder.DropColumn(
name: "RoleId",
table: "Employees");
migrationBuilder.RenameTable(
name: "Attendance",
newName: "Attendances");
migrationBuilder.RenameIndex(
name: "IX_Attendance_TenantId",
table: "Attendances",
newName: "IX_Attendances_TenantId");
migrationBuilder.RenameIndex(
name: "IX_Attendance_EmployeeID",
table: "Attendances",
newName: "IX_Attendances_EmployeeID");
migrationBuilder.AddPrimaryKey(
name: "PK_Attendances",
table: "Attendances",
column: "Id");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 1,
column: "Key",
value: "331a7bea-688e-4f27-8dba-697d9cd29870");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 2,
column: "Key",
value: "ba873fd2-277b-4baa-88b9-22b69010ffa8");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 3,
column: "Key",
value: "aa481e97-9a9b-4b1e-b9dd-0a6ce26dab47");
migrationBuilder.AddForeignKey(
name: "FK_AttendanceLogs_Attendances_AttendanceId",
table: "AttendanceLogs",
column: "AttendanceId",
principalTable: "Attendances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Attendances_Employees_EmployeeID",
table: "Attendances",
column: "EmployeeID",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Attendances_Tenants_TenantId",
table: "Attendances",
column: "TenantId",
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}