using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ClassNotify.Server.Data.Migrations
{
///
public partial class AddReliabilityBaselineAndCorrelation : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "CorrelationId",
table: "Notifications",
type: "character varying(32)",
maxLength: 32,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn(
name: "Architecture",
table: "Devices",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "ClientVersion",
table: "Devices",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "LastHeartbeatCorrelationId",
table: "Devices",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "OsVersion",
table: "Devices",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "ProtocolVersion",
table: "Devices",
type: "integer",
nullable: true);
migrationBuilder.AddColumn(
name: "ServiceVersion",
table: "Devices",
type: "text",
nullable: true);
migrationBuilder.CreateTable(
name: "DeviceSelfChecks",
columns: table => new
{
Id = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
TenantId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
DeviceId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
CorrelationId = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
Status = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
RequestedAtUtc = table.Column(type: "timestamp with time zone", nullable: false),
CompletedAtUtc = table.Column(type: "timestamp with time zone", nullable: true),
ResultJson = table.Column(type: "character varying(32768)", maxLength: 32768, nullable: true),
RequestedByUserId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceSelfChecks", x => x.Id);
table.ForeignKey(
name: "FK_DeviceSelfChecks_Devices_DeviceId",
column: x => x.DeviceId,
principalTable: "Devices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DeviceSelfChecks_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Notifications_CorrelationId",
table: "Notifications",
column: "CorrelationId");
migrationBuilder.CreateIndex(
name: "IX_DeviceSelfChecks_CorrelationId",
table: "DeviceSelfChecks",
column: "CorrelationId");
migrationBuilder.CreateIndex(
name: "IX_DeviceSelfChecks_DeviceId_RequestedAtUtc",
table: "DeviceSelfChecks",
columns: new[] { "DeviceId", "RequestedAtUtc" },
descending: new[] { false, true });
migrationBuilder.CreateIndex(
name: "IX_DeviceSelfChecks_TenantId_Status",
table: "DeviceSelfChecks",
columns: new[] { "TenantId", "Status" });
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DeviceSelfChecks");
migrationBuilder.DropIndex(
name: "IX_Notifications_CorrelationId",
table: "Notifications");
migrationBuilder.DropColumn(
name: "CorrelationId",
table: "Notifications");
migrationBuilder.DropColumn(
name: "Architecture",
table: "Devices");
migrationBuilder.DropColumn(
name: "ClientVersion",
table: "Devices");
migrationBuilder.DropColumn(
name: "LastHeartbeatCorrelationId",
table: "Devices");
migrationBuilder.DropColumn(
name: "OsVersion",
table: "Devices");
migrationBuilder.DropColumn(
name: "ProtocolVersion",
table: "Devices");
migrationBuilder.DropColumn(
name: "ServiceVersion",
table: "Devices");
}
}
}