Продолжение работы
This commit is contained in:
+1
-1
@@ -21,6 +21,6 @@ internal class CompendiumFolderCollection : List<CompendiumFolder>
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public CompendiumFolderCollection Filter()
|
public CompendiumFolderCollection Filter()
|
||||||
{
|
{
|
||||||
return [.. this.FindAll(x => x.Type != CompendiumDocumentType.Actor)];
|
return [.. this.FindAll(x => x.Type == CompendiumDocumentType.Item)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+97
-39
@@ -1,20 +1,26 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
using LinqToDB.Common;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using NpgsqlTypes;
|
using NpgsqlTypes;
|
||||||
using Pf2eDataScrapper.Model;
|
using Pf2eDataScrapper.Model;
|
||||||
using Pf2eDataScrapper.Model.Base;
|
using Pf2eDataScrapper.Model.Base;
|
||||||
using Pf2eDataScrapper.Model.Base.Source;
|
using Pf2eDataScrapper.Model.Base.Source;
|
||||||
|
using Pf2eDataScrapper.Model.Base.Targets;
|
||||||
|
using Pf2eDataScrapper.Model.Common;
|
||||||
using Pf2eDataScrapper.Model.Enum;
|
using Pf2eDataScrapper.Model.Enum;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using static LinqToDB.Reflection.Methods.LinqToDB.Insert;
|
||||||
|
|
||||||
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder;
|
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder;
|
||||||
|
|
||||||
internal abstract class AbstractProcessor(JObject input)
|
internal abstract class AbstractProcessor(JObject input)
|
||||||
{
|
{
|
||||||
public readonly Pf2eDbContext Context = new();
|
protected DataBuilderHelper Helper = DataBuilderHelper.Instance;
|
||||||
|
|
||||||
|
public readonly Pf2eDbContext Context = DataBuilderHelper.DbContext;
|
||||||
|
|
||||||
public readonly JObject Input = input;
|
public readonly JObject Input = input;
|
||||||
|
|
||||||
protected DataBuilderHelper Helper = DataBuilderHelper.Instance;
|
|
||||||
|
|
||||||
public Entity Entity { get; set; } = new();
|
public Entity Entity { get; set; } = new();
|
||||||
|
|
||||||
public abstract EntityType Type { get; }
|
public abstract EntityType Type { get; }
|
||||||
@@ -34,6 +40,7 @@ internal abstract class AbstractProcessor(JObject input)
|
|||||||
Entity.IsChecked = false;
|
Entity.IsChecked = false;
|
||||||
|
|
||||||
Entity.Slug = Helper.GenerateSlug(Entity.Name);
|
Entity.Slug = Helper.GenerateSlug(Entity.Name);
|
||||||
|
Entity.Rarity = EnumOptional<EntityRarity>("system.traits.rarity", EntityRarity.Common);
|
||||||
|
|
||||||
Object.Id = Entity.Id;
|
Object.Id = Entity.Id;
|
||||||
|
|
||||||
@@ -52,22 +59,37 @@ internal abstract class AbstractProcessor(JObject input)
|
|||||||
// Source
|
// Source
|
||||||
EntitySource source = new()
|
EntitySource source = new()
|
||||||
{
|
{
|
||||||
EntityId = Entity.Id,
|
|
||||||
Entity = Entity,
|
Entity = Entity,
|
||||||
|
|
||||||
Source = GetSource(),
|
Source = GetSource(GetRequired<string>("system.publication.title")),
|
||||||
|
|
||||||
Suffix = GetRequired<string>("_id"),
|
Suffix = "",
|
||||||
IsRemaster = GetRequired<bool>("system.publication.remaster")
|
IsRemaster = GetRequired<bool>("system.publication.remaster")
|
||||||
};
|
};
|
||||||
Context.EntitySources.Add(source);
|
Context.EntitySources.Add(source);
|
||||||
|
|
||||||
|
// External
|
||||||
|
EntityExternal external = new()
|
||||||
|
{
|
||||||
|
Entity = Entity,
|
||||||
|
Target = GetTarget(),
|
||||||
|
Suffix = GetRequired<string>("_id"),
|
||||||
|
Md5 = Md5(Input.ToString())
|
||||||
|
};
|
||||||
|
Context.EntityExternals.Add(external);
|
||||||
|
|
||||||
// Traits
|
// Traits
|
||||||
JToken? traits = Input.SelectToken("system.traits");
|
JToken? traitsJson = Input.SelectToken("system.traits.value");
|
||||||
|
|
||||||
Console.WriteLine($"{Entity.Name} - Traits: {traits}");
|
if (traitsJson?.Type != JTokenType.Array)
|
||||||
|
{
|
||||||
|
throw new Exception("system.traits.value is expected to be an array");
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Traits, Alias
|
foreach(var trait in GetTraits(traitsJson.ToArray().Select(jToken => jToken.ToString())))
|
||||||
|
{
|
||||||
|
Entity.Traits.Add(trait);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
@@ -91,44 +113,25 @@ internal abstract class AbstractProcessor(JObject input)
|
|||||||
|
|
||||||
public T EnumRequired<T>(string path) where T : Enum
|
public T EnumRequired<T>(string path) where T : Enum
|
||||||
{
|
{
|
||||||
return EnumOptional<T>(path) ?? throw new Exception($"Can't resolve Enum value for {typeof(T).Name} in path {path}");
|
string value = GetOptional<string>(path) ?? throw new NullReferenceException($"Value in path {path} null or not exists");
|
||||||
|
|
||||||
|
return DataBuilderHelper.Enum<T>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? EnumOptional<T>(string path) where T : Enum
|
public T EnumOptional<T>(string path, T defaultValue) where T : Enum
|
||||||
{
|
{
|
||||||
string? value = GetOptional<string>(path);
|
string? value = GetOptional<string>(path);
|
||||||
|
|
||||||
if (value == null)
|
if (value is null)
|
||||||
{
|
{
|
||||||
return default;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (System.Reflection.FieldInfo field in typeof(T).GetFields())
|
return DataBuilderHelper.Enum<T>(value);
|
||||||
{
|
|
||||||
if (Attribute.GetCustomAttribute(field, typeof(PgNameAttribute)) is PgNameAttribute attribute)
|
|
||||||
{
|
|
||||||
if (attribute.PgName == value)
|
|
||||||
{
|
|
||||||
return (T) field.GetValue(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (field.Name == value)
|
|
||||||
{
|
|
||||||
return (T) field.GetValue(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return default;
|
protected Source GetSource(string name)
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected Source GetSource()
|
|
||||||
{
|
{
|
||||||
string name = "pf2e - Foundry module";
|
|
||||||
|
|
||||||
Source? source = Context.Sources.Where(s => s.Name == name).FirstOrDefault();
|
Source? source = Context.Sources.Where(s => s.Name == name).FirstOrDefault();
|
||||||
|
|
||||||
if (source != null)
|
if (source != null)
|
||||||
@@ -138,11 +141,66 @@ internal abstract class AbstractProcessor(JObject input)
|
|||||||
|
|
||||||
source = new()
|
source = new()
|
||||||
{
|
{
|
||||||
Name = "pf2e - Foundry module",
|
Name = name,
|
||||||
Url = "https://github.com/foundryvtt/pf2e"
|
Url = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
Context.Sources.Add(source);
|
Context.Sources.Add(source);
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ExternalTarget GetTarget()
|
||||||
|
{
|
||||||
|
string name = "pf2e - Foundry module";
|
||||||
|
|
||||||
|
ExternalTarget? target = Context.ExternalTargets.Where(s => s.Name == name).FirstOrDefault();
|
||||||
|
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
target = new()
|
||||||
|
{
|
||||||
|
Name = "pf2e - Foundry module",
|
||||||
|
Icon = "",
|
||||||
|
Prefix = "https://github.com/foundryvtt/pf2e",
|
||||||
|
};
|
||||||
|
|
||||||
|
Context.ExternalTargets.Add(target);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IEnumerable<Trait> GetTraits(IEnumerable<string> names)
|
||||||
|
{
|
||||||
|
var result = Context.Traits.Where(t => names.Contains(t.Name)).ToList();
|
||||||
|
|
||||||
|
foreach (var name in names)
|
||||||
|
{
|
||||||
|
if (result.Any(t => t.Name == name))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Trait trait = new()
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
Slug = name,
|
||||||
|
Type = TraitType.Regular,
|
||||||
|
Description = "",
|
||||||
|
};
|
||||||
|
Context.Traits.Add(trait);
|
||||||
|
result.Add(trait);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Md5(string input, bool isLowercase = false)
|
||||||
|
{
|
||||||
|
using var md5 = MD5.Create();
|
||||||
|
var byteHash = md5.ComputeHash(Encoding.UTF8.GetBytes(input));
|
||||||
|
var hash = BitConverter.ToString(byteHash).Replace("-", "");
|
||||||
|
return (isLowercase) ? hash.ToLower() : hash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-1
@@ -1,4 +1,6 @@
|
|||||||
using Slugify;
|
using NpgsqlTypes;
|
||||||
|
using Pf2eDataScrapper.Model;
|
||||||
|
using Slugify;
|
||||||
|
|
||||||
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder;
|
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder;
|
||||||
|
|
||||||
@@ -6,6 +8,8 @@ internal class DataBuilderHelper
|
|||||||
{
|
{
|
||||||
public Pf2eDatabase Database = Pf2eDatabase.Instance;
|
public Pf2eDatabase Database = Pf2eDatabase.Instance;
|
||||||
|
|
||||||
|
public Pf2eDbContext Context = new();
|
||||||
|
|
||||||
public SlugHelper Slugger = new();
|
public SlugHelper Slugger = new();
|
||||||
|
|
||||||
private DataBuilderHelper()
|
private DataBuilderHelper()
|
||||||
@@ -23,5 +27,32 @@ internal class DataBuilderHelper
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static T Enum<T>(string value) where T : Enum
|
||||||
|
{
|
||||||
|
foreach (System.Reflection.FieldInfo field in typeof(T).GetFields())
|
||||||
|
{
|
||||||
|
List<string> variants = [field.Name];
|
||||||
|
|
||||||
|
if (Attribute.GetCustomAttribute(field, typeof(PgNameAttribute)) is PgNameAttribute attribute)
|
||||||
|
{
|
||||||
|
variants.Add(attribute.PgName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (variants.Contains(value))
|
||||||
|
{
|
||||||
|
return (T) field.GetValue(null)!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InvalidEnumStringException(typeof(T), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class InvalidEnumStringException(Type type, string value) : Exception($"Invalid value '{value}' for enum type {type.FullName}.")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static readonly DataBuilderHelper Instance = new();
|
public static readonly DataBuilderHelper Instance = new();
|
||||||
|
|
||||||
|
public static readonly Pf2eDbContext DbContext = Instance.Context;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ internal class ActionProcessor(JObject input) : AbstractProcessor(input)
|
|||||||
|
|
||||||
|
|
||||||
Object.Type = EnumRequired<ActionType>("system.actionType.value");
|
Object.Type = EnumRequired<ActionType>("system.actionType.value");
|
||||||
Object.Category = EnumRequired<ActionCategory>("system.category");
|
Object.Category = EnumOptional<ActionCategory>("system.category", ActionCategory.Unknown);
|
||||||
Object.Actions = GetOptional<int>("system.actions.value");
|
Object.Actions = GetOptional<int>("system.actions.value");
|
||||||
Object.DeathNote = GetOptional<bool>("system.deathNote");
|
Object.DeathNote = GetOptional<bool>("system.deathNote");
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ internal class ConditionProcessor(JObject input) : AbstractProcessor(input)
|
|||||||
};
|
};
|
||||||
|
|
||||||
Object.Extra = extra.ToString(Newtonsoft.Json.Formatting.None);
|
Object.Extra = extra.ToString(Newtonsoft.Json.Formatting.None);
|
||||||
Object.Group = EnumOptional<ConditionGroup>("system.group");
|
Object.Group = EnumOptional<ConditionGroup>("system.group", ConditionGroup.Unknown);
|
||||||
|
|
||||||
Context.Conditions.Add(Object);
|
Context.Conditions.Add(Object);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2051
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,119 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Pf2eDataScrapper.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class _ : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterDatabase()
|
||||||
|
.Annotation("Npgsql:Enum:action_category", "offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||||
|
.Annotation("Npgsql:Enum:action_type", "action,free,reaction,passive")
|
||||||
|
.Annotation("Npgsql:Enum:alias_type", "old,english,old_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,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||||
|
.Annotation("Npgsql:Enum:enum_size", "med,tiny")
|
||||||
|
.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: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", "offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||||
|
.OldAnnotation("Npgsql:Enum:action_type", "action,free,reaction,passive")
|
||||||
|
.OldAnnotation("Npgsql:Enum:alias_type", "old,english,old_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", "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,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||||
|
.OldAnnotation("Npgsql:Enum:enum_size", "med,tiny")
|
||||||
|
.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: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");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "prefix",
|
||||||
|
table: "external_targets",
|
||||||
|
type: "character varying(255)",
|
||||||
|
maxLength: 255,
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "")
|
||||||
|
.Annotation("Relational:ColumnOrder", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "prefix",
|
||||||
|
table: "external_targets");
|
||||||
|
|
||||||
|
migrationBuilder.AlterDatabase()
|
||||||
|
.Annotation("Npgsql:Enum:action_category", "offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||||
|
.Annotation("Npgsql:Enum:action_type", "action,free,reaction,passive")
|
||||||
|
.Annotation("Npgsql:Enum:alias_type", "old,english,old_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", "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,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||||
|
.Annotation("Npgsql:Enum:enum_size", "med,tiny")
|
||||||
|
.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: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", "offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||||
|
.OldAnnotation("Npgsql:Enum:action_type", "action,free,reaction,passive")
|
||||||
|
.OldAnnotation("Npgsql:Enum:alias_type", "old,english,old_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,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||||
|
.OldAnnotation("Npgsql:Enum:enum_size", "med,tiny")
|
||||||
|
.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: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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+2051
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 ActionCategoryUnknown : 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", "action,free,reaction,passive")
|
||||||
|
.Annotation("Npgsql:Enum:alias_type", "old,english,old_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,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||||
|
.Annotation("Npgsql:Enum:enum_size", "med,tiny")
|
||||||
|
.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: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", "offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||||
|
.OldAnnotation("Npgsql:Enum:action_type", "action,free,reaction,passive")
|
||||||
|
.OldAnnotation("Npgsql:Enum:alias_type", "old,english,old_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,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||||
|
.OldAnnotation("Npgsql:Enum:enum_size", "med,tiny")
|
||||||
|
.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: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", "offensive,defensive,interaction,familiar,army_tactic,army_war_action,kingdom_activity,kingdom_feat,kingdom_feature")
|
||||||
|
.Annotation("Npgsql:Enum:action_type", "action,free,reaction,passive")
|
||||||
|
.Annotation("Npgsql:Enum:alias_type", "old,english,old_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,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||||
|
.Annotation("Npgsql:Enum:enum_size", "med,tiny")
|
||||||
|
.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: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", "action,free,reaction,passive")
|
||||||
|
.OldAnnotation("Npgsql:Enum:alias_type", "old,english,old_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,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell")
|
||||||
|
.OldAnnotation("Npgsql:Enum:enum_size", "med,tiny")
|
||||||
|
.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: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
@@ -0,0 +1,42 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Pf2eDataScrapper.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Md5Length : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "md5",
|
||||||
|
table: "entity_externals",
|
||||||
|
type: "character varying(32)",
|
||||||
|
maxLength: 32,
|
||||||
|
nullable: false,
|
||||||
|
comment: "Контроль версии объекта",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "character varying(16)",
|
||||||
|
oldMaxLength: 16,
|
||||||
|
oldComment: "Контроль версии объекта");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "md5",
|
||||||
|
table: "entity_externals",
|
||||||
|
type: "character varying(16)",
|
||||||
|
maxLength: 16,
|
||||||
|
nullable: false,
|
||||||
|
comment: "Контроль версии объекта",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "character varying(32)",
|
||||||
|
oldMaxLength: 32,
|
||||||
|
oldComment: "Контроль версии объекта");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -18,5 +18,5 @@ public partial class Source
|
|||||||
[MaxLength(255)]
|
[MaxLength(255)]
|
||||||
public string Url { get; set; } = null!;
|
public string Url { get; set; } = null!;
|
||||||
|
|
||||||
public ICollection<EntitySource> EntitySources { get; set; } = new List<EntitySource>();
|
public ICollection<EntitySource> EntitySources { get; set; } = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public partial class EntityExternal
|
|||||||
public string Suffix { get; set; } = "";
|
public string Suffix { get; set; } = "";
|
||||||
|
|
||||||
[Column(Order = 3)]
|
[Column(Order = 3)]
|
||||||
[MaxLength(16)]
|
[MaxLength(32)]
|
||||||
[Comment("Контроль версии объекта")]
|
[Comment("Контроль версии объекта")]
|
||||||
public string Md5 { get; set; } = null!;
|
public string Md5 { get; set; } = null!;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ public partial class ExternalTarget
|
|||||||
[StringLength(255)]
|
[StringLength(255)]
|
||||||
public string Icon { get; set; } = null!;
|
public string Icon { get; set; } = null!;
|
||||||
|
|
||||||
|
[Column(Order = 3)]
|
||||||
|
[StringLength(Pf2eDbContext.NameLength)]
|
||||||
|
public string Prefix { get; set; } = null!;
|
||||||
|
|
||||||
[Column(Order = 4)]
|
[Column(Order = 4)]
|
||||||
public virtual ICollection<EntityExternal> EntityExternals { get; set; } = [];
|
public virtual ICollection<EntityExternal> EntityExternals { get; set; } = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,19 @@ namespace Pf2eDataScrapper.Model.Enum;
|
|||||||
|
|
||||||
public enum ActionCategory
|
public enum ActionCategory
|
||||||
{
|
{
|
||||||
|
Unknown,
|
||||||
|
|
||||||
[PgName("offensive")]
|
[PgName("offensive")]
|
||||||
offensive,
|
Offensive,
|
||||||
|
|
||||||
[PgName("defensive")]
|
[PgName("defensive")]
|
||||||
defensive,
|
Defensive,
|
||||||
|
|
||||||
[PgName("interaction")]
|
[PgName("interaction")]
|
||||||
interaction,
|
Interaction,
|
||||||
|
|
||||||
[PgName("familiar")]
|
[PgName("familiar")]
|
||||||
familiar,
|
Familiar,
|
||||||
|
|
||||||
[PgName("army_tactic")]
|
[PgName("army_tactic")]
|
||||||
ArmyTactic,
|
ArmyTactic,
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ namespace Pf2eDataScrapper.Model.Enum;
|
|||||||
|
|
||||||
public enum ConditionGroup
|
public enum ConditionGroup
|
||||||
{
|
{
|
||||||
|
[PgName("unknown")]
|
||||||
|
Unknown,
|
||||||
|
|
||||||
[PgName("senses")]
|
[PgName("senses")]
|
||||||
Senses,
|
Senses,
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public partial class Pf2eDbContext : DbContext
|
|||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
EnvSettings.Load();
|
EnvSettings.Load();
|
||||||
optionsBuilder.LogTo(Console.WriteLine);
|
// optionsBuilder.LogTo(Console.WriteLine);
|
||||||
optionsBuilder.UseSnakeCaseNamingConvention();
|
optionsBuilder.UseSnakeCaseNamingConvention();
|
||||||
optionsBuilder.UseNpgsql(EnvSettings.DatabaseConnection,
|
optionsBuilder.UseNpgsql(EnvSettings.DatabaseConnection,
|
||||||
builder =>
|
builder =>
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public partial class Pf2eDbContext
|
|||||||
DefineBase(modelBuilder);
|
DefineBase(modelBuilder);
|
||||||
DefineCommon(modelBuilder);
|
DefineCommon(modelBuilder);
|
||||||
DefineStructure(modelBuilder);
|
DefineStructure(modelBuilder);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DefineEnums(ModelBuilder modelBuilder)
|
private void DefineEnums(ModelBuilder modelBuilder)
|
||||||
@@ -302,7 +304,7 @@ public partial class Pf2eDbContext
|
|||||||
.IsRequired(false);
|
.IsRequired(false);
|
||||||
|
|
||||||
entity.HasOne(e => e.SpellRitual).WithOne(e => e.Spell)
|
entity.HasOne(e => e.SpellRitual).WithOne(e => e.Spell)
|
||||||
.HasForeignKey<SpellArea>(e => e.SpellId)
|
.HasForeignKey<SpellRitual>(e => e.SpellId)
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired(false);
|
.IsRequired(false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user