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