171 lines
7.1 KiB
C#
171 lines
7.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
namespace Sledgemapper.Api.Migrations
|
|
{
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
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: false),
|
|
OwnerUserId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Campaigns", x => x.CampaignId);
|
|
});
|
|
|
|
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: "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);
|
|
});
|
|
|
|
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),
|
|
CampaignId = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Users_Campaigns_CampaignId",
|
|
column: x => x.CampaignId,
|
|
principalTable: "Campaigns",
|
|
principalColumn: "CampaignId",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_CampaignId",
|
|
table: "Users",
|
|
column: "CampaignId");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
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: "Users");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Campaigns");
|
|
}
|
|
}
|
|
}
|