218 lines
9.1 KiB
C#
218 lines
9.1 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
namespace Sledgemapper.Api.Migrations
|
|
{
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "MapLogs",
|
|
columns: table => new
|
|
{
|
|
MapLogId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
UserId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
SessionId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Operation = table.Column<string>(type: "TEXT", maxLength: 1, nullable: false),
|
|
Type = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
|
|
Object = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
|
|
Timestamp = table.Column<double>(type: "REAL", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_MapLogs", x => x.MapLogId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Sessions",
|
|
columns: table => new
|
|
{
|
|
SessionId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
SessionName = table.Column<string>(type: "TEXT", nullable: false),
|
|
OwnerUserId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Sessions", x => x.SessionId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SessionUsers",
|
|
columns: table => new
|
|
{
|
|
SessionUserId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
SessionId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
UserId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SessionUsers", x => x.SessionUserId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Snapshots",
|
|
columns: table => new
|
|
{
|
|
SnapshotId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
SessionId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Object = table.Column<string>(type: "TEXT", nullable: false),
|
|
Timestamp = table.Column<double>(type: "REAL", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Snapshots", x => x.SnapshotId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UserConnections",
|
|
columns: table => new
|
|
{
|
|
UserConnectionId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
UserId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
ConnectionId = table.Column<string>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_UserConnections", x => x.UserConnectionId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
FirstName = table.Column<string>(type: "TEXT", nullable: true),
|
|
LastName = table.Column<string>(type: "TEXT", nullable: true),
|
|
Username = table.Column<string>(type: "TEXT", nullable: true),
|
|
Initials = table.Column<string>(type: "TEXT", nullable: true),
|
|
PasswordHash = table.Column<byte[]>(type: "BLOB", nullable: true),
|
|
PasswordSalt = table.Column<byte[]>(type: "BLOB", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Campaigns",
|
|
columns: table => new
|
|
{
|
|
CampaignId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
CampaignName = table.Column<string>(type: "TEXT", nullable: true),
|
|
OwnerId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Campaigns", x => x.CampaignId);
|
|
table.ForeignKey(
|
|
name: "FK_Campaigns_Users_OwnerId",
|
|
column: x => x.OwnerId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CampaignUser",
|
|
columns: table => new
|
|
{
|
|
CampaignsCampaignId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
InvitedUsersId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CampaignUser", x => new { x.CampaignsCampaignId, x.InvitedUsersId });
|
|
table.ForeignKey(
|
|
name: "FK_CampaignUser_Campaigns_CampaignsCampaignId",
|
|
column: x => x.CampaignsCampaignId,
|
|
principalTable: "Campaigns",
|
|
principalColumn: "CampaignId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_CampaignUser_Users_InvitedUsersId",
|
|
column: x => x.InvitedUsersId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Maps",
|
|
columns: table => new
|
|
{
|
|
MapId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
MapName = table.Column<string>(type: "TEXT", nullable: false),
|
|
CampaignId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Maps", x => x.MapId);
|
|
table.ForeignKey(
|
|
name: "FK_Maps_Campaigns_CampaignId",
|
|
column: x => x.CampaignId,
|
|
principalTable: "Campaigns",
|
|
principalColumn: "CampaignId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Campaigns_CampaignName_OwnerId",
|
|
table: "Campaigns",
|
|
columns: new[] { "CampaignName", "OwnerId" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Campaigns_OwnerId",
|
|
table: "Campaigns",
|
|
column: "OwnerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CampaignUser_InvitedUsersId",
|
|
table: "CampaignUser",
|
|
column: "InvitedUsersId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Maps_CampaignId",
|
|
table: "Maps",
|
|
column: "CampaignId");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "CampaignUser");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "MapLogs");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Maps");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Sessions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SessionUsers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Snapshots");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UserConnections");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Campaigns");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
}
|
|
}
|
|
}
|