Импорт Действий (action)
This commit is contained in:
@@ -49,7 +49,7 @@ internal abstract partial class AbstractProcessor(ProcessorInput input)
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
protected string AddedDescription(string path) => $"\n\n---\n[{path}]\n\n{Input.GetOptional<string>("markdown") ?? ""}";
|
||||
protected string AddedDescription(string path) => $"\n\n---\n[{path}]\n\n{Input.GetOptional<string>(path) ?? ""}";
|
||||
|
||||
protected string AddedDescription(string[] paths) => string.Join("", paths.Select(AddedDescription));
|
||||
|
||||
@@ -174,7 +174,7 @@ internal abstract partial class AbstractProcessor(ProcessorInput input)
|
||||
|
||||
if (traitsJson?.Type != JTokenType.Array)
|
||||
{
|
||||
throw new Exception("'trait' is expected to be an array");
|
||||
return;
|
||||
}
|
||||
|
||||
IEnumerable<string> names = traitsJson.ToArray().Select(jToken => jToken.ToString());
|
||||
|
||||
@@ -43,7 +43,7 @@ internal class AonprdDataBuilder(AonprdLoader loader)
|
||||
ProgressBar bar2 = new(bars, 1, 15);
|
||||
int i = 0;
|
||||
|
||||
foreach (AonprdProcessorCollection.ProcessorItem item in Processors.Items)
|
||||
foreach (AonprdProcessorCollection.ProcessorItem item in Processors.Iterate())
|
||||
{
|
||||
bar1.Refresh(i++, $"{item.Attribute.Name}");
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processo
|
||||
[AonprdProcessor("action")]
|
||||
internal class ActionProcessor(ProcessorInput input) : AbstractProcessor(input)
|
||||
{
|
||||
public override EntityType Type => EntityType.Trait;
|
||||
public override EntityType Type => EntityType.Action;
|
||||
|
||||
public override Model.Structure.Action Object { get; } = new();
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Pf2eDataScrapper.Model;
|
||||
using Pf2eDataScrapper.Model.Enum;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Pf2eDataScrapper.Migrations
|
||||
{
|
||||
[DbContext(typeof(Pf2eDbContext))]
|
||||
[Migration("20250418062358_Function")]
|
||||
partial class Function
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Pf2eDataScrapper.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Function : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("""
|
||||
CREATE OR REPLACE FUNCTION f_truncate_tables()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql AS
|
||||
$func$
|
||||
BEGIN
|
||||
EXECUTE
|
||||
(SELECT 'TRUNCATE TABLE '
|
||||
|| string_agg(format('%I.%I', schemaname, tablename), ', ')
|
||||
|| ' CASCADE;'
|
||||
FROM pg_tables
|
||||
WHERE schemaname = 'public'
|
||||
AND tablename != '__EFMigrationsHistory'
|
||||
);
|
||||
END
|
||||
$func$;
|
||||
""");
|
||||
migrationBuilder.Sql("""
|
||||
CREATE OR REPLACE FUNCTION f_drop_tables()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql AS
|
||||
$func$
|
||||
BEGIN
|
||||
EXECUTE
|
||||
(SELECT 'DROP TABLE '
|
||||
|| string_agg(format('%I.%I', schemaname, tablename), ', ')
|
||||
|| ' CASCADE;'
|
||||
FROM pg_tables
|
||||
WHERE schemaname = 'public'
|
||||
);
|
||||
END
|
||||
$func$;
|
||||
""");
|
||||
migrationBuilder.Sql("""
|
||||
CREATE OR REPLACE FUNCTION f_permission_tables(_username text)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql AS
|
||||
$func$
|
||||
DECLARE
|
||||
_tbl text;
|
||||
_sch text;
|
||||
BEGIN
|
||||
FOR _sch, _tbl IN
|
||||
SELECT schemaname, tablename
|
||||
FROM pg_tables
|
||||
WHERE schemaname = 'public'
|
||||
LOOP
|
||||
EXECUTE format('ALTER TABLE %I.%I OWNER TO %I', _sch, _tbl, _username);
|
||||
END LOOP;
|
||||
END
|
||||
$func$;
|
||||
""");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("DROP FUNCTION f_truncate_tables;");
|
||||
migrationBuilder.Sql("DROP FUNCTION f_drop_tables;");
|
||||
migrationBuilder.Sql("DROP FUNCTION f_permission_tables;");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2054
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,106 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Pf2eDataScrapper.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EnumUpdate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("Npgsql:Enum:action_category", "unknown,offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||
.Annotation("Npgsql:Enum:action_type", "none,1_action,2_actions,3_actions,1-3_actions,1-2_actions")
|
||||
.Annotation("Npgsql:Enum:alias_type", "legacy,english,legacy_english,hobby,other")
|
||||
.Annotation("Npgsql:Enum:ancestry_vision", "normal,low-light-vision,darkvision")
|
||||
.Annotation("Npgsql:Enum:attribute_values", "any,str,dex,con,int,wis,cha")
|
||||
.Annotation("Npgsql:Enum:class_progression_type", "entity,ancestry_feat,class_feat,general_feat,skill_feat,skill_increase")
|
||||
.Annotation("Npgsql:Enum:condition_group", "unknown,senses,abilities,death,attitudes,detection")
|
||||
.Annotation("Npgsql:Enum:deity_category", "deity,pantheon,covenant,philosophy")
|
||||
.Annotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any")
|
||||
.Annotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any")
|
||||
.Annotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique")
|
||||
.Annotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||
.Annotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free")
|
||||
.Annotation("Npgsql:Enum:feat_category", "ancestryfeature,classfeature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign_feature")
|
||||
.Annotation("Npgsql:Enum:size", "med,tiny")
|
||||
.Annotation("Npgsql:Enum:source_category", "rulebook,adventure-path,lost-omens,adventures,comics,blog-posts,society")
|
||||
.Annotation("Npgsql:Enum:spell_area_type", "burst,emanation,cone,line,square,cube,cylinder")
|
||||
.Annotation("Npgsql:Enum:spell_damage_category", "persistent,splash")
|
||||
.Annotation("Npgsql:Enum:spell_damage_kinds", "damage,healing,any")
|
||||
.Annotation("Npgsql:Enum:training_stage", "untrained,trained,expert,master,legendary")
|
||||
.Annotation("Npgsql:Enum:trait_type", "regular,tradition")
|
||||
.OldAnnotation("Npgsql:Enum:action_category", "unknown,offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||
.OldAnnotation("Npgsql:Enum:action_type", "none,1_action,2_actions,3_actions,1-3_actions,1-2_actions")
|
||||
.OldAnnotation("Npgsql:Enum:alias_type", "legacy,english,legacy_english,hobby,other")
|
||||
.OldAnnotation("Npgsql:Enum:ancestry_vision", "normal,low-light-vision,darkvision")
|
||||
.OldAnnotation("Npgsql:Enum:attribute_values", "any,str,dex,con,int,wis,cha")
|
||||
.OldAnnotation("Npgsql:Enum:class_progression_type", "entity,ancestry_feat,class_feat,general_feat,skill_feat,skill_increase")
|
||||
.OldAnnotation("Npgsql:Enum:condition_group", "unknown,senses,abilities,death,attitudes,detection")
|
||||
.OldAnnotation("Npgsql:Enum:deity_category", "deity,pantheon,covenant,philosophy")
|
||||
.OldAnnotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any")
|
||||
.OldAnnotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any")
|
||||
.OldAnnotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique")
|
||||
.OldAnnotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||
.OldAnnotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free")
|
||||
.OldAnnotation("Npgsql:Enum:feat_category", "ancestryfeature,classfeature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign_feature")
|
||||
.OldAnnotation("Npgsql:Enum:size", "med,tiny")
|
||||
.OldAnnotation("Npgsql:Enum:source_category", "rulebook,adventure-path,lost-omens")
|
||||
.OldAnnotation("Npgsql:Enum:spell_area_type", "burst,emanation,cone,line,square,cube,cylinder")
|
||||
.OldAnnotation("Npgsql:Enum:spell_damage_category", "persistent,splash")
|
||||
.OldAnnotation("Npgsql:Enum:spell_damage_kinds", "damage,healing,any")
|
||||
.OldAnnotation("Npgsql:Enum:training_stage", "untrained,trained,expert,master,legendary")
|
||||
.OldAnnotation("Npgsql:Enum:trait_type", "regular,tradition");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("Npgsql:Enum:action_category", "unknown,offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||
.Annotation("Npgsql:Enum:action_type", "none,1_action,2_actions,3_actions,1-3_actions,1-2_actions")
|
||||
.Annotation("Npgsql:Enum:alias_type", "legacy,english,legacy_english,hobby,other")
|
||||
.Annotation("Npgsql:Enum:ancestry_vision", "normal,low-light-vision,darkvision")
|
||||
.Annotation("Npgsql:Enum:attribute_values", "any,str,dex,con,int,wis,cha")
|
||||
.Annotation("Npgsql:Enum:class_progression_type", "entity,ancestry_feat,class_feat,general_feat,skill_feat,skill_increase")
|
||||
.Annotation("Npgsql:Enum:condition_group", "unknown,senses,abilities,death,attitudes,detection")
|
||||
.Annotation("Npgsql:Enum:deity_category", "deity,pantheon,covenant,philosophy")
|
||||
.Annotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any")
|
||||
.Annotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any")
|
||||
.Annotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique")
|
||||
.Annotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||
.Annotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free")
|
||||
.Annotation("Npgsql:Enum:feat_category", "ancestryfeature,classfeature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign_feature")
|
||||
.Annotation("Npgsql:Enum:size", "med,tiny")
|
||||
.Annotation("Npgsql:Enum:source_category", "rulebook,adventure-path,lost-omens")
|
||||
.Annotation("Npgsql:Enum:spell_area_type", "burst,emanation,cone,line,square,cube,cylinder")
|
||||
.Annotation("Npgsql:Enum:spell_damage_category", "persistent,splash")
|
||||
.Annotation("Npgsql:Enum:spell_damage_kinds", "damage,healing,any")
|
||||
.Annotation("Npgsql:Enum:training_stage", "untrained,trained,expert,master,legendary")
|
||||
.Annotation("Npgsql:Enum:trait_type", "regular,tradition")
|
||||
.OldAnnotation("Npgsql:Enum:action_category", "unknown,offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||
.OldAnnotation("Npgsql:Enum:action_type", "none,1_action,2_actions,3_actions,1-3_actions,1-2_actions")
|
||||
.OldAnnotation("Npgsql:Enum:alias_type", "legacy,english,legacy_english,hobby,other")
|
||||
.OldAnnotation("Npgsql:Enum:ancestry_vision", "normal,low-light-vision,darkvision")
|
||||
.OldAnnotation("Npgsql:Enum:attribute_values", "any,str,dex,con,int,wis,cha")
|
||||
.OldAnnotation("Npgsql:Enum:class_progression_type", "entity,ancestry_feat,class_feat,general_feat,skill_feat,skill_increase")
|
||||
.OldAnnotation("Npgsql:Enum:condition_group", "unknown,senses,abilities,death,attitudes,detection")
|
||||
.OldAnnotation("Npgsql:Enum:deity_category", "deity,pantheon,covenant,philosophy")
|
||||
.OldAnnotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any")
|
||||
.OldAnnotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any")
|
||||
.OldAnnotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique")
|
||||
.OldAnnotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||
.OldAnnotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free")
|
||||
.OldAnnotation("Npgsql:Enum:feat_category", "ancestryfeature,classfeature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign_feature")
|
||||
.OldAnnotation("Npgsql:Enum:size", "med,tiny")
|
||||
.OldAnnotation("Npgsql:Enum:source_category", "rulebook,adventure-path,lost-omens,adventures,comics,blog-posts,society")
|
||||
.OldAnnotation("Npgsql:Enum:spell_area_type", "burst,emanation,cone,line,square,cube,cylinder")
|
||||
.OldAnnotation("Npgsql:Enum:spell_damage_category", "persistent,splash")
|
||||
.OldAnnotation("Npgsql:Enum:spell_damage_kinds", "damage,healing,any")
|
||||
.OldAnnotation("Npgsql:Enum:training_stage", "untrained,trained,expert,master,legendary")
|
||||
.OldAnnotation("Npgsql:Enum:trait_type", "regular,tradition");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,4 +15,20 @@ public enum SourceCategory
|
||||
[PgName("lost-omens")]
|
||||
[AonprdEnum("Lost Omens")]
|
||||
LostOmens,
|
||||
|
||||
[PgName("adventures")]
|
||||
[AonprdEnum("Adventures")]
|
||||
Adventures,
|
||||
|
||||
[PgName("comics")]
|
||||
[AonprdEnum("Comics")]
|
||||
Comics,
|
||||
|
||||
[PgName("blog-posts")]
|
||||
[AonprdEnum("Blog Posts")]
|
||||
BlogPosts,
|
||||
|
||||
[PgName("society")]
|
||||
[AonprdEnum("Society")]
|
||||
Society,
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ using Pf2eDataScrapper.Model.Structure.ClassRelation;
|
||||
using Pf2eDataScrapper.Model.Structure.DeityRelation;
|
||||
using Pf2eDataScrapper.Model.Structure.FeatRelation;
|
||||
using Pf2eDataScrapper.Model.Structure.SpellRelation;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pf2eDataScrapper.Model;
|
||||
|
||||
@@ -29,7 +30,7 @@ public partial class Pf2eDbContext
|
||||
DefineBase(modelBuilder);
|
||||
DefineCommon(modelBuilder);
|
||||
DefineStructure(modelBuilder);
|
||||
DefineFunctions();
|
||||
DefineFunctions(modelBuilder);
|
||||
}
|
||||
|
||||
private void DefineEnums(ModelBuilder modelBuilder)
|
||||
@@ -327,8 +328,31 @@ public partial class Pf2eDbContext
|
||||
});
|
||||
}
|
||||
|
||||
private void DefineFunctions()
|
||||
|
||||
private void DefineFunctions(ModelBuilder modelBuilder)
|
||||
{
|
||||
// modelBuilder.HasDbFunction(typeof(Pf2eDbContext).GetMethod(nameof(FTruncateTables), Array.Empty<Type>()))
|
||||
/*
|
||||
modelBuilder.HasPostgresExtension($"""
|
||||
CREATE OR REPLACE FUNCTION f_truncate_tables()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql AS
|
||||
$func$
|
||||
BEGIN
|
||||
EXECUTE (
|
||||
SELECT 'TRUNCATE TABLE '
|
||||
|| string_agg(format('%I.%I', schemaname, tablename), ', ')
|
||||
|| ' CASCADE;'
|
||||
FROM pg_tables
|
||||
WHERE schemaname = 'public'
|
||||
AND tablename != '__EFMigrationsHistory'
|
||||
);
|
||||
END
|
||||
$func$;
|
||||
""")
|
||||
;
|
||||
|
||||
/*
|
||||
Database.ExecuteSql($"""
|
||||
CREATE OR REPLACE FUNCTION f_truncate_tables()
|
||||
RETURNS void
|
||||
@@ -383,5 +407,6 @@ public partial class Pf2eDbContext
|
||||
END
|
||||
$func$;
|
||||
""");
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user