mirror of
https://github.com/bitwarden/server.git
synced 2024-11-24 12:35:25 +01:00
4c0f8d54f3
* Add new tables * Add stored procedures * Add core entities and models * Setup EF * Add repository interfaces * Add dapper repos * Add EF repos * Add order by * EF updates * PM-10560: Notifications repository matching requirements. * PM-10560: Notifications repository matching requirements. * PM-10560: Migration scripts * PM-10560: EF index optimizations * PM-10560: Cleanup * PM-10560: Priority in natural order, Repository, sql simplifications * PM-10560: Title column update * PM-10560: Incorrect EF migration removal * PM-10560: EF migrations * PM-10560: Added views, SP naming simplification * PM-10560: Notification entity Title update, EF migrations * PM-10560: Removing Notification_ReadByUserId * PM-10560: Notification ReadByUserIdAndStatus fix * PM-10560: Notification ReadByUserIdAndStatus fix to be in line with requirements and EF --------- Co-authored-by: Maciej Zieniuk <mzieniuk@bitwarden.com> Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
105 lines
4.5 KiB
C#
105 lines
4.5 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Bit.MySqlMigrations.Migrations;
|
|
|
|
/// <inheritdoc />
|
|
public partial class NotificationCenter : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Notification",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Priority = table.Column<byte>(type: "tinyint unsigned", nullable: false),
|
|
Global = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
ClientType = table.Column<byte>(type: "tinyint unsigned", nullable: false),
|
|
UserId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
Title = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Body = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
RevisionDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Notification", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Notification_Organization_OrganizationId",
|
|
column: x => x.OrganizationId,
|
|
principalTable: "Organization",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_Notification_User_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "User",
|
|
principalColumn: "Id");
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "NotificationStatus",
|
|
columns: table => new
|
|
{
|
|
NotificationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ReadDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
DeletedDate = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_NotificationStatus", x => new { x.UserId, x.NotificationId });
|
|
table.ForeignKey(
|
|
name: "FK_NotificationStatus_Notification_NotificationId",
|
|
column: x => x.NotificationId,
|
|
principalTable: "Notification",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_NotificationStatus_User_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "User",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Notification_ClientType_Global_UserId_OrganizationId_Priorit~",
|
|
table: "Notification",
|
|
columns: new[] { "ClientType", "Global", "UserId", "OrganizationId", "Priority", "CreationDate" },
|
|
descending: new[] { false, false, false, false, true, true });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Notification_OrganizationId",
|
|
table: "Notification",
|
|
column: "OrganizationId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Notification_UserId",
|
|
table: "Notification",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_NotificationStatus_NotificationId",
|
|
table: "NotificationStatus",
|
|
column: "NotificationId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "NotificationStatus");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Notification");
|
|
}
|
|
}
|