using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace EVCB_OCPP.Domain.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "__MigrationHistory", columns: table => new { MigrationId = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), ContextKey = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false), Model = table.Column(type: "varbinary(max)", nullable: false), ProductVersion = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false) }, constraints: table => { table.PrimaryKey("PK_dbo.__MigrationHistory", x => new { x.MigrationId, x.ContextKey }); }); migrationBuilder.CreateTable( name: "ConnectorMeterValueRecord", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ConnectorId = table.Column(type: "tinyint", nullable: false), Value = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true), CreatedOn = table.Column(type: "datetime", nullable: false), ContextId = table.Column(type: "int", nullable: false), FormatId = table.Column(type: "int", nullable: false), MeasurandId = table.Column(type: "int", nullable: false), PhaseId = table.Column(type: "int", nullable: false), LocationId = table.Column(type: "int", nullable: false), UnitId = table.Column(type: "int", nullable: false), ChargeBoxId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), TransactionId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_dbo.ConnectorMeterValueRecord", x => x.Id); }); migrationBuilder.CreateTable( name: "ConnectorStatus", columns: table => new { Id = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: false), ConnectorId = table.Column(type: "tinyint", nullable: false), Status = table.Column(type: "int", nullable: false), ErrorInfo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), VendorId = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), CreatedOn = table.Column(type: "datetime", nullable: false), VendorErrorCode = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), ChargePointErrorCodeId = table.Column(type: "int", nullable: false), ChargeBoxId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), TotalEnergy = table.Column(type: "decimal(10,2)", nullable: false), Type = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_dbo.ConnectorStatus", x => x.Id); }); migrationBuilder.CreateTable( name: "Customer", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), CreatedOn = table.Column(type: "datetime", nullable: false), CreatedBy = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), Deadline = table.Column(type: "datetime", nullable: true), UpdatedOn = table.Column(type: "datetime", nullable: true), UpdatedBy = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), ApiUrl = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), ApiKey = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), ApiKeyUpdatedOn = table.Column(type: "datetime", nullable: true), PartnerId = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true), ApiCustomerId = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true), CallPartnerApiOnSchedule = table.Column(type: "bit", nullable: false), IsShow = table.Column(type: "bit", nullable: false), FTPPath = table.Column(type: "nvarchar(max)", nullable: true), FTPHost = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), FTPUser = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), FTPPassword = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), EnableTTIA = table.Column(type: "bit", nullable: false), TTIA_EquipmentProvider = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true), TTIA_CustomerId = table.Column(type: "int", nullable: false), TTIA_APIUrl = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), TTIA_APIKey = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true), InstantStopTxReport = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_dbo.Customer", x => x.Id); }); migrationBuilder.CreateTable( name: "LoadingBalance", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), StationId = table.Column(type: "int", nullable: false), MachineId = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: false), Power = table.Column(type: "decimal(10,2)", nullable: false), CreatedOn = table.Column(type: "datetime", nullable: false), FinishedOn = table.Column(type: "datetime", nullable: false) }, constraints: table => { table.PrimaryKey("PK_LoadingBalance", x => x.Id); }); migrationBuilder.CreateTable( name: "MachineConfigurations", columns: table => new { ConfigureName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), ChargeBoxId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ConfigureSetting = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), ReadOnly = table.Column(type: "bit", nullable: false), Exists = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_dbo.MachineConfigurations", x => new { x.ConfigureName, x.ChargeBoxId }); }); migrationBuilder.CreateTable( name: "MachineError", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ConnectorId = table.Column(type: "tinyint", nullable: false), PreStatus = table.Column(type: "int", nullable: false), Status = table.Column(type: "int", nullable: false), ErrorInfo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), VendorId = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), CreatedOn = table.Column(type: "datetime", nullable: false), ErrorCodeId = table.Column(type: "int", nullable: false), VendorErrorCode = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), ChargeBoxId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_dbo.MachineError", x => x.Id); }); migrationBuilder.CreateTable( name: "MachineOperateRecord", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), SerialNo = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true), RequestType = table.Column(type: "int", nullable: false), RequestContent = table.Column(type: "nvarchar(max)", nullable: true), Status = table.Column(type: "int", nullable: false), CreatedOn = table.Column(type: "datetime", nullable: false), FinishedOn = table.Column(type: "datetime", nullable: false), EVSE_Value = table.Column(type: "nvarchar(max)", nullable: true), EVSE_Status = table.Column(type: "int", nullable: false), ChargeBoxId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), Action = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: true), ReportedOn = table.Column(type: "datetime", nullable: false) }, constraints: table => { table.PrimaryKey("PK_dbo.MachineOperateRecord", x => x.Id); }); migrationBuilder.CreateTable( name: "OCMF", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), TransactionId = table.Column(type: "int", nullable: false), DataString = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: true), PublicKey = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true) }, constraints: table => { table.PrimaryKey("PK_dbo.OCMF", x => x.Id); }); migrationBuilder.CreateTable( name: "ServerMessage", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), SerialNo = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true), OutAction = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: true), OutRequest = table.Column(type: "nvarchar(max)", nullable: true), InMessage = table.Column(type: "nvarchar(max)", nullable: true), CreatedOn = table.Column(type: "datetime", nullable: false), CreatedBy = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true), ReceivedOn = table.Column(type: "datetime", nullable: false), ChargeBoxId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), UpdatedOn = table.Column(type: "datetime", nullable: false) }, constraints: table => { table.PrimaryKey("PK_dbo.ServerMessage", x => x.Id); }); migrationBuilder.CreateTable( name: "TransactionRecord", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), StartTime = table.Column(type: "datetime", nullable: false), StopTime = table.Column(type: "datetime", nullable: false), CustomerId = table.Column(type: "uniqueidentifier", nullable: false), ConnectorId = table.Column(type: "tinyint", nullable: false), MeterStart = table.Column(type: "decimal(18,2)", nullable: false), MeterStop = table.Column(type: "decimal(18,2)", nullable: false), CreatedOn = table.Column(type: "datetime", nullable: false), UpdatedOn = table.Column(type: "datetime", nullable: false), StartTransactionReportedOn = table.Column(type: "datetime", nullable: false), RetryStartTransactionTimes = table.Column(type: "int", nullable: false), StopTransactionReportedOn = table.Column(type: "datetime", nullable: false), ErrorMsg = table.Column(type: "nvarchar(max)", nullable: true), StartIdTag = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), StopIdTag = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), ReservationId = table.Column(type: "int", nullable: false), StopReasonId = table.Column(type: "int", nullable: false), ChargeBoxId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), RetryStopTransactionTimes = table.Column(type: "int", nullable: false), UploadedtoTTIA = table.Column(type: "bit", nullable: false), Cost = table.Column(type: "decimal(18,2)", nullable: false), Fee = table.Column(type: "nvarchar(1500)", maxLength: 1500, nullable: true), Receipt = table.Column(type: "nvarchar(3000)", maxLength: 3000, nullable: true), BillingDone = table.Column(type: "bit", nullable: false), StopReason = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: true), StartSOC = table.Column(type: "nvarchar(3)", maxLength: 3, nullable: true), StopSOC = table.Column(type: "nvarchar(3)", maxLength: 3, nullable: true), NotifyPnC = table.Column(type: "bit", nullable: false), EVCCID = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: true) }, constraints: table => { table.PrimaryKey("PK_dbo.TransactionRecord", x => x.Id); }); migrationBuilder.CreateTable( name: "UploadFile", columns: table => new { Id = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: false), FileName = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), OriginName = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), FileSize = table.Column(type: "int", nullable: false), FileType = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), FileExtensionName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), FilePath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), CreatedOn = table.Column(type: "datetime", nullable: false), CreatedBy = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), FileMD5 = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), FileUrl = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), VendorId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), ModelName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), ModuleId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_dbo.UploadFile", x => x.Id); }); migrationBuilder.CreateTable( name: "Machine", columns: table => new { Id = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: false), ChargePointSerialNumber = table.Column(type: "nvarchar(25)", maxLength: 25, nullable: true), ChargeBoxSerialNumber = table.Column(type: "nvarchar(25)", maxLength: 25, nullable: true), ChargePointModel = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), ChargePointVendor = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), Iccid = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), Imsi = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), MeterType = table.Column(type: "nvarchar(25)", maxLength: 25, nullable: true), MeterSerialNumber = table.Column(type: "nvarchar(25)", maxLength: 25, nullable: true), CreatedOn = table.Column(type: "datetime", nullable: false), CreatedBy = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), Comment = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), CustomerId = table.Column(type: "uniqueidentifier", nullable: false), GunAmt = table.Column(type: "int", nullable: false), HeartbeatUpdatedOn = table.Column(type: "datetime", nullable: false), FW_VersionReport = table.Column(type: "int", nullable: true), FW_AssignedVersion = table.Column(type: "int", nullable: true), Online = table.Column(type: "bit", nullable: false), OfflineOn = table.Column(type: "datetime", nullable: true), FW_CurrentVersion = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), ChargeBoxId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), ConnectionType = table.Column(type: "int", nullable: false), RatedPower = table.Column(type: "decimal(6,2)", nullable: false), ConnectorType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), ConnectorPowerType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), Latitude = table.Column(type: "decimal(10,6)", nullable: false), Longitude = table.Column(type: "decimal(10,6)", nullable: false), VendorId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true, defaultValueSql: "('Zerova')"), ModelName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false, defaultValueSql: "('')"), BoardVersions = table.Column(type: "nvarchar(max)", nullable: true), IsDelete = table.Column(type: "bit", nullable: false), TTIATag = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_dbo.Machine", x => x.Id); table.ForeignKey( name: "FK_dbo.Machine_dbo.Customer_CustomerId", column: x => x.CustomerId, principalTable: "Customer", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MachineVersionFile", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CreatedOn = table.Column(type: "datetime", nullable: false), UploadFileId = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: false), Seq = table.Column(type: "int", nullable: false), ChargeBoxId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_dbo.MachineVersionFile", x => x.Id); table.ForeignKey( name: "FK_dbo.MachineVersionFile_dbo.UploadFile_UploadFileId", column: x => x.UploadFileId, principalTable: "UploadFile", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_ConnectorStatus", table: "ConnectorStatus", columns: new[] { "ChargeBoxId", "ConnectorId" }, unique: true, filter: "[ChargeBoxId] IS NOT NULL"); migrationBuilder.CreateIndex( name: "nci_wi_Machine_7CD4A9D1688F96F6967B2244A0666F62", table: "Machine", columns: new[] { "CustomerId", "ChargeBoxId" }); migrationBuilder.CreateIndex( name: "nci_wi_MachineConfigurations_132E765C043BF95A2570D2EA019DD783", table: "MachineConfigurations", columns: new[] { "ConfigureName", "ConfigureSetting" }); migrationBuilder.CreateIndex( name: "IX_MachineVersionFile_UploadFileId", table: "MachineVersionFile", column: "UploadFileId"); migrationBuilder.CreateIndex( name: "nci_wi_ServerMessage_EC00C205420F6CB01974705B93F9507F", table: "ServerMessage", columns: new[] { "ReceivedOn", "UpdatedOn", "CreatedOn" }); migrationBuilder.CreateIndex( name: "IX_TransactionRecord_StartTime", table: "TransactionRecord", columns: new[] { "CustomerId", "ConnectorId", "StartTime", "ChargeBoxId" }); migrationBuilder.CreateIndex( name: "nci_wi_TransactionRecord_92D4DF08E7034102014AC91760F890FE", table: "TransactionRecord", columns: new[] { "CustomerId", "StopTransactionReportedOn", "StopTime" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "__MigrationHistory"); migrationBuilder.DropTable( name: "ConnectorMeterValueRecord"); migrationBuilder.DropTable( name: "ConnectorStatus"); migrationBuilder.DropTable( name: "LoadingBalance"); migrationBuilder.DropTable( name: "Machine"); migrationBuilder.DropTable( name: "MachineConfigurations"); migrationBuilder.DropTable( name: "MachineError"); migrationBuilder.DropTable( name: "MachineOperateRecord"); migrationBuilder.DropTable( name: "MachineVersionFile"); migrationBuilder.DropTable( name: "OCMF"); migrationBuilder.DropTable( name: "ServerMessage"); migrationBuilder.DropTable( name: "TransactionRecord"); migrationBuilder.DropTable( name: "Customer"); migrationBuilder.DropTable( name: "UploadFile"); } } }