forked from ddrilling/AsbCloudServer
1. Добавил флаг прочитано ли уведомление 2. Добавил новые миграции
177 lines
8.1 KiB
C#
177 lines
8.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace AsbCloudDb.Migrations
|
|
{
|
|
public partial class Add_Notifications : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterColumn<int>(
|
|
name: "id_category",
|
|
table: "t_help_page",
|
|
type: "integer",
|
|
nullable: false,
|
|
comment: "Id категории файла",
|
|
oldClrType: typeof(int),
|
|
oldType: "integer",
|
|
oldComment: "id категории файла");
|
|
|
|
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_transport",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
name = table.Column<string>(type: "text", nullable: false, comment: "Название способа доставки уведомлений")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_t_notification_transport", 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_transport = 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: "Заголовок уведомления"),
|
|
subject = table.Column<string>(type: "text", nullable: false, comment: "Текст уведомления"),
|
|
time_to_life = table.Column<TimeSpan>(type: "interval", nullable: false, comment: "Время жизни уведомления"),
|
|
sent_date_at_utc = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "Дата отправки уведомления"),
|
|
is_read = table.Column<bool>(type: "boolean", nullable: true, 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_notification_transport_id_notification_tra~",
|
|
column: x => x.id_notification_transport,
|
|
principalTable: "t_notification_transport",
|
|
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.InsertData(
|
|
table: "t_notification_transport",
|
|
columns: new[] { "id", "name" },
|
|
values: new object[] { 1, "SignalR" });
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "t_permission",
|
|
columns: new[] { "id", "description", "name" },
|
|
values: new object[,]
|
|
{
|
|
{ 519, "Разрешение просматривать список контактов", "WellContact.get" },
|
|
{ 520, "Разрешение редактировать список контактов", "WellContact.edit" }
|
|
});
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "t_relation_user_role_permission",
|
|
columns: new[] { "id_permission", "id_user_role" },
|
|
values: new object[,]
|
|
{
|
|
{ 519, 1 },
|
|
{ 520, 1 }
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_t_notification_id_notification_category",
|
|
table: "t_notification",
|
|
column: "id_notification_category");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_t_notification_id_notification_transport",
|
|
table: "t_notification",
|
|
column: "id_notification_transport");
|
|
|
|
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");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "t_notification_transport");
|
|
|
|
migrationBuilder.DeleteData(
|
|
table: "t_relation_user_role_permission",
|
|
keyColumns: new[] { "id_permission", "id_user_role" },
|
|
keyValues: new object[] { 519, 1 });
|
|
|
|
migrationBuilder.DeleteData(
|
|
table: "t_relation_user_role_permission",
|
|
keyColumns: new[] { "id_permission", "id_user_role" },
|
|
keyValues: new object[] { 520, 1 });
|
|
|
|
migrationBuilder.DeleteData(
|
|
table: "t_permission",
|
|
keyColumn: "id",
|
|
keyValue: 519);
|
|
|
|
migrationBuilder.DeleteData(
|
|
table: "t_permission",
|
|
keyColumn: "id",
|
|
keyValue: 520);
|
|
|
|
migrationBuilder.AlterColumn<int>(
|
|
name: "id_category",
|
|
table: "t_help_page",
|
|
type: "integer",
|
|
nullable: false,
|
|
comment: "id категории файла",
|
|
oldClrType: typeof(int),
|
|
oldType: "integer",
|
|
oldComment: "Id категории файла");
|
|
}
|
|
}
|
|
}
|