|
@@ -0,0 +1,400 @@
|
|
|
+namespace EVCB_OCPP.Domain.MainDBContextMigrations
|
|
|
+{
|
|
|
+ using System;
|
|
|
+ using System.Data.Entity.Migrations;
|
|
|
+
|
|
|
+ public partial class Init : DbMigration
|
|
|
+ {
|
|
|
+ public override void Up()
|
|
|
+ {
|
|
|
+ CreateTable(
|
|
|
+ "dbo.ApiLogEntry",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ ApiLogEntryId = c.Long(nullable: false, identity: true),
|
|
|
+ Application = c.String(),
|
|
|
+ User = c.String(),
|
|
|
+ Machine = c.String(),
|
|
|
+ RequestIpAddress = c.String(),
|
|
|
+ RequestContentType = c.String(),
|
|
|
+ RequestContentBody = c.String(),
|
|
|
+ RequestUri = c.String(),
|
|
|
+ RequestMethod = c.String(),
|
|
|
+ RequestRouteTemplate = c.String(),
|
|
|
+ RequestRouteData = c.String(),
|
|
|
+ RequestHeaders = c.String(),
|
|
|
+ RequestTimestamp = c.DateTime(),
|
|
|
+ ResponseContentType = c.String(),
|
|
|
+ ResponseContentBody = c.String(),
|
|
|
+ ResponseStatusCode = c.Int(),
|
|
|
+ ResponseHeaders = c.String(),
|
|
|
+ ResponseTimestamp = c.DateTime(),
|
|
|
+ IsOutData = c.Boolean(nullable: false),
|
|
|
+ ErrorMsg = c.String(),
|
|
|
+ ErrorOn = c.DateTime(),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.ApiLogEntryId)
|
|
|
+ .Index(t => t.RequestTimestamp);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.ConnectorStatus",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.String(nullable: false, maxLength: 36),
|
|
|
+ ChargePointSerialNumber = c.String(maxLength: 25),
|
|
|
+ ConnectorId = c.Byte(nullable: false),
|
|
|
+ Status = c.Int(nullable: false),
|
|
|
+ ChargePointErrorCodeNo = c.Int(nullable: false),
|
|
|
+ ErrorInfo = c.String(maxLength: 50),
|
|
|
+ VendorId = c.String(maxLength: 255),
|
|
|
+ VendorErrorCodeNo = c.Int(nullable: false),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.Customer",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Guid(nullable: false),
|
|
|
+ Name = c.String(maxLength: 50),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ CreatedBy = c.String(maxLength: 50),
|
|
|
+ Deadline = c.DateTime(),
|
|
|
+ UpdatedOn = c.DateTime(),
|
|
|
+ UpdatedBy = c.String(maxLength: 50),
|
|
|
+ ApiUrl = c.String(maxLength: 256),
|
|
|
+ ApiKey = c.String(maxLength: 128),
|
|
|
+ ApiKeyUpdatedOn = c.DateTime(),
|
|
|
+ PartnerId = c.String(maxLength: 36),
|
|
|
+ ApiCustomerId = c.String(maxLength: 36),
|
|
|
+ CallPartnerApiOnSchedule = c.Boolean(nullable: false),
|
|
|
+ IsShow = c.Boolean(nullable: false),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.CustomerMachineComponent",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ CustomerId = c.Guid(nullable: false),
|
|
|
+ MachineComponentId = c.Int(nullable: false),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ CreatedBy = c.String(maxLength: 50),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id)
|
|
|
+ .ForeignKey("dbo.Customer", t => t.CustomerId, cascadeDelete: true)
|
|
|
+ .ForeignKey("dbo.MachineComponent", t => t.MachineComponentId, cascadeDelete: true)
|
|
|
+ .Index(t => t.CustomerId)
|
|
|
+ .Index(t => t.MachineComponentId);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.MachineComponent",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ MachineModelId = c.Int(nullable: false),
|
|
|
+ GunAmt = c.Int(),
|
|
|
+ MachinePartId = c.Int(nullable: false),
|
|
|
+ ModelName = c.String(),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id)
|
|
|
+ .ForeignKey("dbo.MachineModel", t => t.MachineModelId, cascadeDelete: true)
|
|
|
+ .ForeignKey("dbo.MachinePart", t => t.MachinePartId, cascadeDelete: true)
|
|
|
+ .Index(t => t.MachineModelId)
|
|
|
+ .Index(t => t.MachinePartId);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.MachineModel",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ Name = c.String(maxLength: 36),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.MachinePart",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false),
|
|
|
+ Desc = c.String(maxLength: 36),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.Machine",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.String(nullable: false, maxLength: 36),
|
|
|
+ ChargePointSerialNumber = c.String(maxLength: 25),
|
|
|
+ ChargeBoxSerialNumber = c.String(maxLength: 25),
|
|
|
+ ChargePointModel = c.String(maxLength: 20),
|
|
|
+ ChargePointVendor = c.String(maxLength: 20),
|
|
|
+ Iccid = c.String(maxLength: 20),
|
|
|
+ Imsi = c.String(maxLength: 20),
|
|
|
+ MeterType = c.String(maxLength: 25),
|
|
|
+ MeterSerialNumber = c.String(maxLength: 25),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ CreatedBy = c.String(maxLength: 50),
|
|
|
+ Comment = c.String(maxLength: 100),
|
|
|
+ CustomerId = c.Guid(nullable: false),
|
|
|
+ AC = c.Boolean(nullable: false),
|
|
|
+ GunAmt = c.Int(nullable: false),
|
|
|
+ HeartbeatUpdatedOn = c.DateTime(),
|
|
|
+ FW_VersionReport = c.Int(),
|
|
|
+ FW_AssignedVersion = c.Int(),
|
|
|
+ FW_AssignedMachineVersionId = c.Int(),
|
|
|
+ Online = c.Boolean(nullable: false),
|
|
|
+ WattId = c.Int(nullable: false),
|
|
|
+ MachineModelId = c.Int(nullable: false),
|
|
|
+ MachinePartId = c.Int(nullable: false),
|
|
|
+ OfflineOn = c.DateTime(),
|
|
|
+ FW_CurrentVersion = c.String(maxLength: 50),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id)
|
|
|
+ .ForeignKey("dbo.Customer", t => t.CustomerId, cascadeDelete: true)
|
|
|
+ .ForeignKey("dbo.MachineVersion", t => t.FW_AssignedMachineVersionId)
|
|
|
+ .ForeignKey("dbo.MachineModel", t => t.MachineModelId, cascadeDelete: true)
|
|
|
+ .ForeignKey("dbo.MachinePart", t => t.MachinePartId, cascadeDelete: true)
|
|
|
+ .Index(t => t.ChargePointSerialNumber, unique: true)
|
|
|
+ .Index(t => t.CustomerId)
|
|
|
+ .Index(t => t.FW_AssignedMachineVersionId)
|
|
|
+ .Index(t => t.MachineModelId)
|
|
|
+ .Index(t => t.MachinePartId);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.MachineVersion",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ PublishVersionId = c.Int(nullable: false),
|
|
|
+ MachineId = c.String(nullable: false, maxLength: 36),
|
|
|
+ UpdatedOn = c.DateTime(),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id)
|
|
|
+ .ForeignKey("dbo.Machine", t => t.MachineId, cascadeDelete: true)
|
|
|
+ .ForeignKey("dbo.PublishVersion", t => t.PublishVersionId, cascadeDelete: true)
|
|
|
+ .Index(t => t.PublishVersionId)
|
|
|
+ .Index(t => t.MachineId);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.MachineVersionFile",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ UpdatedOn = c.DateTime(),
|
|
|
+ MachineVersionId = c.Int(nullable: false),
|
|
|
+ UploadFileId = c.Guid(nullable: false),
|
|
|
+ DownloadedOn = c.DateTime(),
|
|
|
+ Seq = c.Int(nullable: false),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id)
|
|
|
+ .ForeignKey("dbo.MachineVersion", t => t.MachineVersionId, cascadeDelete: true)
|
|
|
+ .ForeignKey("dbo.UploadFile", t => t.UploadFileId, cascadeDelete: true)
|
|
|
+ .Index(t => t.MachineVersionId)
|
|
|
+ .Index(t => t.UploadFileId);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.UploadFile",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Guid(nullable: false),
|
|
|
+ FileName = c.String(nullable: false, maxLength: 500),
|
|
|
+ OriginName = c.String(nullable: false, maxLength: 500),
|
|
|
+ FileSize = c.Int(nullable: false),
|
|
|
+ FileType = c.String(maxLength: 200),
|
|
|
+ FileExtensionName = c.String(maxLength: 50),
|
|
|
+ FilePath = c.String(nullable: false, maxLength: 500),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ CreatedBy = c.String(maxLength: 50),
|
|
|
+ IsOnline = c.Boolean(nullable: false),
|
|
|
+ CustomerId = c.Guid(nullable: false),
|
|
|
+ FileMD5 = c.String(maxLength: 50),
|
|
|
+ FileUrl = c.String(maxLength: 512),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.PublishVersion",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ Version = c.Int(nullable: false),
|
|
|
+ CustomerMachineComponentId = c.Int(nullable: false),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id)
|
|
|
+ .ForeignKey("dbo.CustomerMachineComponent", t => t.CustomerMachineComponentId)
|
|
|
+ .Index(t => t.CustomerMachineComponentId);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.PublishVersionFile",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ PublishVersionId = c.Int(nullable: false),
|
|
|
+ UploadFileId = c.Guid(nullable: false),
|
|
|
+ Seq = c.Int(nullable: false),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id)
|
|
|
+ .ForeignKey("dbo.PublishVersion", t => t.PublishVersionId, cascadeDelete: true)
|
|
|
+ .ForeignKey("dbo.UploadFile", t => t.UploadFileId, cascadeDelete: true)
|
|
|
+ .Index(t => t.PublishVersionId)
|
|
|
+ .Index(t => t.UploadFileId);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.MachineConfigures",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ ChargePointSerialNumber = c.String(maxLength: 25),
|
|
|
+ ConfigureName = c.String(maxLength: 50),
|
|
|
+ ConfigureSetting = c.String(maxLength: 500),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.MachineError",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ ChargePointSerialNumber = c.String(maxLength: 25),
|
|
|
+ ConnectorId = c.Byte(nullable: false),
|
|
|
+ PreStatus = c.Int(nullable: false),
|
|
|
+ Status = c.Int(nullable: false),
|
|
|
+ ErrorCode = c.Int(nullable: false),
|
|
|
+ ErrorInfo = c.String(maxLength: 50),
|
|
|
+ VendorId = c.String(maxLength: 255),
|
|
|
+ VendorErrorCodeNum = c.Int(nullable: false),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.MachineOperateRecord",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ ChargePointSerialNumber = c.String(maxLength: 25),
|
|
|
+ SerialNo = c.String(maxLength: 36),
|
|
|
+ RequestType = c.Int(nullable: false),
|
|
|
+ RequestContent = c.String(maxLength: 36),
|
|
|
+ Status = c.Int(nullable: false),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ FinishedOn = c.DateTime(nullable: false),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.ServerCommand",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Int(nullable: false, identity: true),
|
|
|
+ ChargePointSerialNumber = c.String(maxLength: 25),
|
|
|
+ SerialNo = c.String(maxLength: 36),
|
|
|
+ OutMessage = c.String(),
|
|
|
+ InMessage = c.String(),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ CreatedBy = c.String(),
|
|
|
+ ReceivedOn = c.DateTime(),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id);
|
|
|
+
|
|
|
+ CreateTable(
|
|
|
+ "dbo.TransactionRecord",
|
|
|
+ c => new
|
|
|
+ {
|
|
|
+ Id = c.Long(nullable: false, identity: true),
|
|
|
+ CustomerId = c.Guid(nullable: false),
|
|
|
+ MachineId = c.String(nullable: false, maxLength: 36),
|
|
|
+ ConnectorId = c.Byte(nullable: false),
|
|
|
+ TransactionId = c.Int(nullable: false),
|
|
|
+ chargePointSerialNumber = c.String(maxLength: 25),
|
|
|
+ IdTag = c.String(maxLength: 20),
|
|
|
+ StartTime = c.DateTime(nullable: false),
|
|
|
+ StopTime = c.DateTime(nullable: false),
|
|
|
+ StopTransactionReasonId = c.Int(nullable: false),
|
|
|
+ MeterStart = c.Decimal(nullable: false, precision: 18, scale: 2),
|
|
|
+ MeterStop = c.Decimal(nullable: false, precision: 18, scale: 2),
|
|
|
+ SOCStart = c.Decimal(nullable: false, precision: 18, scale: 2),
|
|
|
+ SOCStop = c.Decimal(nullable: false, precision: 18, scale: 2),
|
|
|
+ ReportedOn = c.DateTime(),
|
|
|
+ CreatedOn = c.DateTime(nullable: false),
|
|
|
+ UpdatedOn = c.DateTime(),
|
|
|
+ StartTransactionReportedOn = c.DateTime(nullable: false),
|
|
|
+ RetryStartTransactionTimes = c.Int(nullable: false),
|
|
|
+ StopTransactionReportedOn = c.DateTime(nullable: false),
|
|
|
+ RtryStopTransactionTimes = c.Int(nullable: false),
|
|
|
+ ErrorMsg = c.String(),
|
|
|
+ })
|
|
|
+ .PrimaryKey(t => t.Id)
|
|
|
+ .ForeignKey("dbo.Machine", t => t.MachineId, cascadeDelete: true)
|
|
|
+ .Index(t => new { t.MachineId, t.ConnectorId, t.TransactionId, t.StartTime }, unique: true, name: "IX_1202_Issue_Report")
|
|
|
+ .Index(t => t.MachineId)
|
|
|
+ .Index(t => t.TransactionId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void Down()
|
|
|
+ {
|
|
|
+ DropForeignKey("dbo.TransactionRecord", "MachineId", "dbo.Machine");
|
|
|
+ DropForeignKey("dbo.Machine", "MachinePartId", "dbo.MachinePart");
|
|
|
+ DropForeignKey("dbo.Machine", "MachineModelId", "dbo.MachineModel");
|
|
|
+ DropForeignKey("dbo.Machine", "FW_AssignedMachineVersionId", "dbo.MachineVersion");
|
|
|
+ DropForeignKey("dbo.MachineVersion", "PublishVersionId", "dbo.PublishVersion");
|
|
|
+ DropForeignKey("dbo.PublishVersionFile", "UploadFileId", "dbo.UploadFile");
|
|
|
+ DropForeignKey("dbo.PublishVersionFile", "PublishVersionId", "dbo.PublishVersion");
|
|
|
+ DropForeignKey("dbo.PublishVersion", "CustomerMachineComponentId", "dbo.CustomerMachineComponent");
|
|
|
+ DropForeignKey("dbo.MachineVersionFile", "UploadFileId", "dbo.UploadFile");
|
|
|
+ DropForeignKey("dbo.MachineVersionFile", "MachineVersionId", "dbo.MachineVersion");
|
|
|
+ DropForeignKey("dbo.MachineVersion", "MachineId", "dbo.Machine");
|
|
|
+ DropForeignKey("dbo.Machine", "CustomerId", "dbo.Customer");
|
|
|
+ DropForeignKey("dbo.CustomerMachineComponent", "MachineComponentId", "dbo.MachineComponent");
|
|
|
+ DropForeignKey("dbo.MachineComponent", "MachinePartId", "dbo.MachinePart");
|
|
|
+ DropForeignKey("dbo.MachineComponent", "MachineModelId", "dbo.MachineModel");
|
|
|
+ DropForeignKey("dbo.CustomerMachineComponent", "CustomerId", "dbo.Customer");
|
|
|
+ DropIndex("dbo.TransactionRecord", new[] { "TransactionId" });
|
|
|
+ DropIndex("dbo.TransactionRecord", new[] { "MachineId" });
|
|
|
+ DropIndex("dbo.TransactionRecord", "IX_1202_Issue_Report");
|
|
|
+ DropIndex("dbo.PublishVersionFile", new[] { "UploadFileId" });
|
|
|
+ DropIndex("dbo.PublishVersionFile", new[] { "PublishVersionId" });
|
|
|
+ DropIndex("dbo.PublishVersion", new[] { "CustomerMachineComponentId" });
|
|
|
+ DropIndex("dbo.MachineVersionFile", new[] { "UploadFileId" });
|
|
|
+ DropIndex("dbo.MachineVersionFile", new[] { "MachineVersionId" });
|
|
|
+ DropIndex("dbo.MachineVersion", new[] { "MachineId" });
|
|
|
+ DropIndex("dbo.MachineVersion", new[] { "PublishVersionId" });
|
|
|
+ DropIndex("dbo.Machine", new[] { "MachinePartId" });
|
|
|
+ DropIndex("dbo.Machine", new[] { "MachineModelId" });
|
|
|
+ DropIndex("dbo.Machine", new[] { "FW_AssignedMachineVersionId" });
|
|
|
+ DropIndex("dbo.Machine", new[] { "CustomerId" });
|
|
|
+ DropIndex("dbo.Machine", new[] { "ChargePointSerialNumber" });
|
|
|
+ DropIndex("dbo.MachineComponent", new[] { "MachinePartId" });
|
|
|
+ DropIndex("dbo.MachineComponent", new[] { "MachineModelId" });
|
|
|
+ DropIndex("dbo.CustomerMachineComponent", new[] { "MachineComponentId" });
|
|
|
+ DropIndex("dbo.CustomerMachineComponent", new[] { "CustomerId" });
|
|
|
+ DropIndex("dbo.ApiLogEntry", new[] { "RequestTimestamp" });
|
|
|
+ DropTable("dbo.TransactionRecord");
|
|
|
+ DropTable("dbo.ServerCommand");
|
|
|
+ DropTable("dbo.MachineOperateRecord");
|
|
|
+ DropTable("dbo.MachineError");
|
|
|
+ DropTable("dbo.MachineConfigures");
|
|
|
+ DropTable("dbo.PublishVersionFile");
|
|
|
+ DropTable("dbo.PublishVersion");
|
|
|
+ DropTable("dbo.UploadFile");
|
|
|
+ DropTable("dbo.MachineVersionFile");
|
|
|
+ DropTable("dbo.MachineVersion");
|
|
|
+ DropTable("dbo.Machine");
|
|
|
+ DropTable("dbo.MachinePart");
|
|
|
+ DropTable("dbo.MachineModel");
|
|
|
+ DropTable("dbo.MachineComponent");
|
|
|
+ DropTable("dbo.CustomerMachineComponent");
|
|
|
+ DropTable("dbo.Customer");
|
|
|
+ DropTable("dbo.ConnectorStatus");
|
|
|
+ DropTable("dbo.ApiLogEntry");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|