diff --git a/Pf2eDataScrapper/Importers/DatabaseHelper.cs b/Pf2eDataScrapper/Importers/DatabaseHelper.cs index f6c5208..c6a377f 100644 --- a/Pf2eDataScrapper/Importers/DatabaseHelper.cs +++ b/Pf2eDataScrapper/Importers/DatabaseHelper.cs @@ -1,4 +1,4 @@ -using Pf2eModel.Model; +using Pf2eModel; using Slugify; namespace Pf2eDataScrapper.Importers; diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdLoader.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdLoader.cs index b66fe0d..f73f641 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdLoader.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdLoader.cs @@ -42,11 +42,6 @@ internal class AonprdLoader(AonprdImporter importer) { foreach (string? file in Compendium.Files(types)) { - if (file is null) - { - continue; - } - using StreamReader fileReader = new(Path.Combine(Importer.Dir, $"{file}.json")); JArray array = JArray.Parse(fileReader.ReadToEnd()); diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AbstractProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AbstractProcessor.cs index 7be2b55..6eaba7d 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AbstractProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AbstractProcessor.cs @@ -1,5 +1,6 @@ -using LinqToDB; +using Microsoft.EntityFrameworkCore; using Newtonsoft.Json.Linq; +using Pf2eModel; using Pf2eModel.Model; using Pf2eModel.Model.Base; using Pf2eModel.Model.Base.Source; @@ -49,7 +50,7 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) Context.SaveChanges(); } - protected string AddedDescription(string path) => $"\n\n---\n[{path}]\n\n{Input.GetOptional(path) ?? ""}"; + protected string AddedDescription(string path) => $"\r\n\r\n========== [{path}] ==========\r\n\r\n{Input.GetOptional(path) ?? ""}"; protected string AddedDescription(string[] paths) => string.Join("", paths.Select(AddedDescription)); @@ -60,7 +61,7 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) Entity.Id = Helper.NextEntityId; Entity.Type = Type; Entity.Name = Input.GetRequired("name"); - Entity.Img = ""; // GetRequired("img"); + Entity.Img = ""; Entity.Description = GetDescription(); Entity.Rarity = Input.EnumOptional("rarity", EntityRarity.Common); Entity.Slug = Helper.GenerateSlug(Entity.Name); @@ -85,32 +86,33 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) JArray? legacyIdArray = Input.GetOptional("legacy_id"); - if (legacyIdArray is not null) + if (legacyIdArray is null) { - string legacyId = legacyIdArray[0].ToString(); - - if (LegacyAliases.TryGetValue(legacyId, out string? legacyName)) - { - if (legacyName != Entity.Name) - { - EntityAlias legacyAlias = new() - { - Type = AliasType.LegacyEnglish, - Alias = legacyName, - Entity = Entity - }; - - Context.EntityAliases.Add(legacyAlias); - } - - LegacyAliases.Remove(legacyId); - } - else - { - RemasterWithoutLegacy.Add(legacyId, Entity); - } + return; } + string legacyId = legacyIdArray[0].ToString(); + + if (LegacyAliases.TryGetValue(legacyId, out string? legacyName)) + { + if (legacyName != Entity.Name) + { + EntityAlias legacyAlias = new() + { + Type = AliasType.LegacyEnglish, + Alias = legacyName, + Entity = Entity + }; + + Context.EntityAliases.Add(legacyAlias); + } + + LegacyAliases.Remove(legacyId); + } + else + { + RemasterWithoutLegacy.Add(legacyId, Entity); + } } protected virtual void AddSource() @@ -185,6 +187,8 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) .ToList(); List traits = Context.Traits + .Include(t => t.Entity) + .ThenInclude(e => e.Aliases) .Where(t => traitEntities.Contains(t.Entity)) .ToList(); @@ -202,47 +206,22 @@ internal abstract partial class AbstractProcessor(ProcessorInput input) } } - - protected IEnumerable GetTraits(IEnumerable names) - { - List result = Context.Traits.Where(t => names.Contains(t.Entity.Name)).ToList(); - - foreach (string name in names) - { - if (result.Any(t => t.Entity.Name == name)) - { - continue; - } - /* - Trait trait = new() - { - Name = name, - Slug = name, - Type = TraitType.Regular, - Description = "", - }; - Context.Traits.Add(trait); - result.Add(trait); - */ - } - - return result; - } - protected void ProcessLegacy(string id, string name) { if (RemasterWithoutLegacy.TryGetValue(id, out Entity? remastered)) { - if (remastered.Name != name) + if (remastered.Name == name) { - EntityAlias alias = new() - { - Type = AliasType.LegacyEnglish, - Alias = name, - Entity = remastered! - }; - Context.EntityAliases.Add(alias); + return; } + + EntityAlias alias = new() + { + Type = AliasType.LegacyEnglish, + Alias = name, + Entity = remastered! + }; + Context.EntityAliases.Add(alias); } else { diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs index f6e1a14..107b256 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs @@ -52,7 +52,7 @@ internal class AonprdDataBuilder(AonprdLoader loader) foreach (AonprdLoader.LoaderEntry entry in Loader.Entries(item.Attribute.Type)) { - bar2.Refresh(i++, $"{entry.Id}"); + bar2.Refresh(j++, $"{entry.Id}"); AonprdProcessorInput input = new(entry.Json); AbstractProcessor processor = (AbstractProcessor) item.Constructor.Invoke([input]); @@ -68,7 +68,7 @@ internal class AonprdDataBuilder(AonprdLoader loader) } } - bar2.Refresh(j, "Processor complited"); + bar2.Refresh(j, "Processor completed"); } bar1.Refresh(i, "Done!"); diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumAttribute.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumAttribute.cs deleted file mode 100644 index 5d1e202..0000000 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder; - -[AttributeUsage(AttributeTargets.Field)] -internal class AonprdEnumAttribute(string[] values) : Attribute -{ - public readonly string[] Values = values; - - public AonprdEnumAttribute(string value) : this([value]) - { - } -} diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumResolver.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumResolver.cs index cf20b42..25c36a4 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumResolver.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdEnumResolver.cs @@ -4,7 +4,8 @@ namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder; public static class AonprdEnumResolver { private static readonly ICollection Solvers = [ - new Solver(new() { + new Solver(new() + { { "Single Action", ActionType.SingleAction }, { "Reaction or One Action", ActionType.SingleAction }, { "Free Action or One Action", ActionType.SingleAction }, @@ -16,7 +17,8 @@ public static class AonprdEnumResolver { "Single Action to Two Actions", ActionType.SingleToTwoActions }, }), - new Solver(new() { + new Solver(new() + { { "Rulebooks", SourceCategory.Rulebooks }, { "Adventure Paths", SourceCategory.AdventurePaths }, { "Lost Omens", SourceCategory.LostOmens }, @@ -25,6 +27,17 @@ public static class AonprdEnumResolver { "Blog Posts", SourceCategory.BlogPosts }, { "Society", SourceCategory.Society }, }), + + new Solver(new() + { + { "Low-Light Vision", AncestryVision.LowLightVision }, + { "Darkvision", AncestryVision.DarkVision }, + }), + + new Solver(new() + { + { "Consitution", AttributeValues.Constitution } + }) ]; public static T Resolve(string value) where T : Enum diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AncestryProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AncestryProcessor.cs new file mode 100644 index 0000000..83c4143 --- /dev/null +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AncestryProcessor.cs @@ -0,0 +1,78 @@ +using LinqToDB; +using Newtonsoft.Json.Linq; +using Pf2eModel.Model; +using Pf2eModel.Model.Enum; +using Pf2eModel.Model.Structure; +using Pf2eModel.Model.Structure.AncestryRelation; +using System.Text.RegularExpressions; + +namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors; + +[AonprdProcessor("ancestry", ["trait", "language"])] +internal class AncestryProcessor(ProcessorInput input) : AbstractProcessor(input) +{ + public override EntityType Type { get; } = EntityType.Ancestry; + + public override Ancestry Object { get; } = new Ancestry(); + + public override void Process() + { + string type = Input.GetRequired("type"); + + if (type != "Ancestry") + { + return; + } + + base.Process(); + + Object.Size = Input.GetRequired("size").Select(t => Input.Enum(t.ToString())).ToArray(); + + string hp = Input.GetRequired("hp_raw"); + Object.Hp = Convert.ToInt32((hp != "") ? hp : "0"); + + Object.Speed = Convert.ToInt32(Input.GetOptional("speed.land")); + + Object.Vision = Input.EnumOptional("vision", AncestryVision.Normal); + + AddBoosts("attribute", true); + AddBoosts("attribute_flaw", false); + + // TODO - import languages from Foundry! + // ProcessLanguages(); + } + + protected void AddBoosts(string path, bool isBoost) + { + List boosts = Input.GetOptional(path)?.ToArray().Select(t => t.ToString()).ToList() ?? []; + + if (boosts.Contains("Two free ability boosts")) + { + boosts.Remove("Two free ability boosts"); + boosts.Add("Free"); + boosts.Add("Free"); + } + + foreach (string boost in boosts) + { + AncestryBoost ancestryBoost = new() + { + Ancestry = Object, + Boost = isBoost, + Value = Input.Enum(boost), + }; + + Context.AncestryBoosts.Add(ancestryBoost); + } + } + + + + protected override string GetDescription() + => base.GetDescription() + AddedDescription([ + "source_markdown", + "summary_markdown", + "trait_markdown", + "search_markdown" + ]); +} \ No newline at end of file diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/LanguageProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/LanguageProcessor.cs new file mode 100644 index 0000000..67c76db --- /dev/null +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/LanguageProcessor.cs @@ -0,0 +1,13 @@ +using Pf2eModel.Model.Enum; +using Pf2eModel.Model.Structure; + +namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors; + +[AonprdProcessor("language")] +internal class LanguageProcessor(ProcessorInput input) : AbstractProcessor(input) +{ + public override EntityType Type { get; } = EntityType.Language; + + public override Language Object { get; } = new Language(); + +} \ No newline at end of file diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/TraitProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/TraitProcessor.cs index 22ffc87..d63854f 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/TraitProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/TraitProcessor.cs @@ -21,7 +21,7 @@ internal class TraitProcessor(ProcessorInput input) : AbstractProcessor(input) protected override void AddTraits() { - // Во втором проходе + // Необходимо пропускать } protected override string GetDescription() diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs index 816b1d8..d222cd0 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json.Linq; +using Pf2eModel; using Pf2eModel.Model; using Pf2eModel.Model.Base; using Pf2eModel.Model.Base.Source; diff --git a/Pf2eDataScrapper/Program.cs b/Pf2eDataScrapper/Program.cs index e61b2d5..e01695e 100644 --- a/Pf2eDataScrapper/Program.cs +++ b/Pf2eDataScrapper/Program.cs @@ -1,7 +1,7 @@ using Pf2eDataScrapper; using Pf2eDataScrapper.Importers.Implementations.Aonprd; -Console.SetWindowSize(Console.LargestWindowWidth - 20, Console.LargestWindowHeight - 10); +//Console.SetWindowSize(Console.LargestWindowWidth - 20, Console.LargestWindowHeight - 10); EnvSettings.Load(); diff --git a/Pf2eModel/Migrations/20250418083111_1.cs b/Pf2eModel/Migrations/20250418083111_1.cs deleted file mode 100644 index eec9c65..0000000 --- a/Pf2eModel/Migrations/20250418083111_1.cs +++ /dev/null @@ -1,1197 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Pf2eModel.Model.Enum; - -#nullable disable - -namespace Pf2eModel.Migrations; - -/// -public partial class _1 : Migration -{ - /// - 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", "none,1_action,2_actions,3_actions,1-3_actions,1-2_actions") - .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,adventures,comics,blog-posts,society") - .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: "date", 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), - actions = table.Column(type: "integer", nullable: true), - max_actions = table.Column(type: "integer", nullable: true), - is_reaction = table.Column(type: "boolean", nullable: false), - is_free_action = table.Column(type: "boolean", nullable: false), - is_passive = table.Column(type: "boolean", nullable: false), - 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"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "actions"); - - migrationBuilder.DropTable( - name: "ancestry_boosts"); - - migrationBuilder.DropTable( - name: "ancestry_items"); - - migrationBuilder.DropTable( - name: "ancestry_languages"); - - migrationBuilder.DropTable( - name: "background_boosts"); - - migrationBuilder.DropTable( - name: "background_items"); - - migrationBuilder.DropTable( - name: "background_skills"); - - migrationBuilder.DropTable( - name: "class_key_abilities"); - - migrationBuilder.DropTable( - name: "class_progressions"); - - migrationBuilder.DropTable( - name: "class_trainings"); - - migrationBuilder.DropTable( - name: "conditions"); - - migrationBuilder.DropTable( - name: "deity_attributes"); - - migrationBuilder.DropTable( - name: "deity_domains"); - - migrationBuilder.DropTable( - name: "deity_spells"); - - migrationBuilder.DropTable( - name: "deity_training"); - - migrationBuilder.DropTable( - name: "deity_weapons"); - - migrationBuilder.DropTable( - name: "entity_aliases"); - - migrationBuilder.DropTable( - name: "entity_externals"); - - migrationBuilder.DropTable( - name: "entity_keyword"); - - migrationBuilder.DropTable( - name: "entity_sources"); - - migrationBuilder.DropTable( - name: "entity_trait"); - - migrationBuilder.DropTable( - name: "feat_prerequisites"); - - migrationBuilder.DropTable( - name: "frequencies"); - - migrationBuilder.DropTable( - name: "heritages"); - - migrationBuilder.DropTable( - name: "keyword_aliases"); - - migrationBuilder.DropTable( - name: "spell_areas"); - - migrationBuilder.DropTable( - name: "spell_damages"); - - migrationBuilder.DropTable( - name: "spell_defenses"); - - migrationBuilder.DropTable( - name: "spell_rituals"); - - migrationBuilder.DropTable( - name: "languages"); - - migrationBuilder.DropTable( - name: "backgrounds"); - - migrationBuilder.DropTable( - name: "classes"); - - migrationBuilder.DropTable( - name: "trainings"); - - migrationBuilder.DropTable( - name: "deities"); - - migrationBuilder.DropTable( - name: "external_targets"); - - migrationBuilder.DropTable( - name: "sources"); - - migrationBuilder.DropTable( - name: "traits"); - - migrationBuilder.DropTable( - name: "feats"); - - migrationBuilder.DropTable( - name: "ancestries"); - - migrationBuilder.DropTable( - name: "keywords"); - - migrationBuilder.DropTable( - name: "spells"); - - migrationBuilder.DropTable( - name: "entities"); - } -} diff --git a/Pf2eModel/Migrations/20250418083111_1.Designer.cs b/Pf2eModel/Migrations/20250418160209_1.Designer.cs similarity index 99% rename from Pf2eModel/Migrations/20250418083111_1.Designer.cs rename to Pf2eModel/Migrations/20250418160209_1.Designer.cs index 6ee5aaa..802ae5f 100644 --- a/Pf2eModel/Migrations/20250418083111_1.Designer.cs +++ b/Pf2eModel/Migrations/20250418160209_1.Designer.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Pf2eModel.Model; +using Pf2eModel; using Pf2eModel.Model.Enum; #nullable disable @@ -13,7 +13,7 @@ using Pf2eModel.Model.Enum; namespace Pf2eModel.Migrations { [DbContext(typeof(Pf2eDbContext))] - [Migration("20250418083111_1")] + [Migration("20250418160209_1")] partial class _1 { /// @@ -27,8 +27,8 @@ namespace Pf2eModel.Migrations NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_category", new[] { "unknown", "offensive", "defensive", "interaction", "familiar", "army_tactic", "army_war_action", "kingdom_activity", "kingdom_feat", "kingdom_feature" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_type", new[] { "none", "1_action", "2_actions", "3_actions", "1-3_actions", "1-2_actions" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "alias_type", new[] { "legacy", "english", "legacy_english", "hobby", "other" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ancestry_vision", new[] { "normal", "low-light-vision", "darkvision" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "attribute_values", new[] { "any", "str", "dex", "con", "int", "wis", "cha" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ancestry_vision", new[] { "normal", "low-light-vision", "dark-vision" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "attribute_values", new[] { "free", "str", "dex", "con", "int", "wis", "cha" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "class_progression_type", new[] { "entity", "ancestry_feat", "class_feat", "general_feat", "skill_feat", "skill_increase" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "condition_group", new[] { "unknown", "senses", "abilities", "death", "attitudes", "detection" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_category", new[] { "deity", "pantheon", "covenant", "philosophy" }); @@ -38,7 +38,7 @@ namespace Pf2eModel.Migrations NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "ancestryfeature", "classfeature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign_feature" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "med", "tiny" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "tiny", "small", "medium", "large" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "source_category", new[] { "rulebook", "adventure-path", "lost-omens", "adventures", "comics", "blog-posts", "society" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_area_type", new[] { "burst", "emanation", "cone", "line", "square", "cube", "cylinder" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_damage_category", new[] { "persistent", "splash" }); @@ -543,25 +543,21 @@ namespace Pf2eModel.Migrations .HasColumnName("hp") .HasColumnOrder(3); - b.Property("Reach") - .HasColumnType("integer") - .HasColumnName("reach") - .HasColumnOrder(4); - - b.Property("Size") - .HasColumnType("size") + b.PrimitiveCollection("Size") + .IsRequired() + .HasColumnType("size[]") .HasColumnName("size") .HasColumnOrder(2); b.Property("Speed") .HasColumnType("integer") .HasColumnName("speed") - .HasColumnOrder(5); + .HasColumnOrder(4); b.Property("Vision") .HasColumnType("ancestry_vision") .HasColumnName("vision") - .HasColumnOrder(6); + .HasColumnOrder(5); b.HasKey("Id") .HasName("pk_ancestries"); diff --git a/Pf2eModel/Migrations/20250418160209_1.cs b/Pf2eModel/Migrations/20250418160209_1.cs new file mode 100644 index 0000000..c494f23 --- /dev/null +++ b/Pf2eModel/Migrations/20250418160209_1.cs @@ -0,0 +1,1198 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Pf2eModel.Model.Enum; + +#nullable disable + +namespace Pf2eModel.Migrations +{ + /// + public partial class _1 : Migration + { + /// + 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", "none,1_action,2_actions,3_actions,1-3_actions,1-2_actions") + .Annotation("Npgsql:Enum:alias_type", "legacy,english,legacy_english,hobby,other") + .Annotation("Npgsql:Enum:ancestry_vision", "normal,low-light-vision,dark-vision") + .Annotation("Npgsql:Enum:attribute_values", "free,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", "tiny,small,medium,large") + .Annotation("Npgsql:Enum:source_category", "rulebook,adventure-path,lost-omens,adventures,comics,blog-posts,society") + .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: "date", 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), + actions = table.Column(type: "integer", nullable: true), + max_actions = table.Column(type: "integer", nullable: true), + is_reaction = table.Column(type: "boolean", nullable: false), + is_free_action = table.Column(type: "boolean", nullable: false), + is_passive = table.Column(type: "boolean", nullable: false), + 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), + 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"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "actions"); + + migrationBuilder.DropTable( + name: "ancestry_boosts"); + + migrationBuilder.DropTable( + name: "ancestry_items"); + + migrationBuilder.DropTable( + name: "ancestry_languages"); + + migrationBuilder.DropTable( + name: "background_boosts"); + + migrationBuilder.DropTable( + name: "background_items"); + + migrationBuilder.DropTable( + name: "background_skills"); + + migrationBuilder.DropTable( + name: "class_key_abilities"); + + migrationBuilder.DropTable( + name: "class_progressions"); + + migrationBuilder.DropTable( + name: "class_trainings"); + + migrationBuilder.DropTable( + name: "conditions"); + + migrationBuilder.DropTable( + name: "deity_attributes"); + + migrationBuilder.DropTable( + name: "deity_domains"); + + migrationBuilder.DropTable( + name: "deity_spells"); + + migrationBuilder.DropTable( + name: "deity_training"); + + migrationBuilder.DropTable( + name: "deity_weapons"); + + migrationBuilder.DropTable( + name: "entity_aliases"); + + migrationBuilder.DropTable( + name: "entity_externals"); + + migrationBuilder.DropTable( + name: "entity_keyword"); + + migrationBuilder.DropTable( + name: "entity_sources"); + + migrationBuilder.DropTable( + name: "entity_trait"); + + migrationBuilder.DropTable( + name: "feat_prerequisites"); + + migrationBuilder.DropTable( + name: "frequencies"); + + migrationBuilder.DropTable( + name: "heritages"); + + migrationBuilder.DropTable( + name: "keyword_aliases"); + + migrationBuilder.DropTable( + name: "spell_areas"); + + migrationBuilder.DropTable( + name: "spell_damages"); + + migrationBuilder.DropTable( + name: "spell_defenses"); + + migrationBuilder.DropTable( + name: "spell_rituals"); + + migrationBuilder.DropTable( + name: "languages"); + + migrationBuilder.DropTable( + name: "backgrounds"); + + migrationBuilder.DropTable( + name: "classes"); + + migrationBuilder.DropTable( + name: "trainings"); + + migrationBuilder.DropTable( + name: "deities"); + + migrationBuilder.DropTable( + name: "external_targets"); + + migrationBuilder.DropTable( + name: "sources"); + + migrationBuilder.DropTable( + name: "traits"); + + migrationBuilder.DropTable( + name: "feats"); + + migrationBuilder.DropTable( + name: "ancestries"); + + migrationBuilder.DropTable( + name: "keywords"); + + migrationBuilder.DropTable( + name: "spells"); + + migrationBuilder.DropTable( + name: "entities"); + } + } +} diff --git a/Pf2eModel/Migrations/Pf2eDbContextModelSnapshot.cs b/Pf2eModel/Migrations/Pf2eDbContextModelSnapshot.cs index fd12d3e..d5cadec 100644 --- a/Pf2eModel/Migrations/Pf2eDbContextModelSnapshot.cs +++ b/Pf2eModel/Migrations/Pf2eDbContextModelSnapshot.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Pf2eModel.Model; +using Pf2eModel; using Pf2eModel.Model.Enum; #nullable disable @@ -24,8 +24,8 @@ namespace Pf2eModel.Migrations NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_category", new[] { "unknown", "offensive", "defensive", "interaction", "familiar", "army_tactic", "army_war_action", "kingdom_activity", "kingdom_feat", "kingdom_feature" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_type", new[] { "none", "1_action", "2_actions", "3_actions", "1-3_actions", "1-2_actions" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "alias_type", new[] { "legacy", "english", "legacy_english", "hobby", "other" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ancestry_vision", new[] { "normal", "low-light-vision", "darkvision" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "attribute_values", new[] { "any", "str", "dex", "con", "int", "wis", "cha" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ancestry_vision", new[] { "normal", "low-light-vision", "dark-vision" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "attribute_values", new[] { "free", "str", "dex", "con", "int", "wis", "cha" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "class_progression_type", new[] { "entity", "ancestry_feat", "class_feat", "general_feat", "skill_feat", "skill_increase" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "condition_group", new[] { "unknown", "senses", "abilities", "death", "attitudes", "detection" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_category", new[] { "deity", "pantheon", "covenant", "philosophy" }); @@ -35,7 +35,7 @@ namespace Pf2eModel.Migrations NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "ancestryfeature", "classfeature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign_feature" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "med", "tiny" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "tiny", "small", "medium", "large" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "source_category", new[] { "rulebook", "adventure-path", "lost-omens", "adventures", "comics", "blog-posts", "society" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_area_type", new[] { "burst", "emanation", "cone", "line", "square", "cube", "cylinder" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_damage_category", new[] { "persistent", "splash" }); @@ -540,25 +540,21 @@ namespace Pf2eModel.Migrations .HasColumnName("hp") .HasColumnOrder(3); - b.Property("Reach") - .HasColumnType("integer") - .HasColumnName("reach") - .HasColumnOrder(4); - - b.Property("Size") - .HasColumnType("size") + b.PrimitiveCollection("Size") + .IsRequired() + .HasColumnType("size[]") .HasColumnName("size") .HasColumnOrder(2); b.Property("Speed") .HasColumnType("integer") .HasColumnName("speed") - .HasColumnOrder(5); + .HasColumnOrder(4); b.Property("Vision") .HasColumnType("ancestry_vision") .HasColumnName("vision") - .HasColumnOrder(6); + .HasColumnOrder(5); b.HasKey("Id") .HasName("pk_ancestries"); diff --git a/Pf2eModel/Model/Common/Language.cs b/Pf2eModel/Model/Common/Language.cs deleted file mode 100644 index 198d246..0000000 --- a/Pf2eModel/Model/Common/Language.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Pf2eModel.Model.Enum; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace Pf2eModel.Model.Common; - -public partial class Language -{ - [System.ComponentModel.DataAnnotations.Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Column(Order = 1)] - public int Id { get; set; } - - [Column(Order = 2)] - [MaxLength(Pf2eDbContext.NameLength)] - public string Name { get; set; } = null!; - - [Column(Order = 3)] - [MaxLength(Pf2eDbContext.NameLength)] - public string Slug { get; set; } = null!; - - [Column(Order = 4)] - public EntityRarity Rarity { get; set; } -} diff --git a/Pf2eModel/Model/Enum/AncestryVision.cs b/Pf2eModel/Model/Enum/AncestryVision.cs index 414ddd1..fdc4124 100644 --- a/Pf2eModel/Model/Enum/AncestryVision.cs +++ b/Pf2eModel/Model/Enum/AncestryVision.cs @@ -5,11 +5,11 @@ namespace Pf2eModel.Model.Enum; public enum AncestryVision { [PgName("normal")] - normal, + Normal, [PgName("low-light-vision")] LowLightVision, - [PgName("darkvision")] - darkvision, + [PgName("dark-vision")] + DarkVision, } \ No newline at end of file diff --git a/Pf2eModel/Model/Enum/AttributeValues.cs b/Pf2eModel/Model/Enum/AttributeValues.cs index eade520..2c818c7 100644 --- a/Pf2eModel/Model/Enum/AttributeValues.cs +++ b/Pf2eModel/Model/Enum/AttributeValues.cs @@ -4,8 +4,8 @@ namespace Pf2eModel.Model.Enum; public enum AttributeValues { - [PgName("any")] - Any, + [PgName("free")] + Free, [PgName("str")] Strength, diff --git a/Pf2eModel/Model/Enum/EntityType.cs b/Pf2eModel/Model/Enum/EntityType.cs index 59a37e7..5abddc0 100644 --- a/Pf2eModel/Model/Enum/EntityType.cs +++ b/Pf2eModel/Model/Enum/EntityType.cs @@ -41,5 +41,8 @@ public enum EntityType Heritage, [PgName("spell")] - Spell + Spell, + + [PgName("language")] + Language } \ No newline at end of file diff --git a/Pf2eModel/Model/Enum/Size.cs b/Pf2eModel/Model/Enum/Size.cs index dfda57e..785e65a 100644 --- a/Pf2eModel/Model/Enum/Size.cs +++ b/Pf2eModel/Model/Enum/Size.cs @@ -4,9 +4,15 @@ namespace Pf2eModel.Model.Enum; public enum Size { - [PgName("med")] - med, - [PgName("tiny")] - tiny, + Tiny, + + [PgName("small")] + Small, + + [PgName("medium")] + Medium, + + [PgName("large")] + Large, } \ No newline at end of file diff --git a/Pf2eModel/Model/Structure/Ancestry.cs b/Pf2eModel/Model/Structure/Ancestry.cs index a02d58e..76d9d06 100644 --- a/Pf2eModel/Model/Structure/Ancestry.cs +++ b/Pf2eModel/Model/Structure/Ancestry.cs @@ -16,19 +16,16 @@ public partial class Ancestry : IEntity public Entity Entity { get; set; } = null!; [Column(Order = 2)] - public Size Size { get; set; } = Size.med; + public Size[] Size { get; set; } [Column(Order = 3)] public int Hp { get; set; } [Column(Order = 4)] - public int Reach { get; set; } - - [Column(Order = 5)] public int Speed { get; set; } - [Column(Order = 6)] - public AncestryVision Vision { get; set; } = AncestryVision.normal; + [Column(Order = 5)] + public AncestryVision Vision { get; set; } = AncestryVision.Normal; public virtual ICollection AncestryBoosts { get; set; } = []; diff --git a/Pf2eModel/Model/Structure/AncestryRelation/AncestryLanguage.cs b/Pf2eModel/Model/Structure/AncestryRelation/AncestryLanguage.cs index 8f3f518..ed34d82 100644 --- a/Pf2eModel/Model/Structure/AncestryRelation/AncestryLanguage.cs +++ b/Pf2eModel/Model/Structure/AncestryRelation/AncestryLanguage.cs @@ -1,5 +1,4 @@ using Microsoft.EntityFrameworkCore; -using Pf2eModel.Model.Common; using System.ComponentModel.DataAnnotations.Schema; namespace Pf2eModel.Model.Structure.AncestryRelation; diff --git a/Pf2eModel/Model/Structure/Language.cs b/Pf2eModel/Model/Structure/Language.cs new file mode 100644 index 0000000..9c367d6 --- /dev/null +++ b/Pf2eModel/Model/Structure/Language.cs @@ -0,0 +1,18 @@ +using Pf2eModel.Model.Base; +using Pf2eModel.Model.Enum; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Pf2eModel.Model.Structure; + +[EntityOfType(EntityType.Language)] +public partial class Language: IEntity +{ + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Column(Order = 1)] + public int Id { get; set; } + + public Entity Entity { get; set; } = null!; + +} diff --git a/Pf2eModel/Pf2eDbContext.cs b/Pf2eModel/Pf2eDbContext.cs index 335d3ee..dfa3e0f 100644 --- a/Pf2eModel/Pf2eDbContext.cs +++ b/Pf2eModel/Pf2eDbContext.cs @@ -15,7 +15,7 @@ using Pf2eModel.Model.Structure.DeityRelation; using Pf2eModel.Model.Structure.FeatRelation; using Pf2eModel.Model.Structure.SpellRelation; -namespace Pf2eModel.Model; +namespace Pf2eModel; public partial class Pf2eDbContext : DbContext { @@ -30,7 +30,7 @@ public partial class Pf2eDbContext : DbContext #region DbSets - public virtual DbSet Actions { get; set; } + public virtual DbSet Actions { get; set; } public virtual DbSet Ancestries { get; set; } diff --git a/Pf2eModel/Pf2eDbContextModel.cs b/Pf2eModel/Pf2eDbContextModel.cs index fba19e6..dfe5d36 100644 --- a/Pf2eModel/Pf2eDbContextModel.cs +++ b/Pf2eModel/Pf2eDbContextModel.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Pf2eModel.Model; using Pf2eModel.Model.Base; using Pf2eModel.Model.Base.Keywords; using Pf2eModel.Model.Base.Source; @@ -14,7 +15,7 @@ using Pf2eModel.Model.Structure.DeityRelation; using Pf2eModel.Model.Structure.FeatRelation; using Pf2eModel.Model.Structure.SpellRelation; -namespace Pf2eModel.Model; +namespace Pf2eModel; public partial class Pf2eDbContext { @@ -28,7 +29,6 @@ public partial class Pf2eDbContext DefineBase(modelBuilder); DefineCommon(modelBuilder); DefineStructure(modelBuilder); - DefineFunctions(modelBuilder); } private void DefineEnums(ModelBuilder modelBuilder) @@ -135,7 +135,7 @@ public partial class Pf2eDbContext private void DefineStructure(ModelBuilder modelBuilder) { // Action - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { BindEntity(entity); }); @@ -325,86 +325,4 @@ public partial class Pf2eDbContext BindEntity(entity); }); } - - - private void DefineFunctions(ModelBuilder modelBuilder) - { - // modelBuilder.HasDbFunction(typeof(Pf2eDbContext).GetMethod(nameof(FTruncateTables), Array.Empty())) - /* - modelBuilder.HasPostgresExtension($""" - CREATE OR REPLACE FUNCTION f_truncate_tables() - RETURNS void - LANGUAGE plpgsql AS - $func$ - BEGIN - EXECUTE ( - SELECT 'TRUNCATE TABLE ' - || string_agg(format('%I.%I', schemaname, tablename), ', ') - || ' CASCADE;' - FROM pg_tables - WHERE schemaname = 'public' - AND tablename != '__EFMigrationsHistory' - ); - END - $func$; - """) - ; - - /* - Database.ExecuteSql($""" - CREATE OR REPLACE FUNCTION f_truncate_tables() - RETURNS void - LANGUAGE plpgsql AS - $func$ - BEGIN - EXECUTE ( - SELECT 'TRUNCATE TABLE ' - || string_agg(format('%I.%I', schemaname, tablename), ', ') - || ' CASCADE;' - FROM pg_tables - WHERE schemaname = 'public' - AND tablename != '__EFMigrationsHistory' - ); - END - $func$; - """); - - Database.ExecuteSql($""" - CREATE OR REPLACE FUNCTION f_drop_tables() - RETURNS void - LANGUAGE plpgsql AS - $func$ - BEGIN - EXECUTE ( - SELECT 'DROP TABLE ' - || string_agg(format('%I.%I', schemaname, tablename), ', ') - || ' CASCADE;' - FROM pg_tables - WHERE schemaname = 'public' - ); - END - $func$; - """); - - Database.ExecuteSql($""" - CREATE OR REPLACE FUNCTION f_permission_tables(_username text) - RETURNS void - LANGUAGE plpgsql AS - $func$ - DECLARE - _tbl text; - _sch text; - BEGIN - FOR _sch, _tbl IN - SELECT schemaname, tablename - FROM pg_tables - WHERE schemaname = 'public' - LOOP - EXECUTE format('ALTER TABLE %I.%I OWNER TO %I', _sch, _tbl, _username); - END LOOP; - END - $func$; - """); - */ - } } diff --git a/Pf2eModel/Pf2eModel.csproj b/Pf2eModel/Pf2eModel.csproj index 884de5a..034bf66 100644 --- a/Pf2eModel/Pf2eModel.csproj +++ b/Pf2eModel/Pf2eModel.csproj @@ -27,4 +27,22 @@ + + + + + + + + + + + + + True + True + RebuildDatabase.bat + + + diff --git a/Pf2eModel/RebuildDatabase.bat b/Pf2eModel/RebuildDatabase.bat new file mode 100644 index 0000000..f11d736 --- /dev/null +++ b/Pf2eModel/RebuildDatabase.bat @@ -0,0 +1,10 @@ + +@echo off + +del /s .\Migrations\Pf2eDbContextModelSnapshot.cs +del /s .\Migrations\*_1.cs +del /s .\Migrations\*_1.Designer.cs + +dotnet ef database drop -f +dotnet ef migrations add 1 +dotnet ef database update \ No newline at end of file diff --git a/Pf2eViewer/EntityConventor.cs b/Pf2eViewer/EntityConverter.cs similarity index 67% rename from Pf2eViewer/EntityConventor.cs rename to Pf2eViewer/EntityConverter.cs index da6c0c8..e022d9e 100644 --- a/Pf2eViewer/EntityConventor.cs +++ b/Pf2eViewer/EntityConverter.cs @@ -1,14 +1,15 @@ using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Pf2eModel; using Pf2eModel.Model; using Pf2eModel.Model.Base; using Pf2eModel.Model.Structure; namespace Pf2eViewer; -internal class EntityConventor : JsonConverter +internal class EntityConverter : JsonConverter { - private Pf2eDbContext Context = new(); + private readonly Pf2eDbContext _context = new(); public override bool CanConvert(Type objectType) { @@ -34,48 +35,31 @@ internal class EntityConventor : JsonConverter break; } - obj.WriteTo(writer); } - JObject ProcessEntity(JObject obj, Entity e) + private JObject ProcessEntity(JObject obj, Entity e) { List traitIds = e.Traits.Select(t => t.Id).ToList(); - List traits = Context.Traits.Where(t => traitIds.Contains(t.Id)).Include(t => t.Entity).ToList(); + List traits = _context.Traits.Where(t => traitIds.Contains(t.Id)).Include(t => t.Entity).ToList(); - - foreach (JToken item in (JArray) obj.SelectToken("Traits")) + foreach (JToken item in (JArray) obj.SelectToken("Traits")!) { JObject o = (JObject) item; - int id = o.SelectToken("Id").ToObject(); + int id = o.SelectToken("Id")!.ToObject(); o.Add("Name", traits.FirstOrDefault(t => t.Id == id)!.Entity.Name); } obj.Remove("Description"); - - - + return obj; } - - + public override bool CanRead => false; public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { throw new NotImplementedException("Unnecessary because CanRead is false. The type will skip the converter."); } - - - private abstract class Conventer(JsonWriter writer, T value, JsonSerializer serializer, Pf2eDbContext context) - { - public JsonWriter Writer { get; } = writer; - public T Value { get; } = value; - public JsonSerializer Serializer { get; } = serializer; - public Pf2eDbContext Context { get; } = context; - - public abstract JObject Process(); - } - } diff --git a/Pf2eViewer/MainViewForm.Designer.cs b/Pf2eViewer/MainViewForm.Designer.cs index 9c3bb3b..103d5aa 100644 --- a/Pf2eViewer/MainViewForm.Designer.cs +++ b/Pf2eViewer/MainViewForm.Designer.cs @@ -65,8 +65,8 @@ partial class MainViewForm // RootSplitContainer.Panel2.Controls.Add(ResultSplitContainer); RootSplitContainer.Panel2MinSize = 400; - RootSplitContainer.Size = new Size(811, 688); - RootSplitContainer.SplitterDistance = 324; + RootSplitContainer.Size = new Size(1181, 688); + RootSplitContainer.SplitterDistance = 200; RootSplitContainer.TabIndex = 0; // // InnerSplitContainer @@ -83,7 +83,7 @@ partial class MainViewForm // InnerSplitContainer.Panel2 // InnerSplitContainer.Panel2.Controls.Add(EntityGridView); - InnerSplitContainer.Size = new Size(324, 688); + InnerSplitContainer.Size = new Size(200, 688); InnerSplitContainer.SplitterDistance = 274; InnerSplitContainer.TabIndex = 1; // @@ -94,7 +94,7 @@ partial class MainViewForm TypesListBox.ItemHeight = 15; TypesListBox.Location = new Point(0, 0); TypesListBox.Name = "TypesListBox"; - TypesListBox.Size = new Size(324, 274); + TypesListBox.Size = new Size(200, 274); TypesListBox.TabIndex = 0; TypesListBox.SelectedIndexChanged += TypesListBox_SelectedIndexChanged; // @@ -112,7 +112,7 @@ partial class MainViewForm EntityGridView.RowHeadersVisible = false; EntityGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; EntityGridView.ShowEditingIcon = false; - EntityGridView.Size = new Size(324, 410); + EntityGridView.Size = new Size(200, 410); EntityGridView.TabIndex = 0; EntityGridView.RowStateChanged += EntityGridView_RowStateChanged; // @@ -121,7 +121,6 @@ partial class MainViewForm ResultSplitContainer.Dock = DockStyle.Fill; ResultSplitContainer.Location = new Point(0, 0); ResultSplitContainer.Name = "ResultSplitContainer"; - ResultSplitContainer.Orientation = Orientation.Horizontal; // // ResultSplitContainer.Panel1 // @@ -130,8 +129,8 @@ partial class MainViewForm // ResultSplitContainer.Panel2 // ResultSplitContainer.Panel2.Controls.Add(DescriptionTextBox); - ResultSplitContainer.Size = new Size(483, 688); - ResultSplitContainer.SplitterDistance = 269; + ResultSplitContainer.Size = new Size(977, 688); + ResultSplitContainer.SplitterDistance = 495; ResultSplitContainer.TabIndex = 1; // // EntityTreeView @@ -139,7 +138,7 @@ partial class MainViewForm EntityTreeView.Dock = DockStyle.Fill; EntityTreeView.Location = new Point(0, 0); EntityTreeView.Name = "EntityTreeView"; - EntityTreeView.Size = new Size(483, 269); + EntityTreeView.Size = new Size(495, 688); EntityTreeView.TabIndex = 0; // // DescriptionTextBox @@ -150,14 +149,14 @@ partial class MainViewForm DescriptionTextBox.Name = "DescriptionTextBox"; DescriptionTextBox.ReadOnly = true; DescriptionTextBox.ScrollBars = ScrollBars.Vertical; - DescriptionTextBox.Size = new Size(483, 415); + DescriptionTextBox.Size = new Size(478, 688); DescriptionTextBox.TabIndex = 0; // // MainViewForm // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(811, 688); + ClientSize = new Size(1181, 688); Controls.Add(RootSplitContainer); Name = "MainViewForm"; Text = "DataBaseViewer"; diff --git a/Pf2eViewer/MainViewForm.cs b/Pf2eViewer/MainViewForm.cs index 7611271..5dfc237 100644 --- a/Pf2eViewer/MainViewForm.cs +++ b/Pf2eViewer/MainViewForm.cs @@ -29,7 +29,7 @@ public partial class MainViewForm : Form TypesListBox.SelectedIndex = 0; } - private void TypesListBox_SelectedIndexChanged(object sender, EventArgs e) + private void TypesListBox_SelectedIndexChanged(object sender, EventArgs _) { if (TypesListBox.SelectedItem is null) { @@ -39,7 +39,10 @@ public partial class MainViewForm : Form EntityGridView.DataSource = Context.Entities .Where(e => e.Type == (EntityType) TypesListBox.SelectedItem) .OrderBy(e => e.Id) - .Include(e => e.Sources).Include(e => e.Aliases).Include(e => e.Keywords).Include(e => e.Externals) + .Include(e => e.Sources) + .Include(e => e.Aliases) + .Include(e => e.Keywords) + .Include(e => e.Externals) .Include(e => e.Traits) .Select(e => new EntityGridRow(e)) .ToList(); @@ -49,7 +52,7 @@ public partial class MainViewForm : Form private void EntityGridView_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e) { int rowsCount = EntityGridView.SelectedRows.Count; - if (rowsCount == 0 || rowsCount > 1) + if (rowsCount is 0 or > 1) { return; } @@ -62,23 +65,22 @@ public partial class MainViewForm : Form JsonToTreeview(EntityTreeView, json, "Entity"); - DescriptionTextBox.Text = data.GetEntity().Description; + DescriptionTextBox.Text = data.GetEntity().Description.Replace("\\r", "").Replace("\\n", "\\r\\n"); } public string SerializeEntity(Entity entity) { - JsonSerializerSettings settings = new JsonSerializerSettings() + JsonSerializerSettings settings = new() { - Converters = [new EntityConventor()] - // ContractResolver = new CamelCasePropertyNamesContractResolver(), + Converters = [new EntityConverter()] }; string result = JsonConvert.SerializeObject(entity, settings); Type type = EntityOfTypeAttribute.Resolve(entity); - string subReuslt = JsonConvert.SerializeObject(Context.Find(type, entity.Id), settings); + string subResult = JsonConvert.SerializeObject(Context.Find(type, entity.Id), settings); - return result[..^1] + $",\"SubEntity\":{subReuslt}}}"; + return result[..^1] + $",\"SubEntity\":{subResult}}}"; } @@ -114,10 +116,7 @@ public partial class MainViewForm : Form case "JArray": JArray jArray = (JArray) element; int i = 0; - foreach (JToken oJtok in jArray) - { - subNodes.Add(Element2TreeNode(oJtok, string.Format("[{0}]", i++))); - } + subNodes.AddRange(jArray.Select(token => Element2TreeNode(token, $"[{i++}]"))); if (i == 0) { @@ -147,17 +146,11 @@ public partial class MainViewForm : Form return treeNode; } - - - - - private class EntityGridRow(Entity e) { public int Id { get; set; } = e.Id; public string Name { get; set; } = e.Name; - //public string Slug { get; set; } = e.Slug; - //public EntityRarity Rarity { get; set; } = e.Rarity; + public EntityRarity Rarity { get; set; } = e.Rarity; private readonly Entity _e = e; public Entity GetEntity() => _e;