diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AbstractSubclassProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AbstractSubclassProcessor.cs new file mode 100644 index 0000000..e9d34db --- /dev/null +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AbstractSubclassProcessor.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Pf2eModel; +using Pf2eModel.Model; +using Pf2eModel.Model.Base; +using Pf2eModel.Model.Common.I18n; +using Pf2eModel.Model.Enum; +using Pf2eModel.Model.Structure; + +namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors; + +internal abstract class AbstractSubclassProcessor(AonprdProcessorInput input) + : AbstractProcessor(input) +{ + public override EntityType Type => EntityType.Subclass; + + public abstract override Subclass Object { get; } + + public abstract string? ClassName { get; } + + public abstract string GroupName { get; } + + protected override void Add() => Context.Subclasses.Add(Object); + + public override void Process() + { + base.Process(); + + Object.Group = GetGroup(); + } + + public abstract void ProcessObject(); + + public SubclassGroup GetGroup() + { + SubclassGroup? group = Context.SubclassGroups.FirstOrDefault(g => + Pf2eDbContext.LocaleSearch(g.Entity.Name, GroupName) + ); + + if (group is null) + { + Class? cl = + (ClassName is not null) + ? Context.Classes.FirstOrDefault(c => + Pf2eDbContext.LocaleSearch(c.Entity.Name, GroupName) + ) + : null; + + Entity groupEntity = new() + { + Id = Helper.NextEntityId, + Type = EntityType.SubclassGroup, + Img = "", + Description = "", + Rarity = EntityRarity.Common, + IsTranslated = false, + IsChecked = false, + }; + + groupEntity.Name[LocaleType.English] = GroupName; + groupEntity.Slug = Helper.GenerateSlug(GroupName); + Context.Entities.Add(groupEntity); + + /* + + Entity.Id = Helper.NextEntityId; + Entity.Type = Type; + Entity.Name[LocaleType.English] = Input.GetRequired("name"); + Entity.Img = ""; + Entity.Description = GetDescription(); + Entity.Rarity = Input.EnumOptional("rarity", EntityRarity.Common); + Entity.Slug = Helper.GenerateSlug(Entity.Name[LocaleType.English]); + Entity.IsTranslated = false; + Entity.IsChecked = false; + + */ + + group = new SubclassGroup() { Entity = groupEntity, Class = cl }; + Context.SubclassGroups.Add(group); + } + + return group; + } +} diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Subclasses/ApparitionProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Subclasses/ApparitionProcessor.cs new file mode 100644 index 0000000..686ef55 --- /dev/null +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Subclasses/ApparitionProcessor.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Pf2eModel.Model.Structure; + +namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Subclasses; + +[AonprdProcessor("apparition", ["class"])] +internal class ApparitionProcessor(AonprdProcessorInput input) : AbstractSubclassProcessor(input) +{ + public override Subclass Object { get; } = new(); + + public override string? ClassName => "Animist"; + + public override string GroupName => "Apparition"; + + public override void ProcessObject() { } + + protected override string GetDescription() => + base.GetDescription() + + AddedDescription(["skill_markdown", "spell_markdown", "summary_markdown"]); +} diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/FeatProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/FeatProcessor.cs index f1ddb3e..c40264c 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/FeatProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/FeatProcessor.cs @@ -5,7 +5,7 @@ using Pf2eModel.Model.Structure; namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types; -[AonprdProcessor("feat", ["trait", "source", "archetype"])] +// [AonprdProcessor("feat", ["trait", "source", "archetype"])] internal class FeatProcessor(AonprdProcessorInput input) : AbstractProcessor(input) { public override EntityType Type => EntityType.Feat; diff --git a/Pf2eDataScrapper/Pf2eDataScrapper.csproj b/Pf2eDataScrapper/Pf2eDataScrapper.csproj index dc784c7..b3f3052 100644 --- a/Pf2eDataScrapper/Pf2eDataScrapper.csproj +++ b/Pf2eDataScrapper/Pf2eDataScrapper.csproj @@ -32,7 +32,4 @@ Always - - - diff --git a/Pf2eDataScrapper/Program.cs b/Pf2eDataScrapper/Program.cs index 935f46d..dac032a 100644 --- a/Pf2eDataScrapper/Program.cs +++ b/Pf2eDataScrapper/Program.cs @@ -11,5 +11,5 @@ Pf2EFoundryImporter importer = new(); AonprdImporter importer = new(); importer.Prepare(); -// importer.Import(); -importer.BuildSchemas(); +importer.Import(); +// importer.BuildSchemas(); diff --git a/Pf2eModel/Migrations/20250424112427_1.cs b/Pf2eModel/Migrations/20250424112427_1.cs deleted file mode 100644 index 8d7ec08..0000000 --- a/Pf2eModel/Migrations/20250424112427_1.cs +++ /dev/null @@ -1,1588 +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,archetype,class-feature,class-feat,offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature" - ) - .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,archetype,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell,language" - ) - .Annotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free") - .Annotation( - "Npgsql:Enum:feat_category", - "uncategorized,ancestry-feature,class-feature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign-feature" - ) - .Annotation( - "Npgsql:Enum:locale_type", - "english,legacy_english,russian,legacy,hobby,other" - ) - .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,class,tradition"); - - migrationBuilder.CreateTable( - name: "entities", - columns: table => new - { - id = table - .Column(type: "integer", nullable: false) - .Annotation( - "Npgsql:ValueGenerationStrategy", - NpgsqlValueGenerationStrategy.IdentityByDefaultColumn - ), - name = table.Column( - type: "jsonb", - 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: "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 - ), - name = table.Column( - type: "character varying(255)", - maxLength: 255, - nullable: false - ), - type = table.Column(type: "integer", 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), - 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), - tradition = table.Column(type: "integer", 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: "feats", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - category = table.Column(type: "action_category", nullable: false), - level = table.Column(type: "integer", 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_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: "languages", - columns: table => new - { - id = table - .Column(type: "integer", nullable: false) - .Annotation( - "Npgsql:ValueGenerationStrategy", - NpgsqlValueGenerationStrategy.IdentityByDefaultColumn - ), - entity_id = table.Column(type: "integer", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("pk_languages", x => x.id); - table.ForeignKey( - name: "fk_languages_entities_entity_id", - column: x => x.entity_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: "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) - .Annotation( - "Npgsql:ValueGenerationStrategy", - NpgsqlValueGenerationStrategy.IdentityByDefaultColumn - ), - 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: "training_stage", 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: "archetypes", - columns: table => new - { - id = table.Column(type: "integer", nullable: false), - level = table.Column(type: "integer", nullable: false), - dedication_feat_id = table.Column(type: "integer", nullable: true), - extra = table.Column(type: "text", nullable: true), - }, - constraints: table => - { - table.PrimaryKey("pk_archetypes", x => x.id); - table.ForeignKey( - name: "fk_archetypes_entities_id", - column: x => x.id, - principalTable: "entities", - principalColumn: "id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "fk_archetypes_feats_dedication_feat_id", - column: x => x.dedication_feat_id, - principalTable: "feats", - 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: "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: "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.CreateTable( - name: "archetype_feats", - columns: table => new - { - archetype_id = table.Column(type: "integer", nullable: false), - feat_id = table.Column(type: "integer", nullable: false), - }, - constraints: table => - { - table.PrimaryKey("pk_archetype_feats", x => new { x.archetype_id, x.feat_id }); - table.ForeignKey( - name: "fk_archetype_feats_archetypes_archetype_id", - column: x => x.archetype_id, - principalTable: "archetypes", - principalColumn: "id", - onDelete: ReferentialAction.Cascade - ); - table.ForeignKey( - name: "fk_archetype_feats_feats_feat_id", - column: x => x.feat_id, - principalTable: "feats", - 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_archetype_feats_feat_id", - table: "archetype_feats", - column: "feat_id" - ); - - migrationBuilder.CreateIndex( - name: "ix_archetypes_dedication_feat_id", - table: "archetypes", - column: "dedication_feat_id", - unique: true - ); - - 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_languages_entity_id", - table: "languages", - column: "entity_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: "archetype_feats"); - - 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_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: "archetypes"); - - 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: "ancestries"); - - migrationBuilder.DropTable(name: "keywords"); - - migrationBuilder.DropTable(name: "spells"); - - migrationBuilder.DropTable(name: "feats"); - - migrationBuilder.DropTable(name: "entities"); - } -} diff --git a/Pf2eModel/Migrations/20250424112427_1.Designer.cs b/Pf2eModel/Migrations/20250425111349_1.Designer.cs similarity index 95% rename from Pf2eModel/Migrations/20250424112427_1.Designer.cs rename to Pf2eModel/Migrations/20250425111349_1.Designer.cs index 2afff95..fdfd306 100644 --- a/Pf2eModel/Migrations/20250424112427_1.Designer.cs +++ b/Pf2eModel/Migrations/20250425111349_1.Designer.cs @@ -13,7 +13,7 @@ using Pf2eModel.Model.Enum; namespace Pf2eModel.Migrations { [DbContext(typeof(Pf2eDbContext))] - [Migration("20250424112427_1")] + [Migration("20250425111349_1")] partial class _1 { /// @@ -33,7 +33,7 @@ namespace Pf2eModel.Migrations NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell", "language" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "subclass_group", "subclass", "condition", "deity", "feat", "heritage", "spell", "language" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "uncategorized", "ancestry-feature", "class-feature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign-feature" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "locale_type", new[] { "english", "legacy_english", "russian", "legacy", "hobby", "other" }); @@ -1441,6 +1441,59 @@ namespace Pf2eModel.Migrations b.ToTable("spell_rituals", (string)null); }); + modelBuilder.Entity("Pf2eModel.Model.Structure.Subclass", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id") + .HasColumnOrder(1); + + b.Property("Additional") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("additional") + .HasColumnOrder(3); + + b.Property("Extra") + .IsRequired() + .HasColumnType("text") + .HasColumnName("extra"); + + b.Property("GroupId") + .HasColumnType("integer") + .HasColumnName("group_id") + .HasColumnOrder(2); + + b.HasKey("Id") + .HasName("pk_subclasses"); + + b.HasIndex("GroupId") + .HasDatabaseName("ix_subclasses_group_id"); + + b.ToTable("subclasses", (string)null); + }); + + modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id") + .HasColumnOrder(1); + + b.Property("ClassId") + .HasColumnType("integer") + .HasColumnName("class_id") + .HasColumnOrder(2); + + b.HasKey("Id") + .HasName("pk_subclass_groups"); + + b.HasIndex("ClassId") + .HasDatabaseName("ix_subclass_groups_class_id"); + + b.ToTable("subclass_groups", (string)null); + }); + modelBuilder.Entity("Pf2eModel.Model.Structure.Trait", b => { b.Property("Id") @@ -2004,6 +2057,47 @@ namespace Pf2eModel.Migrations b.Navigation("Spell"); }); + modelBuilder.Entity("Pf2eModel.Model.Structure.Subclass", b => + { + b.HasOne("Pf2eModel.Model.Structure.SubclassGroup", "Group") + .WithMany("Subclasses") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_subclasses_subclass_groups_group_id"); + + b.HasOne("Pf2eModel.Model.Base.Entity", "Entity") + .WithOne() + .HasForeignKey("Pf2eModel.Model.Structure.Subclass", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_subclasses_entities_id"); + + b.Navigation("Entity"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b => + { + b.HasOne("Pf2eModel.Model.Structure.Class", "Class") + .WithMany("SubclassGroups") + .HasForeignKey("ClassId") + .OnDelete(DeleteBehavior.Cascade) + .HasConstraintName("fk_subclass_groups_classes_class_id"); + + b.HasOne("Pf2eModel.Model.Base.Entity", "Entity") + .WithOne() + .HasForeignKey("Pf2eModel.Model.Structure.SubclassGroup", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_subclass_groups_entities_id"); + + b.Navigation("Class"); + + b.Navigation("Entity"); + }); + modelBuilder.Entity("Pf2eModel.Model.Structure.Trait", b => { b.HasOne("Pf2eModel.Model.Base.Entity", "Entity") @@ -2065,6 +2159,8 @@ namespace Pf2eModel.Migrations b.Navigation("ClassProgressions"); b.Navigation("ClassTrainings"); + + b.Navigation("SubclassGroups"); }); modelBuilder.Entity("Pf2eModel.Model.Structure.Deity", b => @@ -2093,6 +2189,11 @@ namespace Pf2eModel.Migrations b.Navigation("SpellRitual"); }); + + modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b => + { + b.Navigation("Subclasses"); + }); #pragma warning restore 612, 618 } } diff --git a/Pf2eModel/Migrations/20250425111349_1.cs b/Pf2eModel/Migrations/20250425111349_1.cs new file mode 100644 index 0000000..c58fe03 --- /dev/null +++ b/Pf2eModel/Migrations/20250425111349_1.cs @@ -0,0 +1,1318 @@ +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,archetype,class-feature,class-feat,offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature") + .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,archetype,background,backpack,campaign_feature,class,subclass_group,subclass,condition,deity,feat,heritage,spell,language") + .Annotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free") + .Annotation("Npgsql:Enum:feat_category", "uncategorized,ancestry-feature,class-feature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign-feature") + .Annotation("Npgsql:Enum:locale_type", "english,legacy_english,russian,legacy,hobby,other") + .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,class,tradition"); + + migrationBuilder.CreateTable( + name: "entities", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + name = table.Column(type: "jsonb", 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: "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), + name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + type = table.Column(type: "integer", 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), + 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), + tradition = table.Column(type: "integer", 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: "feats", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + category = table.Column(type: "action_category", nullable: false), + level = table.Column(type: "integer", 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_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: "languages", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + entity_id = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_languages", x => x.id); + table.ForeignKey( + name: "fk_languages_entities_entity_id", + column: x => x.entity_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: "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) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + 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: "training_stage", 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: "subclass_groups", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + class_id = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_subclass_groups", x => x.id); + table.ForeignKey( + name: "fk_subclass_groups_classes_class_id", + column: x => x.class_id, + principalTable: "classes", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_subclass_groups_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + 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: "archetypes", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + level = table.Column(type: "integer", nullable: false), + dedication_feat_id = table.Column(type: "integer", nullable: true), + extra = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_archetypes", x => x.id); + table.ForeignKey( + name: "fk_archetypes_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_archetypes_feats_dedication_feat_id", + column: x => x.dedication_feat_id, + principalTable: "feats", + 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: "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: "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.CreateTable( + name: "subclasses", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + group_id = table.Column(type: "integer", nullable: false), + additional = table.Column(type: "jsonb", nullable: false), + extra = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_subclasses", x => x.id); + table.ForeignKey( + name: "fk_subclasses_entities_id", + column: x => x.id, + principalTable: "entities", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_subclasses_subclass_groups_group_id", + column: x => x.group_id, + principalTable: "subclass_groups", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "archetype_feats", + columns: table => new + { + archetype_id = table.Column(type: "integer", nullable: false), + feat_id = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_archetype_feats", x => new { x.archetype_id, x.feat_id }); + table.ForeignKey( + name: "fk_archetype_feats_archetypes_archetype_id", + column: x => x.archetype_id, + principalTable: "archetypes", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_archetype_feats_feats_feat_id", + column: x => x.feat_id, + principalTable: "feats", + 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_archetype_feats_feat_id", + table: "archetype_feats", + column: "feat_id"); + + migrationBuilder.CreateIndex( + name: "ix_archetypes_dedication_feat_id", + table: "archetypes", + column: "dedication_feat_id", + unique: true); + + 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_languages_entity_id", + table: "languages", + column: "entity_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"); + + migrationBuilder.CreateIndex( + name: "ix_subclass_groups_class_id", + table: "subclass_groups", + column: "class_id"); + + migrationBuilder.CreateIndex( + name: "ix_subclasses_group_id", + table: "subclasses", + column: "group_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: "archetype_feats"); + + 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_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: "subclasses"); + + migrationBuilder.DropTable( + name: "languages"); + + migrationBuilder.DropTable( + name: "archetypes"); + + migrationBuilder.DropTable( + name: "backgrounds"); + + migrationBuilder.DropTable( + name: "trainings"); + + migrationBuilder.DropTable( + name: "deities"); + + migrationBuilder.DropTable( + name: "external_targets"); + + migrationBuilder.DropTable( + name: "sources"); + + migrationBuilder.DropTable( + name: "traits"); + + migrationBuilder.DropTable( + name: "ancestries"); + + migrationBuilder.DropTable( + name: "keywords"); + + migrationBuilder.DropTable( + name: "spells"); + + migrationBuilder.DropTable( + name: "subclass_groups"); + + migrationBuilder.DropTable( + name: "feats"); + + migrationBuilder.DropTable( + name: "classes"); + + migrationBuilder.DropTable( + name: "entities"); + } + } +} diff --git a/Pf2eModel/Migrations/Pf2eDbContextModelSnapshot.cs b/Pf2eModel/Migrations/Pf2eDbContextModelSnapshot.cs index e41ede2..230f89e 100644 --- a/Pf2eModel/Migrations/Pf2eDbContextModelSnapshot.cs +++ b/Pf2eModel/Migrations/Pf2eDbContextModelSnapshot.cs @@ -30,7 +30,7 @@ namespace Pf2eModel.Migrations NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell", "language" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "subclass_group", "subclass", "condition", "deity", "feat", "heritage", "spell", "language" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "uncategorized", "ancestry-feature", "class-feature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign-feature" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "locale_type", new[] { "english", "legacy_english", "russian", "legacy", "hobby", "other" }); @@ -1438,6 +1438,59 @@ namespace Pf2eModel.Migrations b.ToTable("spell_rituals", (string)null); }); + modelBuilder.Entity("Pf2eModel.Model.Structure.Subclass", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id") + .HasColumnOrder(1); + + b.Property("Additional") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("additional") + .HasColumnOrder(3); + + b.Property("Extra") + .IsRequired() + .HasColumnType("text") + .HasColumnName("extra"); + + b.Property("GroupId") + .HasColumnType("integer") + .HasColumnName("group_id") + .HasColumnOrder(2); + + b.HasKey("Id") + .HasName("pk_subclasses"); + + b.HasIndex("GroupId") + .HasDatabaseName("ix_subclasses_group_id"); + + b.ToTable("subclasses", (string)null); + }); + + modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id") + .HasColumnOrder(1); + + b.Property("ClassId") + .HasColumnType("integer") + .HasColumnName("class_id") + .HasColumnOrder(2); + + b.HasKey("Id") + .HasName("pk_subclass_groups"); + + b.HasIndex("ClassId") + .HasDatabaseName("ix_subclass_groups_class_id"); + + b.ToTable("subclass_groups", (string)null); + }); + modelBuilder.Entity("Pf2eModel.Model.Structure.Trait", b => { b.Property("Id") @@ -2001,6 +2054,47 @@ namespace Pf2eModel.Migrations b.Navigation("Spell"); }); + modelBuilder.Entity("Pf2eModel.Model.Structure.Subclass", b => + { + b.HasOne("Pf2eModel.Model.Structure.SubclassGroup", "Group") + .WithMany("Subclasses") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_subclasses_subclass_groups_group_id"); + + b.HasOne("Pf2eModel.Model.Base.Entity", "Entity") + .WithOne() + .HasForeignKey("Pf2eModel.Model.Structure.Subclass", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_subclasses_entities_id"); + + b.Navigation("Entity"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b => + { + b.HasOne("Pf2eModel.Model.Structure.Class", "Class") + .WithMany("SubclassGroups") + .HasForeignKey("ClassId") + .OnDelete(DeleteBehavior.Cascade) + .HasConstraintName("fk_subclass_groups_classes_class_id"); + + b.HasOne("Pf2eModel.Model.Base.Entity", "Entity") + .WithOne() + .HasForeignKey("Pf2eModel.Model.Structure.SubclassGroup", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_subclass_groups_entities_id"); + + b.Navigation("Class"); + + b.Navigation("Entity"); + }); + modelBuilder.Entity("Pf2eModel.Model.Structure.Trait", b => { b.HasOne("Pf2eModel.Model.Base.Entity", "Entity") @@ -2062,6 +2156,8 @@ namespace Pf2eModel.Migrations b.Navigation("ClassProgressions"); b.Navigation("ClassTrainings"); + + b.Navigation("SubclassGroups"); }); modelBuilder.Entity("Pf2eModel.Model.Structure.Deity", b => @@ -2090,6 +2186,11 @@ namespace Pf2eModel.Migrations b.Navigation("SpellRitual"); }); + + modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b => + { + b.Navigation("Subclasses"); + }); #pragma warning restore 612, 618 } } diff --git a/Pf2eModel/Model/Enum/EntityType.cs b/Pf2eModel/Model/Enum/EntityType.cs index 2a5b1bf..7cfd3cf 100644 --- a/Pf2eModel/Model/Enum/EntityType.cs +++ b/Pf2eModel/Model/Enum/EntityType.cs @@ -31,6 +31,12 @@ public enum EntityType [PgName("class")] Class, + [PgName("subclass_group")] + SubclassGroup, + + [PgName("subclass")] + Subclass, + [PgName("condition")] Condition, diff --git a/Pf2eModel/Model/Structure/Class.cs b/Pf2eModel/Model/Structure/Class.cs index 3adc028..a6898a2 100644 --- a/Pf2eModel/Model/Structure/Class.cs +++ b/Pf2eModel/Model/Structure/Class.cs @@ -35,4 +35,6 @@ public partial class Class : IEntity public virtual ICollection ClassProgressions { get; set; } = []; public virtual ICollection ClassTrainings { get; set; } = []; + + public virtual ICollection SubclassGroups { get; set; } = []; } diff --git a/Pf2eModel/Model/Structure/Subclass.cs b/Pf2eModel/Model/Structure/Subclass.cs index b0b53b6..9deb561 100644 --- a/Pf2eModel/Model/Structure/Subclass.cs +++ b/Pf2eModel/Model/Structure/Subclass.cs @@ -2,9 +2,11 @@ using System.ComponentModel.DataAnnotations.Schema; using Pf2eModel.Model.Base; using Pf2eModel.Model.Common.I18n; +using Pf2eModel.Model.Enum; namespace Pf2eModel.Model.Structure; +[EntityOfType(EntityType.Subclass)] public class Subclass : IEntity { [Key] @@ -14,12 +16,12 @@ public class Subclass : IEntity public Entity Entity { get; set; } = null!; [Column(Order = 2)] - public int? ClassId { get; set; } = null; + public int GroupId { get; set; } - public Class? Class { get; set; } = null!; + public SubclassGroup Group { get; set; } = null!; [Column(Order = 3)] - public LocaleString Additional { get; set; } = null!; + public LocaleString Additional { get; set; } = new(); - public string Extra { get; set; } = null!; + public string Extra { get; set; } = "{}"; } diff --git a/Pf2eModel/Model/Structure/SubclassGroup.cs b/Pf2eModel/Model/Structure/SubclassGroup.cs new file mode 100644 index 0000000..5411cb9 --- /dev/null +++ b/Pf2eModel/Model/Structure/SubclassGroup.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Pf2eModel.Model.Base; +using Pf2eModel.Model.Enum; +using Pf2eModel.Model.Structure.ClassRelation; + +namespace Pf2eModel.Model.Structure; + +[EntityOfType(EntityType.SubclassGroup)] +public class SubclassGroup : IEntity +{ + [Key] + [Column(Order = 1)] + public int Id { get; set; } + + public Entity Entity { get; set; } = null!; + + [Column(Order = 2)] + public int? ClassId { get; set; } = null; + + public Class? Class { get; set; } = null!; + + public virtual ICollection Subclasses { get; set; } = []; +} diff --git a/Pf2eModel/Pf2eDbContext.cs b/Pf2eModel/Pf2eDbContext.cs index dfdf028..f886b90 100644 --- a/Pf2eModel/Pf2eDbContext.cs +++ b/Pf2eModel/Pf2eDbContext.cs @@ -55,6 +55,10 @@ public partial class Pf2eDbContext : DbContext public virtual DbSet ClassTrainings { get; set; } + public virtual DbSet SubclassGroups { get; set; } + + public virtual DbSet Subclasses { get; set; } + public virtual DbSet Conditions { get; set; } public virtual DbSet Deities { get; set; } diff --git a/Pf2eModel/Pf2eDbContextModel.cs b/Pf2eModel/Pf2eDbContextModel.cs index 740e592..b850e1a 100644 --- a/Pf2eModel/Pf2eDbContextModel.cs +++ b/Pf2eModel/Pf2eDbContextModel.cs @@ -309,6 +309,30 @@ public partial class Pf2eDbContext .OnDelete(DeleteBehavior.SetNull); }); + // Subclass + modelBuilder.Entity(entity => + { + BindEntity(entity); + + entity + .HasOne(g => g.Class) + .WithMany(c => c.SubclassGroups) + .HasForeignKey(g => g.ClassId) + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity(entity => + { + BindEntity(entity); + + BindLocaleString(entity, s => s.Additional); + + entity + .HasOne(s => s.Group) + .WithMany(g => g.Subclasses) + .HasForeignKey(s => s.GroupId) + .OnDelete(DeleteBehavior.Cascade); + }); + // Condition modelBuilder.Entity(entity => {