161 lines
8.6 KiB
C#
161 lines
8.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace DD.Persistence.Database.Postgres.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ChangeLog",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ записи"),
|
|
IdDiscriminator = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор таблицы"),
|
|
IdAuthor = table.Column<Guid>(type: "uuid", nullable: false, comment: "Автор изменения"),
|
|
IdEditor = table.Column<Guid>(type: "uuid", nullable: true, comment: "Редактор"),
|
|
Creation = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата создания записи"),
|
|
Obsolete = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true, comment: "Дата устаревания (например при удалении)"),
|
|
IdNext = table.Column<Guid>(type: "uuid", nullable: true, comment: "Id заменяющей записи"),
|
|
DepthStart = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина забоя на дату начала интервала"),
|
|
DepthEnd = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина забоя на дату окончания интервала"),
|
|
IdSection = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ секции"),
|
|
Value = table.Column<string>(type: "jsonb", nullable: false, comment: "Значение")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ChangeLog", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DataSourceSystem",
|
|
columns: table => new
|
|
{
|
|
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы - источника данных"),
|
|
Name = table.Column<string>(type: "varchar(256)", nullable: false, comment: "Наименование системы - источника данных"),
|
|
Description = table.Column<string>(type: "text", nullable: true, comment: "Описание системы - источника данных")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ParameterData",
|
|
columns: table => new
|
|
{
|
|
DiscriminatorId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
|
|
ParameterId = table.Column<int>(type: "integer", nullable: false, comment: "Id параметра"),
|
|
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"),
|
|
Value = table.Column<string>(type: "varchar(256)", nullable: false, comment: "Значение параметра в виде строки")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp });
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Setpoint",
|
|
columns: table => new
|
|
{
|
|
Key = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ"),
|
|
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата создания уставки"),
|
|
Value = table.Column<object>(type: "jsonb", nullable: false, comment: "Значение уставки"),
|
|
IdUser = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id автора последнего изменения")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Timestamp });
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ValuesIdentities",
|
|
columns: table => new
|
|
{
|
|
DiscriminatorId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
|
|
Identity = table.Column<string[]>(type: "jsonb", nullable: false, comment: "Идентификаторы")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ValuesIdentities", x => x.DiscriminatorId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TechMessage",
|
|
columns: table => new
|
|
{
|
|
EventId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id события"),
|
|
CategoryId = table.Column<int>(type: "integer", nullable: false, comment: "Id Категории важности"),
|
|
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата возникновения"),
|
|
Text = table.Column<string>(type: "varchar(512)", nullable: false, comment: "Текст сообщения"),
|
|
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы, к которой относится сообщение"),
|
|
EventState = table.Column<int>(type: "integer", nullable: false, comment: "Статус события")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_TechMessage", x => x.EventId);
|
|
table.ForeignKey(
|
|
name: "FK_TechMessage_DataSourceSystem_SystemId",
|
|
column: x => x.SystemId,
|
|
principalTable: "DataSourceSystem",
|
|
principalColumn: "SystemId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TimestampedValues",
|
|
columns: table => new
|
|
{
|
|
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"),
|
|
DiscriminatorId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
|
|
Values = table.Column<string>(type: "jsonb", nullable: false, comment: "Данные")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_TimestampedValues", x => new { x.DiscriminatorId, x.Timestamp });
|
|
table.ForeignKey(
|
|
name: "FK_TimestampedValues_ValuesIdentities_DiscriminatorId",
|
|
column: x => x.DiscriminatorId,
|
|
principalTable: "ValuesIdentities",
|
|
principalColumn: "DiscriminatorId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TechMessage_SystemId",
|
|
table: "TechMessage",
|
|
column: "SystemId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "ChangeLog");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ParameterData");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Setpoint");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "TechMessage");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "TimestampedValues");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DataSourceSystem");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ValuesIdentities");
|
|
}
|
|
}
|
|
}
|