shoc-backend/Data.SeaHavenIndustries/Migrations/20260717140000_AddEventsCalendarTable.cs
Arthur Bassi 4e32c487d2 fix(migrations): discover Phase7, harden Phase4 indexes, align WO model
Make Phase7 EF-discoverable with idempotent DDL, shrink SiteCode and
InternalWONumber before Phase4 search indexes on this branch, align
MaxLength/Fluent indexes with the snapshot, and add the missing Events
calendar table migration so the model has no pending changes.
2026-07-17 11:10:59 -03:00

58 lines
2.2 KiB
C#

using Data.SeaHavenIndustries;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
/// <inheritdoc />
[DbContext(typeof(ApplicationDbContext))]
[Migration("20260717140000_AddEventsCalendarTable")]
public partial class AddEventsCalendarTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// Events entity existed in the model/DbSet without a discoverable migration.
migrationBuilder.Sql(@"
IF OBJECT_ID(N'dbo.Events', N'U') IS NULL
BEGIN
CREATE TABLE Events (
Id int NOT NULL IDENTITY(1,1),
Title nvarchar(100) NOT NULL,
Description nvarchar(max) NULL,
Location nvarchar(150) NULL,
RecordID int NULL,
RecordName nvarchar(max) NULL,
RecordTargetType nvarchar(max) NULL,
ReminderMinutes int NOT NULL,
EventColor nvarchar(20) NOT NULL,
StartDate datetime2 NOT NULL,
StartTime nvarchar(10) NULL,
EndDate datetime2 NOT NULL,
EndTime nvarchar(10) NULL,
AllDay bit NOT NULL,
IsDeleted bit NULL,
createdby nvarchar(max) NULL,
DeleterUserId nvarchar(max) NULL,
DeletionTime datetime2 NULL,
CreatedDate datetime2 NULL,
LastModificationTime datetime2 NULL,
LastModifierUserId int NULL,
CONSTRAINT PK_Events PRIMARY KEY (Id)
);
END
");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"
IF OBJECT_ID(N'dbo.Events', N'U') IS NOT NULL
DROP TABLE Events;
");
}
}
}