using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace LANCommander.Server.Data.PostgreSQL.Migrations
{
///
public partial class InitialMigration : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
PasswordHash = table.Column(type: "text", nullable: true),
SecurityStamp = table.Column(type: "text", nullable: true),
Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
EmailConfirmed = table.Column(type: "boolean", nullable: false),
NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column(type: "text", nullable: true),
PhoneNumber = table.Column(type: "text", nullable: true),
PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false),
TwoFactorEnabled = table.Column(type: "boolean", nullable: false),
LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true),
LockoutEnabled = table.Column(type: "boolean", nullable: false),
AccessFailedCount = table.Column(type: "integer", nullable: false),
RefreshToken = table.Column(type: "text", nullable: true),
RefreshTokenExpiration = table.Column(type: "timestamp with time zone", nullable: false),
Approved = table.Column(type: "boolean", nullable: false),
ApprovedOn = table.Column(type: "timestamp with time zone", nullable: true),
Alias = table.Column(type: "text", nullable: true),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true),
UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
table.ForeignKey(
name: "FK_Users_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Users_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Categories",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
ParentId = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true),
Name = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Categories", x => x.Id);
table.ForeignKey(
name: "FK_Categories_Categories_ParentId",
column: x => x.ParentId,
principalTable: "Categories",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Categories_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Categories_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Collections",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true),
Name = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Collections", x => x.Id);
table.ForeignKey(
name: "FK_Collections_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Collections_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Companies",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Name = table.Column(type: "text", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Companies", x => x.Id);
table.ForeignKey(
name: "FK_Companies_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Companies_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Engines",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true),
Name = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Engines", x => x.Id);
table.ForeignKey(
name: "FK_Engines_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Engines_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Genres",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true),
Name = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Genres", x => x.Id);
table.ForeignKey(
name: "FK_Genres_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Genres_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Libraries",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Libraries", x => x.Id);
table.ForeignKey(
name: "FK_Libraries_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Libraries_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Libraries_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Pages",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Title = table.Column(type: "character varying(256)", maxLength: 256, nullable: false),
Slug = table.Column(type: "character varying(256)", maxLength: 256, nullable: false),
Route = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: false),
Contents = table.Column(type: "text", nullable: false),
SortOrder = table.Column(type: "integer", nullable: false),
ParentId = table.Column(type: "uuid", nullable: true),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Pages", x => x.Id);
table.ForeignKey(
name: "FK_Pages_Pages_ParentId",
column: x => x.ParentId,
principalTable: "Pages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Pages_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Pages_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Platforms",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true),
Name = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Platforms", x => x.Id);
table.ForeignKey(
name: "FK_Platforms_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Platforms_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Redistributables",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Name = table.Column(type: "text", nullable: false),
Description = table.Column(type: "text", nullable: true),
Notes = table.Column(type: "text", nullable: true),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Redistributables", x => x.Id);
table.ForeignKey(
name: "FK_Redistributables_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Redistributables_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Roles",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true),
Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Roles", x => x.Id);
table.ForeignKey(
name: "FK_Roles_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Roles_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "StorageLocations",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Default = table.Column(type: "boolean", nullable: false),
Path = table.Column(type: "text", nullable: false),
Type = table.Column(type: "integer", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_StorageLocations", x => x.Id);
table.ForeignKey(
name: "FK_StorageLocations_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id");
table.ForeignKey(
name: "FK_StorageLocations_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Tags",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true),
Name = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tags", x => x.Id);
table.ForeignKey(
name: "FK_Tags_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Tags_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "UserClaims",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column(type: "uuid", nullable: false),
ClaimType = table.Column(type: "text", nullable: true),
ClaimValue = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserClaims", x => x.Id);
table.ForeignKey(
name: "FK_UserClaims_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserCustomField",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false),
Value = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserCustomField", x => x.Id);
table.ForeignKey(
name: "FK_UserCustomField_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_UserCustomField_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_UserCustomField_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserLogins",
columns: table => new
{
LoginProvider = table.Column(type: "text", nullable: false),
ProviderKey = table.Column(type: "text", nullable: false),
ProviderDisplayName = table.Column(type: "text", nullable: true),
UserId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_UserLogins_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserTokens",
columns: table => new
{
UserId = table.Column(type: "uuid", nullable: false),
LoginProvider = table.Column(type: "text", nullable: false),
Name = table.Column(type: "text", nullable: false),
Value = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_UserTokens_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Games",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
IGDBId = table.Column(type: "bigint", nullable: true),
Title = table.Column(type: "text", nullable: false),
SortTitle = table.Column(type: "text", nullable: true),
DirectoryName = table.Column(type: "text", nullable: true),
Description = table.Column(type: "text", nullable: true),
Notes = table.Column(type: "text", nullable: true),
ReleasedOn = table.Column(type: "timestamp with time zone", nullable: true),
KeyAllocationMethod = table.Column(type: "integer", nullable: false),
Type = table.Column(type: "integer", nullable: false),
BaseGameId = table.Column(type: "uuid", nullable: true),
Singleplayer = table.Column(type: "boolean", nullable: false),
EngineId = table.Column(type: "uuid", nullable: true),
ValidKeyRegex = table.Column(type: "text", nullable: true),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Games", x => x.Id);
table.ForeignKey(
name: "FK_Games_Engines_EngineId",
column: x => x.EngineId,
principalTable: "Engines",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Games_Games_BaseGameId",
column: x => x.BaseGameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Games_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Games_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "PageRedistributable",
columns: table => new
{
PageId = table.Column(type: "uuid", nullable: false),
RedistributableId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PageRedistributable", x => new { x.PageId, x.RedistributableId });
table.ForeignKey(
name: "FK_PageRedistributable_Pages_PageId",
column: x => x.PageId,
principalTable: "Pages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PageRedistributable_Redistributables_RedistributableId",
column: x => x.RedistributableId,
principalTable: "Redistributables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RoleClaims",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RoleId = table.Column(type: "uuid", nullable: false),
ClaimType = table.Column(type: "text", nullable: true),
ClaimValue = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_RoleClaims_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RoleCollection",
columns: table => new
{
CollectionId = table.Column(type: "uuid", nullable: false),
RoleId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RoleCollection", x => new { x.CollectionId, x.RoleId });
table.ForeignKey(
name: "FK_RoleCollection_Collections_CollectionId",
column: x => x.CollectionId,
principalTable: "Collections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RoleCollection_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserRoles",
columns: table => new
{
UserId = table.Column(type: "uuid", nullable: false),
RoleId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_UserRoles_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserRoles_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Archive",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Changelog = table.Column(type: "text", nullable: true),
ObjectKey = table.Column(type: "text", nullable: false),
Version = table.Column(type: "text", nullable: false),
StorageLocationId = table.Column(type: "uuid", nullable: false),
GameId = table.Column(type: "uuid", nullable: true),
RedistributableId = table.Column(type: "uuid", nullable: true),
LastVersionId = table.Column(type: "uuid", nullable: true),
UncompressedSize = table.Column(type: "bigint", nullable: false),
CompressedSize = table.Column(type: "bigint", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Archive", x => x.Id);
table.ForeignKey(
name: "FK_Archive_Archive_LastVersionId",
column: x => x.LastVersionId,
principalTable: "Archive",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Archive_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Archive_Redistributables_RedistributableId",
column: x => x.RedistributableId,
principalTable: "Redistributables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Archive_StorageLocations_StorageLocationId",
column: x => x.StorageLocationId,
principalTable: "StorageLocations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Archive_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Archive_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "CategoryGame",
columns: table => new
{
CategoriesId = table.Column(type: "uuid", nullable: false),
GamesId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CategoryGame", x => new { x.CategoriesId, x.GamesId });
table.ForeignKey(
name: "FK_CategoryGame_Categories_CategoriesId",
column: x => x.CategoriesId,
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CategoryGame_Games_GamesId",
column: x => x.GamesId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CollectionGame",
columns: table => new
{
CollectionId = table.Column(type: "uuid", nullable: false),
GameId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CollectionGame", x => new { x.CollectionId, x.GameId });
table.ForeignKey(
name: "FK_CollectionGame_Collections_CollectionId",
column: x => x.CollectionId,
principalTable: "Collections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CollectionGame_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GameCustomField",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false),
Value = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false),
GameId = table.Column(type: "uuid", nullable: true),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GameCustomField", x => x.Id);
table.ForeignKey(
name: "FK_GameCustomField_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id");
table.ForeignKey(
name: "FK_GameCustomField_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id");
table.ForeignKey(
name: "FK_GameCustomField_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "GameDeveloper",
columns: table => new
{
GameId = table.Column(type: "uuid", nullable: false),
DeveloperId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GameDeveloper", x => new { x.GameId, x.DeveloperId });
table.ForeignKey(
name: "FK_GameDeveloper_Companies_DeveloperId",
column: x => x.DeveloperId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GameDeveloper_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GameGenre",
columns: table => new
{
GamesId = table.Column(type: "uuid", nullable: false),
GenresId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GameGenre", x => new { x.GamesId, x.GenresId });
table.ForeignKey(
name: "FK_GameGenre_Games_GamesId",
column: x => x.GamesId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GameGenre_Genres_GenresId",
column: x => x.GenresId,
principalTable: "Genres",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GamePlatform",
columns: table => new
{
GamesId = table.Column(type: "uuid", nullable: false),
PlatformsId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GamePlatform", x => new { x.GamesId, x.PlatformsId });
table.ForeignKey(
name: "FK_GamePlatform_Games_GamesId",
column: x => x.GamesId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GamePlatform_Platforms_PlatformsId",
column: x => x.PlatformsId,
principalTable: "Platforms",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GamePublisher",
columns: table => new
{
GameId = table.Column(type: "uuid", nullable: false),
PublisherId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GamePublisher", x => new { x.GameId, x.PublisherId });
table.ForeignKey(
name: "FK_GamePublisher_Companies_PublisherId",
column: x => x.PublisherId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GamePublisher_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GameRedistributable",
columns: table => new
{
GameId = table.Column(type: "uuid", nullable: false),
RedistributableId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GameRedistributable", x => new { x.GameId, x.RedistributableId });
table.ForeignKey(
name: "FK_GameRedistributable_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GameRedistributable_Redistributables_RedistributableId",
column: x => x.RedistributableId,
principalTable: "Redistributables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GameSaves",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
StorageLocationId = table.Column(type: "uuid", nullable: false),
Size = table.Column(type: "bigint", nullable: false),
GameId = table.Column(type: "uuid", nullable: true),
UserId = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GameSaves", x => x.Id);
table.ForeignKey(
name: "FK_GameSaves_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_GameSaves_StorageLocations_StorageLocationId",
column: x => x.StorageLocationId,
principalTable: "StorageLocations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GameSaves_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_GameSaves_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_GameSaves_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GameTag",
columns: table => new
{
GamesId = table.Column(type: "uuid", nullable: false),
TagsId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GameTag", x => new { x.GamesId, x.TagsId });
table.ForeignKey(
name: "FK_GameTag_Games_GamesId",
column: x => x.GamesId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GameTag_Tags_TagsId",
column: x => x.TagsId,
principalTable: "Tags",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Issues",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Description = table.Column(type: "text", nullable: false),
ResolvedOn = table.Column(type: "timestamp with time zone", nullable: true),
GameId = table.Column(type: "uuid", nullable: false),
ResolvedById = table.Column(type: "uuid", nullable: true),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Issues", x => x.Id);
table.ForeignKey(
name: "FK_Issues_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Issues_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Issues_Users_ResolvedById",
column: x => x.ResolvedById,
principalTable: "Users",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Issues_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Keys",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Value = table.Column(type: "character varying(255)", maxLength: 255, nullable: false),
GameId = table.Column(type: "uuid", nullable: false),
AllocationMethod = table.Column(type: "integer", nullable: false),
ClaimedByMacAddress = table.Column(type: "character varying(17)", maxLength: 17, nullable: true),
ClaimedByIpv4Address = table.Column(type: "character varying(15)", maxLength: 15, nullable: true),
ClaimedByComputerName = table.Column(type: "character varying(255)", maxLength: 255, nullable: true),
ClaimedByUserId = table.Column(type: "uuid", nullable: true),
ClaimedOn = table.Column(type: "timestamp with time zone", nullable: true),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Keys", x => x.Id);
table.ForeignKey(
name: "FK_Keys_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Keys_Users_ClaimedByUserId",
column: x => x.ClaimedByUserId,
principalTable: "Users",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Keys_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Keys_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "LibraryGame",
columns: table => new
{
GameId = table.Column(type: "uuid", nullable: false),
LibraryId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LibraryGame", x => new { x.GameId, x.LibraryId });
table.ForeignKey(
name: "FK_LibraryGame_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_LibraryGame_Libraries_LibraryId",
column: x => x.LibraryId,
principalTable: "Libraries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Media",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
FileId = table.Column(type: "uuid", nullable: false),
Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
Type = table.Column(type: "integer", nullable: false),
SourceUrl = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
MimeType = table.Column(type: "character varying(255)", maxLength: 255, nullable: true),
Crc32 = table.Column(type: "character varying(8)", maxLength: 8, nullable: false),
ThumbnailId = table.Column(type: "uuid", nullable: true),
StorageLocationId = table.Column(type: "uuid", nullable: false),
GameId = table.Column(type: "uuid", nullable: true),
UserId = table.Column(type: "uuid", nullable: true),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Media", x => x.Id);
table.ForeignKey(
name: "FK_Media_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Media_Media_ThumbnailId",
column: x => x.ThumbnailId,
principalTable: "Media",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Media_StorageLocations_StorageLocationId",
column: x => x.StorageLocationId,
principalTable: "StorageLocations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Media_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Media_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Media_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MultiplayerModes",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Type = table.Column(type: "integer", nullable: false),
NetworkProtocol = table.Column(type: "integer", nullable: false),
Description = table.Column(type: "text", nullable: true),
MinPlayers = table.Column(type: "integer", nullable: false),
MaxPlayers = table.Column(type: "integer", nullable: false),
Spectators = table.Column(type: "integer", nullable: false),
GameId = table.Column(type: "uuid", nullable: false),
CreatedOn = table.Column(type: "timestamp with time zone", nullable: false),
CreatedById = table.Column(type: "uuid", nullable: true),
UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedById = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MultiplayerModes", x => x.Id);
table.ForeignKey(
name: "FK_MultiplayerModes_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_MultiplayerModes_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_MultiplayerModes_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "PageGame",
columns: table => new
{
GameId = table.Column