using System; using Microsoft.EntityFrameworkCore.Migrations; namespace Application.ATG_Classic_App.Migrations { public partial class init : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Alarms", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), Priority = table.Column(nullable: false), TankNumber = table.Column(nullable: false), Type = table.Column(nullable: false), Description = table.Column(nullable: true), CreatedTimeStamp = table.Column(nullable: false), ClearedTimeStamp = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Alarms", x => x.Id); }); migrationBuilder.CreateTable( name: "Deliveries", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), TankNumber = table.Column(nullable: false), StartingDateTime = table.Column(nullable: false), StartingFuelHeight = table.Column(nullable: false), StartingFuelVolume = table.Column(nullable: false), StartingFuelTCVolume = table.Column(nullable: false), StartingWaterHeight = table.Column(nullable: false), StartingWaterVolume = table.Column(nullable: false), StartingTemperture = table.Column(nullable: false), EndingDateTime = table.Column(nullable: true), EndingFuelHeight = table.Column(nullable: true), EndingFuelVolume = table.Column(nullable: true), EndingFuelTCVolume = table.Column(nullable: true), EndingWaterHeight = table.Column(nullable: true), EndingWaterVolume = table.Column(nullable: true), EndingTemperture = table.Column(nullable: true), Description = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Deliveries", x => x.Id); }); migrationBuilder.CreateTable( name: "Inventories", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), TankNumber = table.Column(nullable: false), TimeStamp = table.Column(nullable: false), FuelHeight = table.Column(nullable: false), FuelVolume = table.Column(nullable: false), FuelTCVolume = table.Column(nullable: false), WaterHeight = table.Column(nullable: false), Temperture = table.Column(nullable: false), Description = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Inventories", x => x.Id); }); migrationBuilder.CreateTable( name: "ProbeConfigs", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), CreatedTimeStamp = table.Column(nullable: false), ModifiedTimeStamp = table.Column(nullable: true), DeviceId = table.Column(nullable: false), ProbeOffset = table.Column(nullable: false), WaterOffset = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_ProbeConfigs", x => x.Id); }); migrationBuilder.CreateTable( name: "ProductConfigs", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), CreatedTimeStamp = table.Column(nullable: false), ModifiedTimeStamp = table.Column(nullable: true), ProductCode = table.Column(nullable: false), ProductLabel = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ProductConfigs", x => x.Id); }); migrationBuilder.CreateTable( name: "TankLimitConfigs", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), CreatedTimeStamp = table.Column(nullable: false), ModifiedTimeStamp = table.Column(nullable: true), MaxVolume = table.Column(nullable: false), FullVolume = table.Column(nullable: false), HighProduct = table.Column(nullable: false), LowProduct = table.Column(nullable: false), HighWaterWarning = table.Column(nullable: false), HighWaterAlarm = table.Column(nullable: false), FuelTemperatureLowLimit = table.Column(nullable: false), FuelTemperatureHighLimit = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_TankLimitConfigs", x => x.Id); }); migrationBuilder.CreateTable( name: "TankOverallConfigs", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), CreatedTimeStamp = table.Column(nullable: false), ModifiedTimeStamp = table.Column(nullable: true), TcReference = table.Column(nullable: false), InventorySamplingInterval = table.Column(nullable: false), DeliveryMode = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_TankOverallConfigs", x => x.Id); }); migrationBuilder.CreateTable( name: "TankConfigs", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), CreatedTimeStamp = table.Column(nullable: false), ModifiedTimeStamp = table.Column(nullable: true), TankNumber = table.Column(nullable: false), Label = table.Column(nullable: true), Diameter = table.Column(nullable: false), ThermalCoefficient = table.Column(nullable: false), DeliveryDelay = table.Column(nullable: false), ProductConfigId = table.Column(nullable: true), TankLimitConfigId = table.Column(nullable: true), ProbeConfigId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_TankConfigs", x => x.Id); table.ForeignKey( name: "FK_TankConfigs_ProbeConfigs_ProbeConfigId", column: x => x.ProbeConfigId, principalTable: "ProbeConfigs", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TankConfigs_ProductConfigs_ProductConfigId", column: x => x.ProductConfigId, principalTable: "ProductConfigs", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TankConfigs_TankLimitConfigs_TankLimitConfigId", column: x => x.TankLimitConfigId, principalTable: "TankLimitConfigs", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "TankProfileDatas", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), BatchLabel = table.Column(nullable: true), TankConfigId = table.Column(nullable: false), Height = table.Column(nullable: false), Volume = table.Column(nullable: false), VolumeChange = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_TankProfileDatas", x => x.Id); table.ForeignKey( name: "FK_TankProfileDatas_TankConfigs_TankConfigId", column: x => x.TankConfigId, principalTable: "TankConfigs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Alarms_CreatedTimeStamp", table: "Alarms", column: "CreatedTimeStamp"); migrationBuilder.CreateIndex( name: "IX_Alarms_TankNumber", table: "Alarms", column: "TankNumber"); migrationBuilder.CreateIndex( name: "IX_Alarms_TankNumber_Type_Priority_ClearedTimeStamp", table: "Alarms", columns: new[] { "TankNumber", "Type", "Priority", "ClearedTimeStamp" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Alarms_TankNumber_Type_Priority_CreatedTimeStamp", table: "Alarms", columns: new[] { "TankNumber", "Type", "Priority", "CreatedTimeStamp" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Deliveries_TankNumber_StartingDateTime", table: "Deliveries", columns: new[] { "TankNumber", "StartingDateTime" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Inventories_TankNumber_TimeStamp", table: "Inventories", columns: new[] { "TankNumber", "TimeStamp" }, unique: true); migrationBuilder.CreateIndex( name: "IX_TankConfigs_ProbeConfigId", table: "TankConfigs", column: "ProbeConfigId"); migrationBuilder.CreateIndex( name: "IX_TankConfigs_ProductConfigId", table: "TankConfigs", column: "ProductConfigId"); migrationBuilder.CreateIndex( name: "IX_TankConfigs_TankLimitConfigId", table: "TankConfigs", column: "TankLimitConfigId"); migrationBuilder.CreateIndex( name: "IX_TankProfileDatas_TankConfigId", table: "TankProfileDatas", column: "TankConfigId"); migrationBuilder.CreateIndex( name: "IX_TankProfileDatas_BatchLabel_Height", table: "TankProfileDatas", columns: new[] { "BatchLabel", "Height" }, unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Alarms"); migrationBuilder.DropTable( name: "Deliveries"); migrationBuilder.DropTable( name: "Inventories"); migrationBuilder.DropTable( name: "TankOverallConfigs"); migrationBuilder.DropTable( name: "TankProfileDatas"); migrationBuilder.DropTable( name: "TankConfigs"); migrationBuilder.DropTable( name: "ProbeConfigs"); migrationBuilder.DropTable( name: "ProductConfigs"); migrationBuilder.DropTable( name: "TankLimitConfigs"); } } }