forked from ddrilling/AsbCloudServer
Степанов Дмитрий Александрович
985c0489d0
1. Изменил сущность уведомления. Добавил состояние уведомления 2. Удалил сущность для доставки уведомлений. 3. Изменение DTO уведомления. 4. Добавил миграцию. 5. Поправил DbContext.
86 lines
4.2 KiB
C#
86 lines
4.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace AsbCloudDb.Migrations
|
|
{
|
|
public partial class Add_Notification : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "t_notification_category",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
name = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_t_notification_category", x => x.id);
|
|
},
|
|
comment: "Категории уведомлений");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "t_notification",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
id_user = table.Column<int>(type: "integer", nullable: false, comment: "Id получателя"),
|
|
id_notification_category = table.Column<int>(type: "integer", nullable: false, comment: "Id категории уведомления"),
|
|
title = table.Column<string>(type: "text", nullable: false, comment: "Заголовок уведомления"),
|
|
message = table.Column<string>(type: "text", nullable: false, comment: "Сообщение уведомления"),
|
|
time_to_life = table.Column<TimeSpan>(type: "interval", nullable: false, comment: "Время жизни уведомления"),
|
|
sent_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "Дата отправки уведомления"),
|
|
notification_state = table.Column<string>(type: "text", nullable: false, comment: "Состояние уведомления"),
|
|
notification_transport = table.Column<string>(type: "text", nullable: false, comment: "Метод доставки уведомления")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_t_notification", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_t_notification_t_notification_category_id_notification_cate~",
|
|
column: x => x.id_notification_category,
|
|
principalTable: "t_notification_category",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_t_notification_t_user_id_user",
|
|
column: x => x.id_user,
|
|
principalTable: "t_user",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
},
|
|
comment: "Уведомления");
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "t_notification_category",
|
|
columns: new[] { "id", "name" },
|
|
values: new object[] { 1, "Системные уведомления" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_t_notification_id_notification_category",
|
|
table: "t_notification",
|
|
column: "id_notification_category");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_t_notification_id_user",
|
|
table: "t_notification",
|
|
column: "id_user");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "t_notification");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "t_notification_category");
|
|
}
|
|
}
|
|
}
|