QuestShare/QuestShare.Server/Migrations/20250217022911_InitialCreate.cs
2025-02-17 22:12:35 -05:00

134 lines
6.0 KiB
C#

using System;
using System.Net;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace QuestShare.Server.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Bans",
columns: table => new
{
BanId = table.Column<string>(type: "text", nullable: false),
BanIp = table.Column<IPAddress>(type: "inet", nullable: false),
BanCharacterId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
BanReason = table.Column<string>(type: "text", nullable: false),
BanIssuer = table.Column<string>(type: "text", nullable: false),
BanDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
BanExpiry = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Bans", x => x.BanId);
});
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
ClientId = table.Column<Guid>(type: "uuid", nullable: false),
CharacterId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
ConnectionId = table.Column<string>(type: "text", nullable: false),
Token = table.Column<string>(type: "text", nullable: false),
ConnectedShareCode = table.Column<string>(type: "text", nullable: false),
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
LastUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp")
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.ClientId);
});
migrationBuilder.CreateTable(
name: "QuestShares",
columns: table => new
{
ShareId = table.Column<Guid>(type: "uuid", nullable: false),
ShareHostClientId = table.Column<Guid>(type: "uuid", nullable: false),
ShareCode = table.Column<string>(type: "text", nullable: false),
BroadcastParty = table.Column<bool>(type: "boolean", nullable: false),
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
LastUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp")
},
constraints: table =>
{
table.PrimaryKey("PK_QuestShares", x => x.ShareId);
table.ForeignKey(
name: "FK_QuestShares_Clients_ShareHostClientId",
column: x => x.ShareHostClientId,
principalTable: "Clients",
principalColumn: "ClientId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Quests",
columns: table => new
{
QuestObjId = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
QuestId = table.Column<long>(type: "bigint", nullable: false),
CurrentStep = table.Column<byte>(type: "smallint", nullable: false),
IsActive = table.Column<bool>(type: "boolean", nullable: false),
ShareId1 = table.Column<Guid>(type: "uuid", nullable: false),
ShareId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Quests", x => x.QuestObjId);
table.ForeignKey(
name: "FK_Quests_QuestShares_ShareId",
column: x => x.ShareId,
principalTable: "QuestShares",
principalColumn: "ShareId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Quests_QuestShares_ShareId1",
column: x => x.ShareId1,
principalTable: "QuestShares",
principalColumn: "ShareId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Quests_ShareId",
table: "Quests",
column: "ShareId");
migrationBuilder.CreateIndex(
name: "IX_Quests_ShareId1",
table: "Quests",
column: "ShareId1");
migrationBuilder.CreateIndex(
name: "IX_QuestShares_ShareHostClientId",
table: "QuestShares",
column: "ShareHostClientId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Bans");
migrationBuilder.DropTable(
name: "Quests");
migrationBuilder.DropTable(
name: "QuestShares");
migrationBuilder.DropTable(
name: "Clients");
}
}
}