using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace MTWorkHR.Infrastructure.Migrations { /// public partial class contractTbls : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Contracts", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CreateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), UpdateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), CreateDate = table.Column(type: "datetime2", nullable: false), UpdateDate = table.Column(type: "datetime2", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeleteUserId = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), ContractTypeId = table.Column(type: "int", nullable: false), CompanyId = table.Column(type: "bigint", nullable: false), CompanyRepresentativeId = table.Column(type: "nvarchar(max)", nullable: false), UserId = table.Column(type: "nvarchar(max)", nullable: false), JobId = table.Column(type: "int", nullable: true), AcademicQualificationId = table.Column(type: "int", nullable: true), SpecializationId = table.Column(type: "int", nullable: true), WorkCountryId = table.Column(type: "int", nullable: false), WorkStateId = table.Column(type: "int", nullable: false), JobTitleId = table.Column(type: "int", nullable: true), JobDescription = table.Column(type: "nvarchar(max)", nullable: true), JobNumber = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: true), StartDate = table.Column(type: "datetime2", nullable: true), EndDate = table.Column(type: "datetime2", nullable: true), ContractDurationId = table.Column(type: "int", nullable: false), TypeOfWork = table.Column(type: "int", nullable: false), VacationDays = table.Column(type: "int", nullable: false), TrialPeriod = table.Column(type: "int", nullable: false), WhoCanTerminateContractInTrial = table.Column(type: "int", nullable: false), WhoCanTerminateContract = table.Column(type: "int", nullable: false), NoticePeriodBeforeTermination = table.Column(type: "int", nullable: false), WorkingDays = table.Column(type: "nvarchar(max)", nullable: false), WorkingHours = table.Column(type: "int", nullable: false), StartDailyWorkingHours = table.Column(type: "datetime2", nullable: true), EndDailyWorkingHours = table.Column(type: "datetime2", nullable: true), Currency = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), Salary = table.Column(type: "decimal(18,2)", nullable: true), BillingCycle = table.Column(type: "int", nullable: false), IncludesAllAllowances = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Contracts", x => x.Id); }); migrationBuilder.CreateTable( name: "ContractAllowance", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CreateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), UpdateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), CreateDate = table.Column(type: "datetime2", nullable: false), UpdateDate = table.Column(type: "datetime2", nullable: true), ContractId = table.Column(type: "bigint", nullable: false), AllowanceType = table.Column(type: "bigint", nullable: false), AllowanceDesc = table.Column(type: "nvarchar(max)", nullable: true), EntitlementPercent = table.Column(type: "bigint", nullable: false), EntitlementAmount = table.Column(type: "bigint", nullable: false), PaymentType = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ContractAllowance", x => x.Id); table.ForeignKey( name: "FK_ContractAllowance_Contracts_ContractId", column: x => x.ContractId, principalTable: "Contracts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ContractTask", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CreateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), UpdateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), CreateDate = table.Column(type: "datetime2", nullable: false), UpdateDate = table.Column(type: "datetime2", nullable: true), ContractId = table.Column(type: "bigint", nullable: false), Title = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), StartDate = table.Column(type: "datetime2", nullable: true), Amount = table.Column(type: "decimal(18,2)", nullable: true), ScopeOfWork = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ContractTask", x => x.Id); table.ForeignKey( name: "FK_ContractTask_Contracts_ContractId", column: x => x.ContractId, principalTable: "Contracts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ProjectStage", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CreateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), UpdateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), CreateDate = table.Column(type: "datetime2", nullable: false), UpdateDate = table.Column(type: "datetime2", nullable: true), ContractId = table.Column(type: "bigint", nullable: false), Title = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), StartDate = table.Column(type: "datetime2", nullable: true), ExpectedEndDate = table.Column(type: "datetime2", nullable: true), AmountPercent = table.Column(type: "decimal(18,2)", nullable: true), ScopeOfWork = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ProjectStage", x => x.Id); table.ForeignKey( name: "FK_ProjectStage_Contracts_ContractId", column: x => x.ContractId, principalTable: "Contracts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ContractTaskAttachment", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CreateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), UpdateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), CreateDate = table.Column(type: "datetime2", nullable: false), UpdateDate = table.Column(type: "datetime2", nullable: true), ContractTaskId = table.Column(type: "bigint", nullable: false), AttachmentTypeId = table.Column(type: "bigint", nullable: true), FileName = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true), OriginalName = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true), Content = table.Column(type: "varbinary(max)", nullable: false), FilePath = table.Column(type: "nvarchar(max)", nullable: true), ContentType = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ContractTaskAttachment", x => x.Id); table.ForeignKey( name: "FK_ContractTaskAttachment_AttachmentTypes_AttachmentTypeId", column: x => x.AttachmentTypeId, principalTable: "AttachmentTypes", principalColumn: "Id"); table.ForeignKey( name: "FK_ContractTaskAttachment_ContractTask_ContractTaskId", column: x => x.ContractTaskId, principalTable: "ContractTask", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ProjectStageAttachment", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CreateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), UpdateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true), CreateDate = table.Column(type: "datetime2", nullable: false), UpdateDate = table.Column(type: "datetime2", nullable: true), ProjectStageId = table.Column(type: "bigint", nullable: false), AttachmentTypeId = table.Column(type: "bigint", nullable: true), FileName = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true), OriginalName = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true), Content = table.Column(type: "varbinary(max)", nullable: false), FilePath = table.Column(type: "nvarchar(max)", nullable: true), ContentType = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ProjectStageAttachment", x => x.Id); table.ForeignKey( name: "FK_ProjectStageAttachment_AttachmentTypes_AttachmentTypeId", column: x => x.AttachmentTypeId, principalTable: "AttachmentTypes", principalColumn: "Id"); table.ForeignKey( name: "FK_ProjectStageAttachment_ProjectStage_ProjectStageId", column: x => x.ProjectStageId, principalTable: "ProjectStage", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_ContractAllowance_ContractId", table: "ContractAllowance", column: "ContractId"); migrationBuilder.CreateIndex( name: "IX_Contracts_CompanyId", table: "Contracts", column: "CompanyId"); migrationBuilder.CreateIndex( name: "IX_ContractTask_ContractId", table: "ContractTask", column: "ContractId"); migrationBuilder.CreateIndex( name: "IX_ContractTaskAttachment_AttachmentTypeId", table: "ContractTaskAttachment", column: "AttachmentTypeId"); migrationBuilder.CreateIndex( name: "IX_ContractTaskAttachment_ContractTaskId", table: "ContractTaskAttachment", column: "ContractTaskId"); migrationBuilder.CreateIndex( name: "IX_ProjectStage_ContractId", table: "ProjectStage", column: "ContractId"); migrationBuilder.CreateIndex( name: "IX_ProjectStageAttachment_AttachmentTypeId", table: "ProjectStageAttachment", column: "AttachmentTypeId"); migrationBuilder.CreateIndex( name: "IX_ProjectStageAttachment_ProjectStageId", table: "ProjectStageAttachment", column: "ProjectStageId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ContractAllowance"); migrationBuilder.DropTable( name: "ContractTaskAttachment"); migrationBuilder.DropTable( name: "ProjectStageAttachment"); migrationBuilder.DropTable( name: "ContractTask"); migrationBuilder.DropTable( name: "ProjectStage"); migrationBuilder.DropTable( name: "Contracts"); } } }