using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace GreenHome.Infrastructure.Migrations { /// public partial class AddAlertNotifications : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AlertNotifications", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DeviceId = table.Column(type: "int", nullable: false), UserId = table.Column(type: "int", nullable: false), AlertType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), Message = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), SentAt = table.Column(type: "datetime2", nullable: false), IsSent = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AlertNotifications", x => x.Id); table.ForeignKey( name: "FK_AlertNotifications_Devices_DeviceId", column: x => x.DeviceId, principalTable: "Devices", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_AlertNotifications_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_AlertNotifications_DeviceId_UserId_AlertType_SentAt", table: "AlertNotifications", columns: new[] { "DeviceId", "UserId", "AlertType", "SentAt" }); migrationBuilder.CreateIndex( name: "IX_AlertNotifications_UserId", table: "AlertNotifications", column: "UserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AlertNotifications"); } } }