From efaa6c71d73b7e6f69c70784a566a5027b734a6c Mon Sep 17 00:00:00 2001 From: kozhilya Date: Thu, 17 Apr 2025 17:26:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D1=87=D0=B8=D1=81=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pf2eDataScrapper/Importers/DatabaseHelper.cs | 2 +- .../Aonprd/DataBuilder/AbstractProcessor.cs | 24 +- .../Aonprd/DataBuilder/AonprdDataBuilder.cs | 20 +- .../Aonprd/DataBuilder/AonprdEnumAttribute.cs | 8 +- .../DataBuilder/AonprdProcessorCollection.cs | 10 +- .../Processors/TraitTraitsProcessor.cs | 7 +- .../DataBuilder/AbstractProcessor.cs | 10 +- .../Migrations/20250417082248_V2.cs | 2300 ++++++++--------- .../Migrations/20250417085326_DateOnly.cs | 54 +- Pf2eDataScrapper/Model/Base/Entity.cs | 1 - Pf2eDataScrapper/Model/Enum/ActionCategory.cs | 1 - Pf2eDataScrapper/Model/Pf2eDbContextModel.cs | 2 +- 12 files changed, 1206 insertions(+), 1233 deletions(-) diff --git a/Pf2eDataScrapper/Importers/DatabaseHelper.cs b/Pf2eDataScrapper/Importers/DatabaseHelper.cs index a8af780..1b950c2 100644 --- a/Pf2eDataScrapper/Importers/DatabaseHelper.cs +++ b/Pf2eDataScrapper/Importers/DatabaseHelper.cs @@ -10,7 +10,7 @@ public class DatabaseHelper private int _id = 0; - + public int NextEntityId { get => ++_id; set => _id = value; } private DatabaseHelper() diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AbstractProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AbstractProcessor.cs index 5337312..e86431f 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AbstractProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AbstractProcessor.cs @@ -77,13 +77,13 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) Context.EntityAliases.Add(alias); - var legacyIdArray = Input.GetOptional("legacy_id"); + JArray? legacyIdArray = Input.GetOptional("legacy_id"); if (legacyIdArray is not null) { string legacyId = legacyIdArray[0].ToString(); - if (LegacyAliases.TryGetValue(legacyId, out var legacyName)) + if (LegacyAliases.TryGetValue(legacyId, out string? legacyName)) { if (legacyName != Entity.Name) { @@ -126,7 +126,7 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) } string sourceMarkdown = Input.GetRequired("source_markdown"); Match match = SourceSuffixRegex().Match(sourceMarkdown); - + EntitySource entitySource = new() { Entity = Entity, @@ -145,11 +145,11 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) AonprdTarget = Context.ExternalTargets.FirstOrDefault(t => t.Name == AonprdImporter.SourceName); AonprdTarget ??= new() - { - Name = AonprdImporter.SourceName, - Icon = "http://www.google.com/s2/favicons?domain=2e.aonprd.com", - Prefix = "https://2e.aonprd.com", - }; + { + Name = AonprdImporter.SourceName, + Icon = "http://www.google.com/s2/favicons?domain=2e.aonprd.com", + Prefix = "https://2e.aonprd.com", + }; } EntityExternal external = new() @@ -171,14 +171,14 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) throw new Exception("'trait' is expected to be an array"); } - var names = traitsJson.ToArray().Select(jToken => jToken.ToString()); - var traitEntities = Context.Traits + IEnumerable names = traitsJson.ToArray().Select(jToken => jToken.ToString()); + List traitEntities = Context.Traits .SelectMany(t => t.Entity.Aliases) .Where(a => names.Contains(a.Alias)) .Select(a => a.Entity) .ToList(); - var traits = Context.Traits + List traits = Context.Traits .Where(t => traitEntities.Contains(t.Entity)) .ToList(); @@ -249,7 +249,7 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) using MD5 md5 = MD5.Create(); byte[] byteHash = md5.ComputeHash(Encoding.UTF8.GetBytes(input)); string hash = BitConverter.ToString(byteHash).Replace("-", ""); - return (isLowercase) ? hash.ToLower() : hash; + return isLowercase ? hash.ToLower() : hash; } protected static ExternalTarget? AonprdTarget = null; diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs index 173c946..041c4a8 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs @@ -1,11 +1,5 @@ using Konsole; -using Newtonsoft.Json.Linq; using Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium; -using Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.Compendium; -using Pf2eDataScrapper.Model.Base; -using System; -using System.ComponentModel; -using System.Reflection; using static Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.AbstractProcessor; namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder; @@ -39,29 +33,29 @@ internal class AonprdDataBuilder(AonprdLoader loader) { Console.WriteLine("Building data..."); - var window = new Window(0, 0, Console.WindowWidth, Console.WindowHeight).Concurrent(); + ConcurrentWriter window = new Window(0, 0, Console.WindowWidth, Console.WindowHeight).Concurrent(); - var bars = window.OpenBox("Progress", Console.WindowWidth, 4, new BoxStyle { Body = Colors.WhiteOnBlack }); + IConsole bars = window.OpenBox("Progress", Console.WindowWidth, 4, new BoxStyle { Body = Colors.WhiteOnBlack }); - var output = new Window(0, 4, Console.WindowWidth, Console.WindowHeight - 4, window); + Window output = new Window(0, 4, Console.WindowWidth, Console.WindowHeight - 4, window); ProgressBar bar1 = new(bars, Loader.ItemCount, 15); ProgressBar bar2 = new(bars, 1, 15); int i = 0; - foreach (var item in Processors.Items) + foreach (AonprdProcessorCollection.ProcessorItem item in Processors.Items) { bar1.Refresh(i++, $"{item.Attribute.Name}"); bar2.Max = Compendium.Count([item.Attribute.Type]); int j = 0; - foreach(var entry in Loader.Entries(item.Attribute.Type)) + foreach (AonprdLoader.LoaderEntry entry in Loader.Entries(item.Attribute.Type)) { bar2.Refresh(i++, $"{entry.Id}"); - var input = new ProcessorInput(entry.Json); - var processor = (AbstractProcessor) item.Constructor.Invoke([input]); + ProcessorInput input = new ProcessorInput(entry.Json); + AbstractProcessor processor = (AbstractProcessor) item.Constructor.Invoke([input]); try { diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumAttribute.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumAttribute.cs index afd91e1..11ae34f 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumAttribute.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumAttribute.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder; +namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder; [AttributeUsage(AttributeTargets.Field)] internal class AonprdEnumAttribute(string value) : Attribute diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdProcessorCollection.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdProcessorCollection.cs index 28979c3..864594c 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdProcessorCollection.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdProcessorCollection.cs @@ -33,7 +33,7 @@ internal class AonprdProcessorCollection ConstructorInfo constructor = type.GetConstructor([typeof(ProcessorInput)])!; - var collision = Items.FirstOrDefault(i => i.Attribute.Name == attribute.Name); + ProcessorItem? collision = Items.FirstOrDefault(i => i.Attribute.Name == attribute.Name); if (collision is not null) { throw new Exception($"Multiply attributes 'AonprdProcessor' have same name '{attribute.Name}'." + @@ -50,14 +50,14 @@ internal class AonprdProcessorCollection while (priorities.Count < Items.Count) { - foreach (var item in Items) + foreach (ProcessorItem item in Items) { if (item.Priority > 0) { continue; } - var dependencyPriorities = item.Attribute.Dependencies.Select(d => priorities.TryGetValue(d, out int value) ? value : -1); + IEnumerable dependencyPriorities = item.Attribute.Dependencies.Select(d => priorities.TryGetValue(d, out int value) ? value : -1); if (dependencyPriorities.Any(p => p == -1)) { @@ -69,14 +69,14 @@ internal class AonprdProcessorCollection } } - Items.Sort((a, b) => a.Priority - b.Priority); + Items.Sort((a, b) => a.Priority - b.Priority); } public IEnumerable Iterate() { SortItems(); - foreach (var item in Items) + foreach (ProcessorItem item in Items) { yield return item; } diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/TraitTraitsProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/TraitTraitsProcessor.cs index a17e995..f6b7154 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/TraitTraitsProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/TraitTraitsProcessor.cs @@ -1,11 +1,6 @@ using Newtonsoft.Json.Linq; using Pf2eDataScrapper.Model.Enum; using Pf2eDataScrapper.Model.Structure; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors; @@ -29,7 +24,7 @@ internal class TraitTraitsProcessor(ProcessorInput input) : AbstractProcessor(in // base.Process(); string url = Input.GetRequired("url"); - var external = Context.EntityExternals.FirstOrDefault(x => x.Suffix == url) ?? throw new Exception("Entity not found?"); + Model.Base.Targets.EntityExternal external = Context.EntityExternals.FirstOrDefault(x => x.Suffix == url) ?? throw new Exception("Entity not found?"); Entity = external.Entity; AddTraits(); diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs index c4b42ba..9a25466 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs @@ -1,17 +1,13 @@ -using LinqToDB.Common; -using Newtonsoft.Json.Linq; -using NpgsqlTypes; +using Newtonsoft.Json.Linq; using Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder; using Pf2eDataScrapper.Model; using Pf2eDataScrapper.Model.Base; using Pf2eDataScrapper.Model.Base.Source; using Pf2eDataScrapper.Model.Base.Targets; -using Pf2eDataScrapper.Model.Common; using Pf2eDataScrapper.Model.Enum; using Pf2eDataScrapper.Model.Structure; using System.Security.Cryptography; using System.Text; -using static LinqToDB.Reflection.Methods.LinqToDB.Insert; namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder; @@ -88,7 +84,7 @@ internal abstract class AbstractProcessor(JObject input) throw new Exception("system.traits.value is expected to be an array"); } - foreach(Trait trait in GetTraits(traitsJson.ToArray().Select(jToken => jToken.ToString()))) + foreach (Trait trait in GetTraits(traitsJson.ToArray().Select(jToken => jToken.ToString()))) { Entity.Traits.Add(trait); } @@ -198,6 +194,6 @@ internal abstract class AbstractProcessor(JObject input) using MD5 md5 = MD5.Create(); byte[] byteHash = md5.ComputeHash(Encoding.UTF8.GetBytes(input)); string hash = BitConverter.ToString(byteHash).Replace("-", ""); - return (isLowercase) ? hash.ToLower() : hash; + return isLowercase ? hash.ToLower() : hash; } } diff --git a/Pf2eDataScrapper/Migrations/20250417082248_V2.cs b/Pf2eDataScrapper/Migrations/20250417082248_V2.cs index 3ed1956..88572f6 100644 --- a/Pf2eDataScrapper/Migrations/20250417082248_V2.cs +++ b/Pf2eDataScrapper/Migrations/20250417082248_V2.cs @@ -1,1071 +1,1070 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Pf2eDataScrapper.Model.Enum; #nullable disable -namespace Pf2eDataScrapper.Migrations +namespace Pf2eDataScrapper.Migrations; + +/// +public partial class V2 : Migration { /// - public partial class V2 : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterDatabase() - .Annotation("Npgsql:Enum:action_category", "unknown,offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature") - .Annotation("Npgsql:Enum:action_type", "action,free,reaction,passive") - .Annotation("Npgsql:Enum:alias_type", "legacy,english,legacy_english,hobby,other") - .Annotation("Npgsql:Enum:ancestry_vision", "normal,low-light-vision,darkvision") - .Annotation("Npgsql:Enum:attribute_values", "any,str,dex,con,int,wis,cha") - .Annotation("Npgsql:Enum:class_progression_type", "entity,ancestry_feat,class_feat,general_feat,skill_feat,skill_increase") - .Annotation("Npgsql:Enum:condition_group", "unknown,senses,abilities,death,attitudes,detection") - .Annotation("Npgsql:Enum:deity_category", "deity,pantheon,covenant,philosophy") - .Annotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any") - .Annotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any") - .Annotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique") - .Annotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell") - .Annotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free") - .Annotation("Npgsql:Enum:feat_category", "ancestryfeature,classfeature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign_feature") - .Annotation("Npgsql:Enum:size", "med,tiny") - .Annotation("Npgsql:Enum:source_category", "rulebook,adventure-path,lost-omens") - .Annotation("Npgsql:Enum:spell_area_type", "burst,emanation,cone,line,square,cube,cylinder") - .Annotation("Npgsql:Enum:spell_damage_category", "persistent,splash") - .Annotation("Npgsql:Enum:spell_damage_kinds", "damage,healing,any") - .Annotation("Npgsql:Enum:training_stage", "untrained,trained,expert,master,legendary") - .Annotation("Npgsql:Enum:trait_type", "regular,tradition"); - - migrationBuilder.CreateTable( - name: "entities", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Отображаемое имя"), - type = table.Column(type: "entity_type", nullable: false, comment: "Тип объекта"), - slug = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Часть имени в URL"), - img = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Изображение объекта"), - description = table.Column(type: "text", nullable: false, comment: "Текстовое описание объекта"), - rarity = table.Column(type: "entity_rarity", nullable: false), - is_translated = table.Column(type: "boolean", nullable: true, comment: "Флаг, указывающий, что у объекта существует перевод"), - is_checked = table.Column(type: "boolean", nullable: true, comment: "Флаг, указывающий, что объект был проверен и не требует автоматической перезаписи") - }, - constraints: table => - { - table.PrimaryKey("pk_entities", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "external_targets", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - icon = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - prefix = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_external_targets", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "frequencies", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - max = table.Column(type: "integer", nullable: false), - per = table.Column(type: "integer", nullable: false), - value = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_frequencies", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "keywords", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - slug = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_keywords", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "languages", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - slug = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - rarity = table.Column(type: "entity_rarity", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_languages", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "sources", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - category = table.Column(type: "source_category", nullable: false), - release_date = table.Column(type: "timestamp with time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_sources", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "trainings", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - key = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_trainings", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "actions", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - type = table.Column(type: "action_type", nullable: false), - category = table.Column(type: "action_category", nullable: false), - actions = table.Column(type: "integer", nullable: true), - death_note = table.Column(type: "boolean", nullable: true), - extra = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_actions", x => x.id); - table.ForeignKey( - name: "fk_actions_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ancestries", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - size = table.Column(type: "size", nullable: false), - hp = table.Column(type: "integer", nullable: false), - reach = table.Column(type: "integer", nullable: false), - speed = table.Column(type: "integer", nullable: false), - vision = table.Column(type: "ancestry_vision", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_ancestries", x => x.id); - table.ForeignKey( - name: "fk_ancestries_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "backgrounds", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_backgrounds", x => x.id); - table.ForeignKey( - name: "fk_backgrounds_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "classes", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - hp = table.Column(type: "integer", nullable: false), - perception = table.Column(type: "integer", nullable: false), - spellcasting = table.Column(type: "boolean", nullable: false), - additional_trained_skills = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_classes", x => x.id); - table.ForeignKey( - name: "fk_classes_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "conditions", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - group = table.Column(type: "condition_group", nullable: true), - extra = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_conditions", x => x.id); - table.ForeignKey( - name: "fk_conditions_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "deities", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - category = table.Column(type: "deity_category", nullable: false), - fonts = table.Column(type: "deity_fonts", nullable: false), - sanctification = table.Column(type: "deity_sanctification", nullable: false), - sanctification_must = table.Column(type: "boolean", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_deities", x => x.id); - table.ForeignKey( - name: "fk_deities_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "entity_aliases", - columns: table => new - { - entity_id = table.Column(type: "integer", nullable: false), - type = table.Column(type: "alias_type", nullable: false), - alias = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_entity_aliases", x => new { x.entity_id, x.type }); - table.ForeignKey( - name: "fk_entity_aliases_entities_entity_id", - column: x => x.entity_id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "feats", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - type = table.Column(type: "action_type", nullable: false), - category = table.Column(type: "action_category", nullable: false), - actions = table.Column(type: "integer", nullable: true), - level = table.Column(type: "integer", nullable: false), - level_taken = table.Column(type: "integer", nullable: true), - max_takable = table.Column(type: "integer", nullable: true), - location = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), - only_level1 = table.Column(type: "boolean", nullable: true), - extra = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_feats", x => x.id); - table.ForeignKey( - name: "fk_feats_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "spells", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - level = table.Column(type: "integer", nullable: false), - cost = table.Column(type: "integer", nullable: false), - counteraction = table.Column(type: "boolean", nullable: false), - sustained = table.Column(type: "boolean", nullable: false), - duration = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - range = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - requirements = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - target = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - time = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - can_heightening = table.Column(type: "boolean", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_spells", x => x.id); - table.ForeignKey( - name: "fk_spells_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "traits", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - type = table.Column(type: "trait_type", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_traits", x => x.id); - table.ForeignKey( - name: "fk_traits_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "entity_externals", - columns: table => new - { - entity_id = table.Column(type: "integer", nullable: false), - target_id = table.Column(type: "integer", nullable: false), - suffix = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Часть URL до объекта. Для источников Foundry - полный UUID объекта"), - md5 = table.Column(type: "character varying(32)", maxLength: 32, nullable: false, comment: "Контроль версии объекта") - }, - constraints: table => - { - table.PrimaryKey("pk_entity_externals", x => new { x.entity_id, x.target_id }); - table.ForeignKey( - name: "fk_entity_externals_entities_entity_id", - column: x => x.entity_id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_entity_externals_external_targets_target_id", - column: x => x.target_id, - principalTable: "external_targets", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "entity_keyword", - columns: table => new - { - entities_id = table.Column(type: "integer", nullable: false), - keywords_id = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_entity_keyword", x => new { x.entities_id, x.keywords_id }); - table.ForeignKey( - name: "fk_entity_keyword_entities_entities_id", - column: x => x.entities_id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_entity_keyword_keywords_keywords_id", - column: x => x.keywords_id, - principalTable: "keywords", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "keyword_aliases", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - keyword_id = table.Column(type: "integer", nullable: false), - value = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_keyword_aliases", x => x.id); - table.ForeignKey( - name: "fk_keyword_aliases_keywords_keyword_id", - column: x => x.keyword_id, - principalTable: "keywords", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "entity_sources", - columns: table => new - { - entity_id = table.Column(type: "integer", nullable: false), - source_id = table.Column(type: "integer", nullable: false), - suffix = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Номер страницы, эррата и т.д."), - is_remaster = table.Column(type: "boolean", nullable: false, comment: "Флаг, указывающий, что объект является частью ремастера") - }, - constraints: table => - { - table.PrimaryKey("pk_entity_sources", x => new { x.entity_id, x.source_id }); - table.ForeignKey( - name: "fk_entity_sources_entities_entity_id", - column: x => x.entity_id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_entity_sources_sources_source_id", - column: x => x.source_id, - principalTable: "sources", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ancestry_boosts", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ancestry_id = table.Column(type: "integer", nullable: false), - boost = table.Column(type: "boolean", nullable: false), - value = table.Column(type: "attribute_values", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_ancestry_boosts", x => x.id); - table.ForeignKey( - name: "fk_ancestry_boosts_ancestries_ancestry_id", - column: x => x.ancestry_id, - principalTable: "ancestries", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ancestry_items", - columns: table => new - { - ancestry_id = table.Column(type: "integer", nullable: false), - item_id = table.Column(type: "integer", nullable: false), - level = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_ancestry_items", x => new { x.ancestry_id, x.item_id }); - table.ForeignKey( - name: "fk_ancestry_items_ancestries_ancestry_id", - column: x => x.ancestry_id, - principalTable: "ancestries", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_ancestry_items_entities_item_id", - column: x => x.item_id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ancestry_languages", - columns: table => new - { - ancestry_id = table.Column(type: "integer", nullable: false), - language_id = table.Column(type: "integer", nullable: false), - is_additional = table.Column(type: "boolean", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_ancestry_languages", x => new { x.ancestry_id, x.language_id }); - table.ForeignKey( - name: "fk_ancestry_languages_ancestries_ancestry_id", - column: x => x.ancestry_id, - principalTable: "ancestries", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_ancestry_languages_languages_language_id", - column: x => x.language_id, - principalTable: "languages", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "heritages", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - ancestry_id = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_heritages", x => x.id); - table.ForeignKey( - name: "fk_heritages_ancestries_ancestry_id", - column: x => x.ancestry_id, - principalTable: "ancestries", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_heritages_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "background_boosts", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - background_id = table.Column(type: "integer", nullable: false), - attribute = table.Column(type: "attribute_values", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_background_boosts", x => x.id); - table.ForeignKey( - name: "fk_background_boosts_backgrounds_background_id", - column: x => x.background_id, - principalTable: "backgrounds", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "background_items", - columns: table => new - { - background_id = table.Column(type: "integer", nullable: false), - entity_id = table.Column(type: "integer", nullable: false), - level = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_background_items", x => new { x.background_id, x.entity_id }); - table.ForeignKey( - name: "fk_background_items_backgrounds_background_id", - column: x => x.background_id, - principalTable: "backgrounds", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_background_items_entities_entity_id", - column: x => x.entity_id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "background_skills", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - background_id = table.Column(type: "integer", nullable: false), - training_id = table.Column(type: "integer", nullable: false), - level = table.Column(type: "training_stage", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_background_skills", x => x.id); - table.ForeignKey( - name: "fk_background_skills_backgrounds_background_id", - column: x => x.background_id, - principalTable: "backgrounds", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_background_skills_trainings_training_id", - column: x => x.training_id, - principalTable: "trainings", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "class_key_abilities", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - class_id = table.Column(type: "integer", nullable: false), - value = table.Column(type: "attribute_values", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_class_key_abilities", x => x.id); - table.ForeignKey( - name: "fk_class_key_abilities_classes_class_id", - column: x => x.class_id, - principalTable: "classes", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "class_progressions", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - class_id = table.Column(type: "integer", nullable: false), - type = table.Column(type: "class_progression_type", nullable: false), - entity_id = table.Column(type: "integer", nullable: true), - level = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_class_progressions", x => x.id); - table.ForeignKey( - name: "fk_class_progressions_classes_class_id", - column: x => x.class_id, - principalTable: "classes", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_class_progressions_entities_entity_id", - column: x => x.entity_id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.SetNull); - }); - - migrationBuilder.CreateTable( - name: "class_trainings", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - class_id = table.Column(type: "integer", nullable: false), - training_id = table.Column(type: "integer", nullable: true), - name = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), - stage = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_class_trainings", x => x.id); - table.ForeignKey( - name: "fk_class_trainings_classes_class_id", - column: x => x.class_id, - principalTable: "classes", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_class_trainings_trainings_training_id", - column: x => x.training_id, - principalTable: "trainings", - principalColumn: "id", - onDelete: ReferentialAction.SetNull); - }); - - migrationBuilder.CreateTable( - name: "deity_attributes", - columns: table => new - { - deity_id = table.Column(type: "integer", nullable: false), - attribute = table.Column(type: "attribute_values", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_deity_attributes", x => new { x.deity_id, x.attribute }); - table.ForeignKey( - name: "fk_deity_attributes_deities_deity_id", - column: x => x.deity_id, - principalTable: "deities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "deity_domains", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - deity_id = table.Column(type: "integer", nullable: false), - is_primary = table.Column(type: "boolean", nullable: false), - value = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_deity_domains", x => x.id); - table.ForeignKey( - name: "fk_deity_domains_deities_deity_id", - column: x => x.deity_id, - principalTable: "deities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "deity_training", - columns: table => new - { - deity_id = table.Column(type: "integer", nullable: false), - skills_id = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_deity_training", x => new { x.deity_id, x.skills_id }); - table.ForeignKey( - name: "fk_deity_training_deities_deity_id", - column: x => x.deity_id, - principalTable: "deities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_deity_training_trainings_skills_id", - column: x => x.skills_id, - principalTable: "trainings", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "deity_weapons", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - deity_id = table.Column(type: "integer", nullable: false), - weapon = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_deity_weapons", x => x.id); - table.ForeignKey( - name: "fk_deity_weapons_deities_deity_id", - column: x => x.deity_id, - principalTable: "deities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "feat_prerequisites", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - feat_id = table.Column(type: "integer", nullable: false), - value = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_feat_prerequisites", x => x.id); - table.ForeignKey( - name: "fk_feat_prerequisites_feats_feat_id", - column: x => x.feat_id, - principalTable: "feats", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "deity_spells", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - deity_id = table.Column(type: "integer", nullable: false), - level = table.Column(type: "integer", nullable: false), - spell_id = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_deity_spells", x => x.id); - table.ForeignKey( - name: "fk_deity_spells_deities_deity_id", - column: x => x.deity_id, - principalTable: "deities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_deity_spells_spells_spell_id", - column: x => x.spell_id, - principalTable: "spells", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "spell_areas", - columns: table => new - { - spell_id = table.Column(type: "integer", nullable: false), - details = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), - type = table.Column(type: "spell_area_type", nullable: false), - value = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_spell_areas", x => x.spell_id); - table.ForeignKey( - name: "fk_spell_areas_spells_spell_id", - column: x => x.spell_id, - principalTable: "spells", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "spell_damages", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - spell_id = table.Column(type: "integer", nullable: false), - key = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - apply_mod = table.Column(type: "boolean", nullable: true), - category = table.Column(type: "spell_damage_category", nullable: true), - formula = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - kinds = table.Column(type: "spell_damage_kinds", nullable: false), - materials = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), - type = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_spell_damages", x => x.id); - table.ForeignKey( - name: "fk_spell_damages_spells_spell_id", - column: x => x.spell_id, - principalTable: "spells", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "spell_defenses", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - spell_id = table.Column(type: "integer", nullable: false), - is_passive = table.Column(type: "boolean", nullable: false), - is_basic = table.Column(type: "boolean", nullable: true), - statistic = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_spell_defenses", x => x.id); - table.ForeignKey( - name: "fk_spell_defenses_spells_spell_id", - column: x => x.spell_id, - principalTable: "spells", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "spell_rituals", - columns: table => new - { - spell_id = table.Column(type: "integer", nullable: false), - primary_check = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - secondary_casters = table.Column(type: "integer", nullable: false), - secondary_checks = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_spell_rituals", x => x.spell_id); - table.ForeignKey( - name: "fk_spell_rituals_spells_spell_id", - column: x => x.spell_id, - principalTable: "spells", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "entity_trait", - columns: table => new - { - entities_id = table.Column(type: "integer", nullable: false), - traits_id = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_entity_trait", x => new { x.entities_id, x.traits_id }); - table.ForeignKey( - name: "fk_entity_trait_entities_entities_id", - column: x => x.entities_id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_entity_trait_traits_traits_id", - column: x => x.traits_id, - principalTable: "traits", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "ix_ancestry_boosts_ancestry_id", - table: "ancestry_boosts", - column: "ancestry_id"); - - migrationBuilder.CreateIndex( - name: "ix_ancestry_items_item_id", - table: "ancestry_items", - column: "item_id"); - - migrationBuilder.CreateIndex( - name: "ix_ancestry_languages_language_id", - table: "ancestry_languages", - column: "language_id"); - - migrationBuilder.CreateIndex( - name: "ix_background_boosts_background_id", - table: "background_boosts", - column: "background_id"); - - migrationBuilder.CreateIndex( - name: "ix_background_items_entity_id", - table: "background_items", - column: "entity_id"); - - migrationBuilder.CreateIndex( - name: "ix_background_skills_background_id", - table: "background_skills", - column: "background_id"); - - migrationBuilder.CreateIndex( - name: "ix_background_skills_training_id", - table: "background_skills", - column: "training_id"); - - migrationBuilder.CreateIndex( - name: "ix_class_key_abilities_class_id", - table: "class_key_abilities", - column: "class_id"); - - migrationBuilder.CreateIndex( - name: "ix_class_progressions_class_id", - table: "class_progressions", - column: "class_id"); - - migrationBuilder.CreateIndex( - name: "ix_class_progressions_entity_id", - table: "class_progressions", - column: "entity_id"); - - migrationBuilder.CreateIndex( - name: "ix_class_trainings_class_id", - table: "class_trainings", - column: "class_id"); - - migrationBuilder.CreateIndex( - name: "ix_class_trainings_training_id", - table: "class_trainings", - column: "training_id"); - - migrationBuilder.CreateIndex( - name: "ix_deity_domains_deity_id", - table: "deity_domains", - column: "deity_id"); - - migrationBuilder.CreateIndex( - name: "ix_deity_spells_deity_id", - table: "deity_spells", - column: "deity_id"); - - migrationBuilder.CreateIndex( - name: "ix_deity_spells_spell_id", - table: "deity_spells", - column: "spell_id"); - - migrationBuilder.CreateIndex( - name: "ix_deity_training_skills_id", - table: "deity_training", - column: "skills_id"); - - migrationBuilder.CreateIndex( - name: "ix_deity_weapons_deity_id", - table: "deity_weapons", - column: "deity_id"); - - migrationBuilder.CreateIndex( - name: "ix_entity_externals_target_id", - table: "entity_externals", - column: "target_id"); - - migrationBuilder.CreateIndex( - name: "ix_entity_keyword_keywords_id", - table: "entity_keyword", - column: "keywords_id"); - - migrationBuilder.CreateIndex( - name: "ix_entity_sources_source_id", - table: "entity_sources", - column: "source_id"); - - migrationBuilder.CreateIndex( - name: "ix_entity_trait_traits_id", - table: "entity_trait", - column: "traits_id"); - - migrationBuilder.CreateIndex( - name: "ix_feat_prerequisites_feat_id", - table: "feat_prerequisites", - column: "feat_id"); - - migrationBuilder.CreateIndex( - name: "ix_heritages_ancestry_id", - table: "heritages", - column: "ancestry_id"); - - migrationBuilder.CreateIndex( - name: "ix_keyword_aliases_keyword_id", - table: "keyword_aliases", - column: "keyword_id"); - - migrationBuilder.CreateIndex( - name: "ix_spell_damages_spell_id", - table: "spell_damages", - column: "spell_id"); - - migrationBuilder.CreateIndex( - name: "ix_spell_defenses_spell_id", - table: "spell_defenses", - column: "spell_id"); - - // Procedures - - migrationBuilder.Sql(""" + migrationBuilder.AlterDatabase() + .Annotation("Npgsql:Enum:action_category", "unknown,offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature") + .Annotation("Npgsql:Enum:action_type", "action,free,reaction,passive") + .Annotation("Npgsql:Enum:alias_type", "legacy,english,legacy_english,hobby,other") + .Annotation("Npgsql:Enum:ancestry_vision", "normal,low-light-vision,darkvision") + .Annotation("Npgsql:Enum:attribute_values", "any,str,dex,con,int,wis,cha") + .Annotation("Npgsql:Enum:class_progression_type", "entity,ancestry_feat,class_feat,general_feat,skill_feat,skill_increase") + .Annotation("Npgsql:Enum:condition_group", "unknown,senses,abilities,death,attitudes,detection") + .Annotation("Npgsql:Enum:deity_category", "deity,pantheon,covenant,philosophy") + .Annotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any") + .Annotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any") + .Annotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique") + .Annotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell") + .Annotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free") + .Annotation("Npgsql:Enum:feat_category", "ancestryfeature,classfeature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign_feature") + .Annotation("Npgsql:Enum:size", "med,tiny") + .Annotation("Npgsql:Enum:source_category", "rulebook,adventure-path,lost-omens") + .Annotation("Npgsql:Enum:spell_area_type", "burst,emanation,cone,line,square,cube,cylinder") + .Annotation("Npgsql:Enum:spell_damage_category", "persistent,splash") + .Annotation("Npgsql:Enum:spell_damage_kinds", "damage,healing,any") + .Annotation("Npgsql:Enum:training_stage", "untrained,trained,expert,master,legendary") + .Annotation("Npgsql:Enum:trait_type", "regular,tradition"); + + migrationBuilder.CreateTable( + name: "entities", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Отображаемое имя"), + type = table.Column(type: "entity_type", nullable: false, comment: "Тип объекта"), + slug = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Часть имени в URL"), + img = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Изображение объекта"), + description = table.Column(type: "text", nullable: false, comment: "Текстовое описание объекта"), + rarity = table.Column(type: "entity_rarity", nullable: false), + is_translated = table.Column(type: "boolean", nullable: true, comment: "Флаг, указывающий, что у объекта существует перевод"), + is_checked = table.Column(type: "boolean", nullable: true, comment: "Флаг, указывающий, что объект был проверен и не требует автоматической перезаписи") + }, + constraints: table => + { + table.PrimaryKey("pk_entities", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "external_targets", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + icon = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + prefix = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_external_targets", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "frequencies", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + max = table.Column(type: "integer", nullable: false), + per = table.Column(type: "integer", nullable: false), + value = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_frequencies", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "keywords", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + slug = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_keywords", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "languages", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + slug = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + rarity = table.Column(type: "entity_rarity", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_languages", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "sources", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + category = table.Column(type: "source_category", nullable: false), + release_date = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_sources", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "trainings", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + key = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_trainings", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "actions", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + type = table.Column(type: "action_type", nullable: false), + category = table.Column(type: "action_category", nullable: false), + actions = table.Column(type: "integer", nullable: true), + death_note = table.Column(type: "boolean", nullable: true), + extra = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_actions", x => x.id); + table.ForeignKey( + name: "fk_actions_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ancestries", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + size = table.Column(type: "size", nullable: false), + hp = table.Column(type: "integer", nullable: false), + reach = table.Column(type: "integer", nullable: false), + speed = table.Column(type: "integer", nullable: false), + vision = table.Column(type: "ancestry_vision", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_ancestries", x => x.id); + table.ForeignKey( + name: "fk_ancestries_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "backgrounds", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_backgrounds", x => x.id); + table.ForeignKey( + name: "fk_backgrounds_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "classes", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + hp = table.Column(type: "integer", nullable: false), + perception = table.Column(type: "integer", nullable: false), + spellcasting = table.Column(type: "boolean", nullable: false), + additional_trained_skills = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_classes", x => x.id); + table.ForeignKey( + name: "fk_classes_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "conditions", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + group = table.Column(type: "condition_group", nullable: true), + extra = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_conditions", x => x.id); + table.ForeignKey( + name: "fk_conditions_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "deities", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + category = table.Column(type: "deity_category", nullable: false), + fonts = table.Column(type: "deity_fonts", nullable: false), + sanctification = table.Column(type: "deity_sanctification", nullable: false), + sanctification_must = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_deities", x => x.id); + table.ForeignKey( + name: "fk_deities_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "entity_aliases", + columns: table => new + { + entity_id = table.Column(type: "integer", nullable: false), + type = table.Column(type: "alias_type", nullable: false), + alias = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_entity_aliases", x => new { x.entity_id, x.type }); + table.ForeignKey( + name: "fk_entity_aliases_entities_entity_id", + column: x => x.entity_id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "feats", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + type = table.Column(type: "action_type", nullable: false), + category = table.Column(type: "action_category", nullable: false), + actions = table.Column(type: "integer", nullable: true), + level = table.Column(type: "integer", nullable: false), + level_taken = table.Column(type: "integer", nullable: true), + max_takable = table.Column(type: "integer", nullable: true), + location = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + only_level1 = table.Column(type: "boolean", nullable: true), + extra = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_feats", x => x.id); + table.ForeignKey( + name: "fk_feats_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "spells", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + level = table.Column(type: "integer", nullable: false), + cost = table.Column(type: "integer", nullable: false), + counteraction = table.Column(type: "boolean", nullable: false), + sustained = table.Column(type: "boolean", nullable: false), + duration = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + range = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + requirements = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + target = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + time = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + can_heightening = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_spells", x => x.id); + table.ForeignKey( + name: "fk_spells_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "traits", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + type = table.Column(type: "trait_type", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_traits", x => x.id); + table.ForeignKey( + name: "fk_traits_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "entity_externals", + columns: table => new + { + entity_id = table.Column(type: "integer", nullable: false), + target_id = table.Column(type: "integer", nullable: false), + suffix = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Часть URL до объекта. Для источников Foundry - полный UUID объекта"), + md5 = table.Column(type: "character varying(32)", maxLength: 32, nullable: false, comment: "Контроль версии объекта") + }, + constraints: table => + { + table.PrimaryKey("pk_entity_externals", x => new { x.entity_id, x.target_id }); + table.ForeignKey( + name: "fk_entity_externals_entities_entity_id", + column: x => x.entity_id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_entity_externals_external_targets_target_id", + column: x => x.target_id, + principalTable: "external_targets", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "entity_keyword", + columns: table => new + { + entities_id = table.Column(type: "integer", nullable: false), + keywords_id = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_entity_keyword", x => new { x.entities_id, x.keywords_id }); + table.ForeignKey( + name: "fk_entity_keyword_entities_entities_id", + column: x => x.entities_id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_entity_keyword_keywords_keywords_id", + column: x => x.keywords_id, + principalTable: "keywords", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "keyword_aliases", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + keyword_id = table.Column(type: "integer", nullable: false), + value = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_keyword_aliases", x => x.id); + table.ForeignKey( + name: "fk_keyword_aliases_keywords_keyword_id", + column: x => x.keyword_id, + principalTable: "keywords", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "entity_sources", + columns: table => new + { + entity_id = table.Column(type: "integer", nullable: false), + source_id = table.Column(type: "integer", nullable: false), + suffix = table.Column(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Номер страницы, эррата и т.д."), + is_remaster = table.Column(type: "boolean", nullable: false, comment: "Флаг, указывающий, что объект является частью ремастера") + }, + constraints: table => + { + table.PrimaryKey("pk_entity_sources", x => new { x.entity_id, x.source_id }); + table.ForeignKey( + name: "fk_entity_sources_entities_entity_id", + column: x => x.entity_id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_entity_sources_sources_source_id", + column: x => x.source_id, + principalTable: "sources", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ancestry_boosts", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ancestry_id = table.Column(type: "integer", nullable: false), + boost = table.Column(type: "boolean", nullable: false), + value = table.Column(type: "attribute_values", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_ancestry_boosts", x => x.id); + table.ForeignKey( + name: "fk_ancestry_boosts_ancestries_ancestry_id", + column: x => x.ancestry_id, + principalTable: "ancestries", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ancestry_items", + columns: table => new + { + ancestry_id = table.Column(type: "integer", nullable: false), + item_id = table.Column(type: "integer", nullable: false), + level = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_ancestry_items", x => new { x.ancestry_id, x.item_id }); + table.ForeignKey( + name: "fk_ancestry_items_ancestries_ancestry_id", + column: x => x.ancestry_id, + principalTable: "ancestries", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_ancestry_items_entities_item_id", + column: x => x.item_id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ancestry_languages", + columns: table => new + { + ancestry_id = table.Column(type: "integer", nullable: false), + language_id = table.Column(type: "integer", nullable: false), + is_additional = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_ancestry_languages", x => new { x.ancestry_id, x.language_id }); + table.ForeignKey( + name: "fk_ancestry_languages_ancestries_ancestry_id", + column: x => x.ancestry_id, + principalTable: "ancestries", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_ancestry_languages_languages_language_id", + column: x => x.language_id, + principalTable: "languages", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "heritages", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + ancestry_id = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_heritages", x => x.id); + table.ForeignKey( + name: "fk_heritages_ancestries_ancestry_id", + column: x => x.ancestry_id, + principalTable: "ancestries", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_heritages_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "background_boosts", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + background_id = table.Column(type: "integer", nullable: false), + attribute = table.Column(type: "attribute_values", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_background_boosts", x => x.id); + table.ForeignKey( + name: "fk_background_boosts_backgrounds_background_id", + column: x => x.background_id, + principalTable: "backgrounds", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "background_items", + columns: table => new + { + background_id = table.Column(type: "integer", nullable: false), + entity_id = table.Column(type: "integer", nullable: false), + level = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_background_items", x => new { x.background_id, x.entity_id }); + table.ForeignKey( + name: "fk_background_items_backgrounds_background_id", + column: x => x.background_id, + principalTable: "backgrounds", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_background_items_entities_entity_id", + column: x => x.entity_id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "background_skills", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + background_id = table.Column(type: "integer", nullable: false), + training_id = table.Column(type: "integer", nullable: false), + level = table.Column(type: "training_stage", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_background_skills", x => x.id); + table.ForeignKey( + name: "fk_background_skills_backgrounds_background_id", + column: x => x.background_id, + principalTable: "backgrounds", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_background_skills_trainings_training_id", + column: x => x.training_id, + principalTable: "trainings", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "class_key_abilities", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + class_id = table.Column(type: "integer", nullable: false), + value = table.Column(type: "attribute_values", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_class_key_abilities", x => x.id); + table.ForeignKey( + name: "fk_class_key_abilities_classes_class_id", + column: x => x.class_id, + principalTable: "classes", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "class_progressions", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + class_id = table.Column(type: "integer", nullable: false), + type = table.Column(type: "class_progression_type", nullable: false), + entity_id = table.Column(type: "integer", nullable: true), + level = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_class_progressions", x => x.id); + table.ForeignKey( + name: "fk_class_progressions_classes_class_id", + column: x => x.class_id, + principalTable: "classes", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_class_progressions_entities_entity_id", + column: x => x.entity_id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.SetNull); + }); + + migrationBuilder.CreateTable( + name: "class_trainings", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + class_id = table.Column(type: "integer", nullable: false), + training_id = table.Column(type: "integer", nullable: true), + name = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + stage = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_class_trainings", x => x.id); + table.ForeignKey( + name: "fk_class_trainings_classes_class_id", + column: x => x.class_id, + principalTable: "classes", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_class_trainings_trainings_training_id", + column: x => x.training_id, + principalTable: "trainings", + principalColumn: "id", + onDelete: ReferentialAction.SetNull); + }); + + migrationBuilder.CreateTable( + name: "deity_attributes", + columns: table => new + { + deity_id = table.Column(type: "integer", nullable: false), + attribute = table.Column(type: "attribute_values", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_deity_attributes", x => new { x.deity_id, x.attribute }); + table.ForeignKey( + name: "fk_deity_attributes_deities_deity_id", + column: x => x.deity_id, + principalTable: "deities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "deity_domains", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + deity_id = table.Column(type: "integer", nullable: false), + is_primary = table.Column(type: "boolean", nullable: false), + value = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_deity_domains", x => x.id); + table.ForeignKey( + name: "fk_deity_domains_deities_deity_id", + column: x => x.deity_id, + principalTable: "deities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "deity_training", + columns: table => new + { + deity_id = table.Column(type: "integer", nullable: false), + skills_id = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_deity_training", x => new { x.deity_id, x.skills_id }); + table.ForeignKey( + name: "fk_deity_training_deities_deity_id", + column: x => x.deity_id, + principalTable: "deities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_deity_training_trainings_skills_id", + column: x => x.skills_id, + principalTable: "trainings", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "deity_weapons", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + deity_id = table.Column(type: "integer", nullable: false), + weapon = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_deity_weapons", x => x.id); + table.ForeignKey( + name: "fk_deity_weapons_deities_deity_id", + column: x => x.deity_id, + principalTable: "deities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "feat_prerequisites", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + feat_id = table.Column(type: "integer", nullable: false), + value = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_feat_prerequisites", x => x.id); + table.ForeignKey( + name: "fk_feat_prerequisites_feats_feat_id", + column: x => x.feat_id, + principalTable: "feats", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "deity_spells", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + deity_id = table.Column(type: "integer", nullable: false), + level = table.Column(type: "integer", nullable: false), + spell_id = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_deity_spells", x => x.id); + table.ForeignKey( + name: "fk_deity_spells_deities_deity_id", + column: x => x.deity_id, + principalTable: "deities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_deity_spells_spells_spell_id", + column: x => x.spell_id, + principalTable: "spells", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "spell_areas", + columns: table => new + { + spell_id = table.Column(type: "integer", nullable: false), + details = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + type = table.Column(type: "spell_area_type", nullable: false), + value = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_spell_areas", x => x.spell_id); + table.ForeignKey( + name: "fk_spell_areas_spells_spell_id", + column: x => x.spell_id, + principalTable: "spells", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "spell_damages", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + spell_id = table.Column(type: "integer", nullable: false), + key = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + apply_mod = table.Column(type: "boolean", nullable: true), + category = table.Column(type: "spell_damage_category", nullable: true), + formula = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + kinds = table.Column(type: "spell_damage_kinds", nullable: false), + materials = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + type = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_spell_damages", x => x.id); + table.ForeignKey( + name: "fk_spell_damages_spells_spell_id", + column: x => x.spell_id, + principalTable: "spells", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "spell_defenses", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + spell_id = table.Column(type: "integer", nullable: false), + is_passive = table.Column(type: "boolean", nullable: false), + is_basic = table.Column(type: "boolean", nullable: true), + statistic = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_spell_defenses", x => x.id); + table.ForeignKey( + name: "fk_spell_defenses_spells_spell_id", + column: x => x.spell_id, + principalTable: "spells", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "spell_rituals", + columns: table => new + { + spell_id = table.Column(type: "integer", nullable: false), + primary_check = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + secondary_casters = table.Column(type: "integer", nullable: false), + secondary_checks = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_spell_rituals", x => x.spell_id); + table.ForeignKey( + name: "fk_spell_rituals_spells_spell_id", + column: x => x.spell_id, + principalTable: "spells", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "entity_trait", + columns: table => new + { + entities_id = table.Column(type: "integer", nullable: false), + traits_id = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_entity_trait", x => new { x.entities_id, x.traits_id }); + table.ForeignKey( + name: "fk_entity_trait_entities_entities_id", + column: x => x.entities_id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_entity_trait_traits_traits_id", + column: x => x.traits_id, + principalTable: "traits", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "ix_ancestry_boosts_ancestry_id", + table: "ancestry_boosts", + column: "ancestry_id"); + + migrationBuilder.CreateIndex( + name: "ix_ancestry_items_item_id", + table: "ancestry_items", + column: "item_id"); + + migrationBuilder.CreateIndex( + name: "ix_ancestry_languages_language_id", + table: "ancestry_languages", + column: "language_id"); + + migrationBuilder.CreateIndex( + name: "ix_background_boosts_background_id", + table: "background_boosts", + column: "background_id"); + + migrationBuilder.CreateIndex( + name: "ix_background_items_entity_id", + table: "background_items", + column: "entity_id"); + + migrationBuilder.CreateIndex( + name: "ix_background_skills_background_id", + table: "background_skills", + column: "background_id"); + + migrationBuilder.CreateIndex( + name: "ix_background_skills_training_id", + table: "background_skills", + column: "training_id"); + + migrationBuilder.CreateIndex( + name: "ix_class_key_abilities_class_id", + table: "class_key_abilities", + column: "class_id"); + + migrationBuilder.CreateIndex( + name: "ix_class_progressions_class_id", + table: "class_progressions", + column: "class_id"); + + migrationBuilder.CreateIndex( + name: "ix_class_progressions_entity_id", + table: "class_progressions", + column: "entity_id"); + + migrationBuilder.CreateIndex( + name: "ix_class_trainings_class_id", + table: "class_trainings", + column: "class_id"); + + migrationBuilder.CreateIndex( + name: "ix_class_trainings_training_id", + table: "class_trainings", + column: "training_id"); + + migrationBuilder.CreateIndex( + name: "ix_deity_domains_deity_id", + table: "deity_domains", + column: "deity_id"); + + migrationBuilder.CreateIndex( + name: "ix_deity_spells_deity_id", + table: "deity_spells", + column: "deity_id"); + + migrationBuilder.CreateIndex( + name: "ix_deity_spells_spell_id", + table: "deity_spells", + column: "spell_id"); + + migrationBuilder.CreateIndex( + name: "ix_deity_training_skills_id", + table: "deity_training", + column: "skills_id"); + + migrationBuilder.CreateIndex( + name: "ix_deity_weapons_deity_id", + table: "deity_weapons", + column: "deity_id"); + + migrationBuilder.CreateIndex( + name: "ix_entity_externals_target_id", + table: "entity_externals", + column: "target_id"); + + migrationBuilder.CreateIndex( + name: "ix_entity_keyword_keywords_id", + table: "entity_keyword", + column: "keywords_id"); + + migrationBuilder.CreateIndex( + name: "ix_entity_sources_source_id", + table: "entity_sources", + column: "source_id"); + + migrationBuilder.CreateIndex( + name: "ix_entity_trait_traits_id", + table: "entity_trait", + column: "traits_id"); + + migrationBuilder.CreateIndex( + name: "ix_feat_prerequisites_feat_id", + table: "feat_prerequisites", + column: "feat_id"); + + migrationBuilder.CreateIndex( + name: "ix_heritages_ancestry_id", + table: "heritages", + column: "ancestry_id"); + + migrationBuilder.CreateIndex( + name: "ix_keyword_aliases_keyword_id", + table: "keyword_aliases", + column: "keyword_id"); + + migrationBuilder.CreateIndex( + name: "ix_spell_damages_spell_id", + table: "spell_damages", + column: "spell_id"); + + migrationBuilder.CreateIndex( + name: "ix_spell_defenses_spell_id", + table: "spell_defenses", + column: "spell_id"); + + // Procedures + + migrationBuilder.Sql(""" CREATE OR REPLACE FUNCTION f_truncate_tables() RETURNS void LANGUAGE plpgsql AS @@ -1082,7 +1081,7 @@ BEGIN END $func$; """); - migrationBuilder.Sql(""" + migrationBuilder.Sql(""" CREATE OR REPLACE FUNCTION f_drop_tables() RETURNS void LANGUAGE plpgsql AS @@ -1098,7 +1097,7 @@ BEGIN END $func$; """); - migrationBuilder.Sql(""" + migrationBuilder.Sql(""" CREATE OR REPLACE FUNCTION f_permission_tables(_username text) RETURNS void LANGUAGE plpgsql AS @@ -1117,136 +1116,135 @@ BEGIN END $func$; """); - } + } - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "actions"); + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "actions"); - migrationBuilder.DropTable( - name: "ancestry_boosts"); + migrationBuilder.DropTable( + name: "ancestry_boosts"); - migrationBuilder.DropTable( - name: "ancestry_items"); + migrationBuilder.DropTable( + name: "ancestry_items"); - migrationBuilder.DropTable( - name: "ancestry_languages"); + migrationBuilder.DropTable( + name: "ancestry_languages"); - migrationBuilder.DropTable( - name: "background_boosts"); + migrationBuilder.DropTable( + name: "background_boosts"); - migrationBuilder.DropTable( - name: "background_items"); + migrationBuilder.DropTable( + name: "background_items"); - migrationBuilder.DropTable( - name: "background_skills"); + migrationBuilder.DropTable( + name: "background_skills"); - migrationBuilder.DropTable( - name: "class_key_abilities"); + migrationBuilder.DropTable( + name: "class_key_abilities"); - migrationBuilder.DropTable( - name: "class_progressions"); + migrationBuilder.DropTable( + name: "class_progressions"); - migrationBuilder.DropTable( - name: "class_trainings"); + migrationBuilder.DropTable( + name: "class_trainings"); - migrationBuilder.DropTable( - name: "conditions"); + migrationBuilder.DropTable( + name: "conditions"); - migrationBuilder.DropTable( - name: "deity_attributes"); + migrationBuilder.DropTable( + name: "deity_attributes"); - migrationBuilder.DropTable( - name: "deity_domains"); + migrationBuilder.DropTable( + name: "deity_domains"); - migrationBuilder.DropTable( - name: "deity_spells"); + migrationBuilder.DropTable( + name: "deity_spells"); - migrationBuilder.DropTable( - name: "deity_training"); + migrationBuilder.DropTable( + name: "deity_training"); - migrationBuilder.DropTable( - name: "deity_weapons"); + migrationBuilder.DropTable( + name: "deity_weapons"); - migrationBuilder.DropTable( - name: "entity_aliases"); + migrationBuilder.DropTable( + name: "entity_aliases"); - migrationBuilder.DropTable( - name: "entity_externals"); + migrationBuilder.DropTable( + name: "entity_externals"); - migrationBuilder.DropTable( - name: "entity_keyword"); + migrationBuilder.DropTable( + name: "entity_keyword"); - migrationBuilder.DropTable( - name: "entity_sources"); + migrationBuilder.DropTable( + name: "entity_sources"); - migrationBuilder.DropTable( - name: "entity_trait"); + migrationBuilder.DropTable( + name: "entity_trait"); - migrationBuilder.DropTable( - name: "feat_prerequisites"); + migrationBuilder.DropTable( + name: "feat_prerequisites"); - migrationBuilder.DropTable( - name: "frequencies"); + migrationBuilder.DropTable( + name: "frequencies"); - migrationBuilder.DropTable( - name: "heritages"); + migrationBuilder.DropTable( + name: "heritages"); - migrationBuilder.DropTable( - name: "keyword_aliases"); + migrationBuilder.DropTable( + name: "keyword_aliases"); - migrationBuilder.DropTable( - name: "spell_areas"); + migrationBuilder.DropTable( + name: "spell_areas"); - migrationBuilder.DropTable( - name: "spell_damages"); + migrationBuilder.DropTable( + name: "spell_damages"); - migrationBuilder.DropTable( - name: "spell_defenses"); + migrationBuilder.DropTable( + name: "spell_defenses"); - migrationBuilder.DropTable( - name: "spell_rituals"); + migrationBuilder.DropTable( + name: "spell_rituals"); - migrationBuilder.DropTable( - name: "languages"); + migrationBuilder.DropTable( + name: "languages"); - migrationBuilder.DropTable( - name: "backgrounds"); + migrationBuilder.DropTable( + name: "backgrounds"); - migrationBuilder.DropTable( - name: "classes"); + migrationBuilder.DropTable( + name: "classes"); - migrationBuilder.DropTable( - name: "trainings"); + migrationBuilder.DropTable( + name: "trainings"); - migrationBuilder.DropTable( - name: "deities"); + migrationBuilder.DropTable( + name: "deities"); - migrationBuilder.DropTable( - name: "external_targets"); + migrationBuilder.DropTable( + name: "external_targets"); - migrationBuilder.DropTable( - name: "sources"); + migrationBuilder.DropTable( + name: "sources"); - migrationBuilder.DropTable( - name: "traits"); + migrationBuilder.DropTable( + name: "traits"); - migrationBuilder.DropTable( - name: "feats"); + migrationBuilder.DropTable( + name: "feats"); - migrationBuilder.DropTable( - name: "ancestries"); + migrationBuilder.DropTable( + name: "ancestries"); - migrationBuilder.DropTable( - name: "keywords"); + migrationBuilder.DropTable( + name: "keywords"); - migrationBuilder.DropTable( - name: "spells"); + migrationBuilder.DropTable( + name: "spells"); - migrationBuilder.DropTable( - name: "entities"); - } + migrationBuilder.DropTable( + name: "entities"); } } diff --git a/Pf2eDataScrapper/Migrations/20250417085326_DateOnly.cs b/Pf2eDataScrapper/Migrations/20250417085326_DateOnly.cs index bdd9575..aa84a2e 100644 --- a/Pf2eDataScrapper/Migrations/20250417085326_DateOnly.cs +++ b/Pf2eDataScrapper/Migrations/20250417085326_DateOnly.cs @@ -1,37 +1,35 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace Pf2eDataScrapper.Migrations +namespace Pf2eDataScrapper.Migrations; + +/// +public partial class DateOnly : Migration { /// - public partial class DateOnly : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "release_date", - table: "sources", - type: "date", - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone", - oldNullable: true); - } + migrationBuilder.AlterColumn( + name: "release_date", + table: "sources", + type: "date", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + } - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "release_date", - table: "sources", - type: "timestamp with time zone", - nullable: true, - oldClrType: typeof(DateOnly), - oldType: "date", - oldNullable: true); - } + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "release_date", + table: "sources", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateOnly), + oldType: "date", + oldNullable: true); } } diff --git a/Pf2eDataScrapper/Model/Base/Entity.cs b/Pf2eDataScrapper/Model/Base/Entity.cs index 9383e88..b82ad9f 100644 --- a/Pf2eDataScrapper/Model/Base/Entity.cs +++ b/Pf2eDataScrapper/Model/Base/Entity.cs @@ -2,7 +2,6 @@ using Pf2eDataScrapper.Model.Base.Keywords; using Pf2eDataScrapper.Model.Base.Source; using Pf2eDataScrapper.Model.Base.Targets; -using Pf2eDataScrapper.Model.Common; using Pf2eDataScrapper.Model.Enum; using Pf2eDataScrapper.Model.Structure; using System.ComponentModel.DataAnnotations; diff --git a/Pf2eDataScrapper/Model/Enum/ActionCategory.cs b/Pf2eDataScrapper/Model/Enum/ActionCategory.cs index 190e31d..b4e8951 100644 --- a/Pf2eDataScrapper/Model/Enum/ActionCategory.cs +++ b/Pf2eDataScrapper/Model/Enum/ActionCategory.cs @@ -1,5 +1,4 @@ using NpgsqlTypes; -using Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder; namespace Pf2eDataScrapper.Model.Enum; diff --git a/Pf2eDataScrapper/Model/Pf2eDbContextModel.cs b/Pf2eDataScrapper/Model/Pf2eDbContextModel.cs index 721e8c2..a765ed3 100644 --- a/Pf2eDataScrapper/Model/Pf2eDbContextModel.cs +++ b/Pf2eDataScrapper/Model/Pf2eDbContextModel.cs @@ -319,7 +319,7 @@ public partial class Pf2eDbContext modelBuilder.Entity(entity => { }); // Trait - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { BindEntity(entity); });