Files
Radicade/Server/Migrations/20261016090000_AddRoomJoinGiftsTable.cs
T
2026-10-16 23:33:13 -07:00

59 lines
2.3 KiB
C#

using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using RadicadeServer.DB;
#nullable disable
namespace RadicadeServer.Migrations
{
/// <summary>
/// A room used to describe exactly one join gift box in its own Rooms row. This table is that
/// box's list: one row per box, so a room can hand out several. A room with no rows here keeps
/// its one box from the Rooms row, which is what every room had before this table existed.
/// </summary>
[DbContext(typeof(RecDBContext))]
[Migration("20261016090000_AddRoomJoinGiftsTable")]
public partial class AddRoomJoinGiftsTable : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"
IF OBJECT_ID(N'dbo.RoomJoinGifts', N'U') IS NULL
BEGIN
CREATE TABLE [RoomJoinGifts] (
[RoomJoinGiftId] bigint NOT NULL IDENTITY(1,1),
[RoomId] bigint NOT NULL,
[SortOrder] int NOT NULL DEFAULT 0,
[Version] int NOT NULL DEFAULT 1,
[Enabled] bit NOT NULL DEFAULT 1,
[OncePerPlayer] bit NOT NULL DEFAULT 1,
[Title] nvarchar(max) NOT NULL DEFAULT N'Room Visit Gift',
[Message] nvarchar(max) NOT NULL DEFAULT N'Thanks for visiting!',
[AvatarItem] nvarchar(max) NOT NULL DEFAULT N'',
[AvatarItemType] int NOT NULL DEFAULT 0,
[EquipmentItem] nvarchar(max) NOT NULL DEFAULT N'',
[EquipmentModificationGuid] nvarchar(max) NOT NULL DEFAULT N'',
[ConsumableItem] nvarchar(max) NOT NULL DEFAULT N'',
[CurrencyType] int NOT NULL DEFAULT 1,
[CurrencyAmount] int NOT NULL DEFAULT 0,
[Xp] int NOT NULL DEFAULT 0,
[Context] int NOT NULL DEFAULT 2,
[Rarity] int NOT NULL DEFAULT 0,
[FromPlayerId] bigint NOT NULL DEFAULT 0,
CONSTRAINT [PK_RoomJoinGifts] PRIMARY KEY ([RoomJoinGiftId])
);
END
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_RoomJoinGifts_RoomId' AND object_id = OBJECT_ID(N'dbo.RoomJoinGifts'))
CREATE INDEX [IX_RoomJoinGifts_RoomId] ON [RoomJoinGifts] ([RoomId]);");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"
IF OBJECT_ID(N'dbo.RoomJoinGifts', N'U') IS NOT NULL
DROP TABLE [RoomJoinGifts];");
}
}
}