Files
Radicade/Server/Migrations/20260927120000_AddKeepsakes.cs
2026-10-16 23:33:13 -07:00

52 lines
1.9 KiB
C#

using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using RadicadeServer.DB;
#nullable disable
namespace RadicadeServer.Migrations;
[DbContext(typeof(RecDBContext))]
[Migration("20260927120000_AddKeepsakes")]
public partial class AddKeepsakes : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"
IF OBJECT_ID(N'dbo.KeepsakeInstances', N'U') IS NULL
BEGIN
CREATE TABLE [KeepsakeInstances] (
[KeepsakeInstanceId] uniqueidentifier NOT NULL,
[RoomId] bigint NOT NULL,
[SubRoomId] bigint NULL,
[KeepsakeCategoryId] int NOT NULL,
[PlacedByAccountId] bigint NOT NULL,
[PlacedAt] datetime2 NOT NULL,
[Removed] bit NOT NULL DEFAULT 0,
CONSTRAINT [PK_KeepsakeInstances] PRIMARY KEY ([KeepsakeInstanceId])
);
CREATE INDEX [IX_KeepsakeInstances_RoomId] ON [KeepsakeInstances] ([RoomId], [Removed]);
END
IF OBJECT_ID(N'dbo.KeepsakeCollectionRecords', N'U') IS NULL
BEGIN
CREATE TABLE [KeepsakeCollectionRecords] (
[KeepsakeCollectionRecordId] bigint IDENTITY(1,1) NOT NULL,
[AccountId] bigint NOT NULL,
[KeepsakeInstanceId] uniqueidentifier NOT NULL,
[KeepsakeCategoryId] int NOT NULL,
[CollectedAt] datetime2 NOT NULL,
CONSTRAINT [PK_KeepsakeCollectionRecords] PRIMARY KEY ([KeepsakeCollectionRecordId])
);
CREATE UNIQUE INDEX [IX_KeepsakeCollectionRecords_AccountId_KeepsakeInstanceId]
ON [KeepsakeCollectionRecords] ([AccountId], [KeepsakeInstanceId]);
END");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"
IF OBJECT_ID(N'dbo.KeepsakeCollectionRecords', N'U') IS NOT NULL DROP TABLE [KeepsakeCollectionRecords];
IF OBJECT_ID(N'dbo.KeepsakeInstances', N'U') IS NOT NULL DROP TABLE [KeepsakeInstances];");
}
}