using System; using Microsoft.EntityFrameworkCore.Migrations; namespace wispro.sp.api.Migrations { public partial class CalMonth : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "BasePointRules", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Rule = table.Column(type: "nvarchar(max)", nullable: true), Point = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_BasePointRules", x => x.Id); }); migrationBuilder.CreateTable( name: "CalMonth", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), year = table.Column(type: "int", nullable: false), month = table.Column(type: "int", nullable: false), status = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CalMonth", x => x.Id); }); migrationBuilder.CreateTable( name: "StaffGrade", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Grade = table.Column(type: "nchar(5)", fixedLength: true, maxLength: 5, nullable: false), Coefficient = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_StaffGrade", x => x.Id); }); migrationBuilder.CreateTable( name: "Staff", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Account = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false), Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), Status = table.Column(type: "nvarchar(25)", maxLength: 25, nullable: false), isCalPerformsnce = table.Column(type: "bit", nullable: false), StaffGradeId = table.Column(type: "int", nullable: false), Department = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), WorkPlace = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), EntyDate = table.Column(type: "date", nullable: true), Mail = table.Column(type: "nvarchar(max)", nullable: true), Memo = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Staff", x => x.Id); table.ForeignKey( name: "FK_Staff_StaffGrade", column: x => x.StaffGradeId, principalTable: "StaffGrade", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "VerifyCoefficient", columns: table => new { CheckerId = table.Column(type: "int", nullable: false), DoPersonId = table.Column(type: "int", nullable: false), Coefficient = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_VerifyCoefficient", x => new { x.CheckerId, x.DoPersonId }); table.ForeignKey( name: "FK_VerifyCoefficient_StaffGrade", column: x => x.CheckerId, principalTable: "StaffGrade", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_VerifyCoefficient_StaffGrade1", column: x => x.DoPersonId, principalTable: "StaffGrade", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "AttachFile", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), SavePath = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), UploadUserId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AttachFile", x => x.Id); table.ForeignKey( name: "FK_AttachFile_UpdateUser", column: x => x.UploadUserId, principalTable: "Staff", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Customer", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), ContactMan = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), Address = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), Phone = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), ResponseManId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Customer", x => x.Id); table.ForeignKey( name: "FK_Customer_Staff", column: x => x.ResponseManId, principalTable: "Staff", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Message", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), MessageInfo = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), Type = table.Column(type: "int", nullable: false), FromId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Message", x => x.Id); table.ForeignKey( name: "FK_From_Staff", column: x => x.FromId, principalTable: "Staff", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "PerformanceItem", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Year = table.Column(type: "int", nullable: false), Month = table.Column(type: "int", nullable: false), CaseNo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), ApplicationType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), BusinessType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), AgentFeedbackMemo = table.Column(type: "nvarchar(max)", nullable: true), DoItem = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), CaseStage = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), CaseCoefficient = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true), DoItemCoefficient = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), PreOAStaffId = table.Column(type: "int", nullable: true), ReviewerId = table.Column(type: "int", nullable: true), CustomerId = table.Column(type: "int", nullable: true), ApplicationName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), FinishedDate = table.Column(type: "date", nullable: true), FinalizationDate = table.Column(type: "date", nullable: true), ReturnDate = table.Column(type: "date", nullable: true), CaseType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), CaseState = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), DoItemMemo = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), DoItemState = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), CaseName = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), CustomerLimitDate = table.Column(type: "date", nullable: true), EntrustingDate = table.Column(type: "date", nullable: true), InternalDate = table.Column(type: "date", nullable: true), FirstDraftDate = table.Column(type: "date", nullable: true), OverDueMemo = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), BasePoint = table.Column(type: "numeric(18,2)", nullable: true), Status = table.Column(type: "int", nullable: true), CaseMemo = table.Column(type: "nvarchar(max)", nullable: true), CalMonthId = table.Column(type: "int", nullable: false), StaffId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_PerformanceItem", x => x.Id); table.ForeignKey( name: "FK_PerformanceItem_CalMonth", column: x => x.CalMonthId, principalTable: "CalMonth", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PerformanceItem_Customer", column: x => x.CustomerId, principalTable: "Customer", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_PerformanceItem_Reviewer", column: x => x.ReviewerId, principalTable: "Staff", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_PerformanceItem_Staff", column: x => x.PreOAStaffId, principalTable: "Staff", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_PerformanceItem_Staff_StaffId", column: x => x.StaffId, principalTable: "Staff", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "MessageReadRecord", columns: table => new { MessageId = table.Column(type: "uniqueidentifier", nullable: false), StaffId = table.Column(type: "int", nullable: false), isReaded = table.Column(type: "bit", nullable: false), MessageId1 = table.Column(type: "uniqueidentifier", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MessageReadRecord", x => new { x.MessageId, x.StaffId }); table.ForeignKey( name: "FK_MessageReadRecord_Message", column: x => x.MessageId, principalTable: "Message", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_MessageReadRecord_Message_MessageId1", column: x => x.MessageId1, principalTable: "Message", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_MessageReadRecord_Staff", column: x => x.StaffId, principalTable: "Staff", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ItemStaff", columns: table => new { ItemId = table.Column(type: "int", nullable: false), DoPersonId = table.Column(type: "int", nullable: false), PerformancePoint = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ItemStaff", x => new { x.ItemId, x.DoPersonId }); table.ForeignKey( name: "FK_ItemStaff_PerformanceItem", column: x => x.ItemId, principalTable: "PerformanceItem", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ItemStaff_Staff", column: x => x.DoPersonId, principalTable: "Staff", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "MessagePerformanceItems", columns: table => new { MessageId = table.Column(type: "uniqueidentifier", nullable: false), ItemId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MessagePerformanceItems", x => new { x.ItemId, x.MessageId }); table.ForeignKey( name: "FK_MessagePerformanceItem_Item", column: x => x.ItemId, principalTable: "PerformanceItem", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MessagePerformanceItem_Message", column: x => x.MessageId, principalTable: "Message", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "StaffGrade", columns: new[] { "Id", "Coefficient", "Grade" }, values: new object[,] { { 1, 1.2, "S级" }, { 2, 1.1000000000000001, "A3级" }, { 3, 1.1000000000000001, "A2级" }, { 4, 1.1000000000000001, "A1级" }, { 5, 1.0, "B3级" }, { 6, 1.0, "B2级" }, { 7, 0.90000000000000002, "B1级" }, { 8, 0.90000000000000002, "C3级" }, { 9, 0.69999999999999996, "C2级" }, { 10, 0.69999999999999996, "C1级" }, { 11, 0.59999999999999998, "D3级" }, { 12, 0.59999999999999998, "D2级" }, { 13, 0.5, "D1级" } }); migrationBuilder.InsertData( table: "VerifyCoefficient", columns: new[] { "CheckerId", "DoPersonId", "Coefficient" }, values: new object[,] { { 2, 5, 0.20000000000000001 }, { 2, 13, 0.5 }, { 4, 12, 0.40000000000000002 }, { 3, 12, 0.40000000000000002 }, { 2, 12, 0.40000000000000002 }, { 4, 11, 0.40000000000000002 }, { 3, 11, 0.40000000000000002 }, { 2, 11, 0.40000000000000002 }, { 4, 10, 0.29999999999999999 }, { 3, 10, 0.29999999999999999 }, { 2, 10, 0.29999999999999999 }, { 4, 9, 0.29999999999999999 }, { 3, 13, 0.5 }, { 3, 9, 0.29999999999999999 }, { 4, 8, 0.20000000000000001 }, { 3, 8, 0.20000000000000001 }, { 2, 8, 0.20000000000000001 }, { 4, 7, 0.20000000000000001 }, { 3, 7, 0.20000000000000001 }, { 2, 7, 0.20000000000000001 }, { 4, 6, 0.20000000000000001 }, { 3, 6, 0.20000000000000001 }, { 2, 6, 0.20000000000000001 }, { 4, 5, 0.20000000000000001 }, { 3, 5, 0.20000000000000001 }, { 2, 9, 0.29999999999999999 }, { 4, 13, 0.5 } }); migrationBuilder.CreateIndex( name: "IX_AttachFile_UploadUserId", table: "AttachFile", column: "UploadUserId"); migrationBuilder.CreateIndex( name: "IX_Customer_ResponseManId", table: "Customer", column: "ResponseManId"); migrationBuilder.CreateIndex( name: "IX_ItemStaff_DoPersonId", table: "ItemStaff", column: "DoPersonId"); migrationBuilder.CreateIndex( name: "IX_Message_FromId", table: "Message", column: "FromId"); migrationBuilder.CreateIndex( name: "IX_MessagePerformanceItems_MessageId", table: "MessagePerformanceItems", column: "MessageId"); migrationBuilder.CreateIndex( name: "IX_MessageReadRecord_MessageId1", table: "MessageReadRecord", column: "MessageId1"); migrationBuilder.CreateIndex( name: "IX_MessageReadRecord_StaffId", table: "MessageReadRecord", column: "StaffId"); migrationBuilder.CreateIndex( name: "IX_PerformanceItem_CalMonthId", table: "PerformanceItem", column: "CalMonthId"); migrationBuilder.CreateIndex( name: "IX_PerformanceItem_CustomerId", table: "PerformanceItem", column: "CustomerId"); migrationBuilder.CreateIndex( name: "IX_PerformanceItem_PreOAStaffId", table: "PerformanceItem", column: "PreOAStaffId"); migrationBuilder.CreateIndex( name: "IX_PerformanceItem_ReviewerId", table: "PerformanceItem", column: "ReviewerId"); migrationBuilder.CreateIndex( name: "IX_PerformanceItem_StaffId", table: "PerformanceItem", column: "StaffId"); migrationBuilder.CreateIndex( name: "IX_Staff_StaffGradeId", table: "Staff", column: "StaffGradeId"); migrationBuilder.CreateIndex( name: "IX_VerifyCoefficient_DoPersonId", table: "VerifyCoefficient", column: "DoPersonId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AttachFile"); migrationBuilder.DropTable( name: "BasePointRules"); migrationBuilder.DropTable( name: "ItemStaff"); migrationBuilder.DropTable( name: "MessagePerformanceItems"); migrationBuilder.DropTable( name: "MessageReadRecord"); migrationBuilder.DropTable( name: "VerifyCoefficient"); migrationBuilder.DropTable( name: "PerformanceItem"); migrationBuilder.DropTable( name: "Message"); migrationBuilder.DropTable( name: "CalMonth"); migrationBuilder.DropTable( name: "Customer"); migrationBuilder.DropTable( name: "Staff"); migrationBuilder.DropTable( name: "StaffGrade"); } } }