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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), CampaignName = table.Column(type: "TEXT", nullable: false), OwnerUserId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Campaigns", x => x.CampaignId); }); migrationBuilder.CreateTable( name: "MapLogs", columns: table => new { MapLogId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), UserId = table.Column(type: "INTEGER", nullable: false), SessionId = table.Column(type: "INTEGER", nullable: false), Operation = table.Column(type: "TEXT", maxLength: 1, nullable: false), Type = table.Column(type: "TEXT", maxLength: 256, nullable: false), Object = table.Column(type: "TEXT", maxLength: 256, nullable: false), Timestamp = table.Column(type: "REAL", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MapLogs", x => x.MapLogId); }); migrationBuilder.CreateTable( name: "Maps", columns: table => new { MapId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), MapName = table.Column(type: "TEXT", nullable: false), CampaignId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Maps", x => x.MapId); }); migrationBuilder.CreateTable( name: "Sessions", columns: table => new { SessionId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), SessionName = table.Column(type: "TEXT", nullable: false), OwnerUserId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Sessions", x => x.SessionId); }); migrationBuilder.CreateTable( name: "SessionUsers", columns: table => new { SessionUserId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), SessionId = table.Column(type: "INTEGER", nullable: false), UserId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SessionUsers", x => x.SessionUserId); }); migrationBuilder.CreateTable( name: "Snapshots", columns: table => new { SnapshotId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), SessionId = table.Column(type: "INTEGER", nullable: false), Object = table.Column(type: "TEXT", nullable: false), Timestamp = table.Column(type: "REAL", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Snapshots", x => x.SnapshotId); }); migrationBuilder.CreateTable( name: "UserConnections", columns: table => new { UserConnectionId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), UserId = table.Column(type: "INTEGER", nullable: false), ConnectionId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserConnections", x => x.UserConnectionId); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), FirstName = table.Column(type: "TEXT", nullable: true), LastName = table.Column(type: "TEXT", nullable: true), Username = table.Column(type: "TEXT", nullable: true), Initials = table.Column(type: "TEXT", nullable: true), PasswordHash = table.Column(type: "BLOB", nullable: true), PasswordSalt = table.Column(type: "BLOB", nullable: true), CampaignId = table.Column(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"); } } }