67 lines
3.1 KiB
C#
67 lines
3.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Persistence.Database.Postgres.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class TechMessageMigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "DrillingSystem",
|
|
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_DrillingSystem", x => x.SystemId);
|
|
});
|
|
|
|
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: "Дата возникновения"),
|
|
Depth = table.Column<double>(type: "double precision", nullable: true, comment: "Глубина забоя"),
|
|
MessageText = table.Column<string>(type: "varchar(512)", nullable: false, comment: "Текст сообщения"),
|
|
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы автобурения, к которой относится сообщение"),
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id пользователя за пультом бурильщика")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_TechMessage", x => x.EventId);
|
|
table.ForeignKey(
|
|
name: "FK_TechMessage_DrillingSystem_SystemId",
|
|
column: x => x.SystemId,
|
|
principalTable: "DrillingSystem",
|
|
principalColumn: "SystemId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TechMessage_SystemId",
|
|
table: "TechMessage",
|
|
column: "SystemId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "TechMessage");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DrillingSystem");
|
|
}
|
|
}
|
|
}
|