Большая пачка изменений

This commit is contained in:
2025-04-17 17:11:46 +04:00
parent 2ed5c2e5c5
commit a0eb739363
40 changed files with 990 additions and 6800 deletions
@@ -0,0 +1,33 @@
using Pf2eDataScrapper.Model;
using Slugify;
namespace Pf2eDataScrapper.Importers;
public class DatabaseHelper
{
public Pf2eDbContext Context = new();
public SlugHelper Slugger = new();
private int _id = 0;
public int NextEntityId { get => ++_id; set => _id = value; }
private DatabaseHelper()
{
NextEntityId = Context.Entities.Any() ? Context.Entities.Max(e => e.Id) : 0;
}
public string GenerateSlug(string name)
{
return Slugger.GenerateSlug(name);
}
public static readonly DatabaseHelper Instance = new();
public static readonly Pf2eDbContext DbContext = Instance.Context;
}
@@ -1,11 +1,12 @@
using Pf2eDataScrapper.Importers.Implementations.Aonprd.SchemaBuilder;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.SchemaBuilder;
using Pf2eDataScrapper.Importers.Repositories;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd;
internal class AonprdImporter : AbstractImporter
{
public override string Name => "Archives of Nethys Pathfinder 2e";
public override string Name => SourceName;
public override string Slug => "aonprd";
@@ -34,6 +35,11 @@ internal class AonprdImporter : AbstractImporter
public override void Import()
{
throw new NotImplementedException();
AonprdDataBuilder builder = new(Loader);
builder.TruncateTables();
builder.Build();
}
public const string SourceName = "Archives of Nethys Pathfinder 2e";
}
@@ -9,7 +9,7 @@ internal class AonprdLoader(AonprdImporter importer)
public AonprdCompendium Compendium = new();
public int ItemCount => Compendium.Count;
public int ItemCount => Compendium.Count();
public void Prepare()
{
@@ -18,10 +18,14 @@ internal class AonprdCompendium
}
}
public int Count => Types.Values.Sum(x => x.Count);
public int Count() => Types.Values.Sum(t => t.Count);
public int Count(IEnumerable<string> types) => Types.Values
.Where(t => types.Contains(t.Type))
.Sum(t => t.Count);
public IEnumerable<string> Files(IEnumerable<string> types) => Types.Values
.Where(t => types.Contains(t.Type))
.SelectMany(t => t.Files)
.Distinct();
}
@@ -0,0 +1,265 @@
using LinqToDB;
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.Model;
using Pf2eDataScrapper.Model.Base;
using Pf2eDataScrapper.Model.Base.Source;
using Pf2eDataScrapper.Model.Base.Targets;
using Pf2eDataScrapper.Model.Enum;
using Pf2eDataScrapper.Model.Structure;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
internal abstract partial class AbstractProcessor(ProcessorInput input)
{
protected DatabaseHelper Helper = DatabaseHelper.Instance;
public readonly Pf2eDbContext Context = DatabaseHelper.DbContext;
public readonly ProcessorInput Input = input;
public Entity Entity { get; set; } = new();
public abstract EntityType Type { get; }
public abstract IEntity Object { get; }
public virtual void Process()
{
if (Input.GetOptional<JArray>("remaster_id") is not null)
{
string id = Input.GetRequired<string>("id");
string name = Input.GetRequired<string>("name");
ProcessLegacy(id, name);
throw new LegacyItemException(name);
}
AddEntity();
AddAlias();
AddSource();
AddExternal();
AddTraits();
}
public void Save()
{
Context.SaveChanges();
}
protected virtual void AddEntity()
{
Entity.Id = Helper.NextEntityId;
Entity.Type = Type;
Entity.Name = Input.GetRequired<string>("name");
Entity.Img = ""; // GetRequired<string>("img");
Entity.Description = Input.GetRequired<string>("markdown");
Entity.Rarity = Input.EnumOptional<EntityRarity>("rarity", EntityRarity.Common);
Entity.Slug = Helper.GenerateSlug(Entity.Name);
Entity.IsTranslated = false;
Entity.IsChecked = false;
Object.Id = Entity.Id;
Context.Entities.Add(Entity);
}
protected virtual void AddAlias()
{
EntityAlias alias = new()
{
Type = AliasType.English,
Alias = Entity.Name,
Entity = Entity
};
Context.EntityAliases.Add(alias);
var legacyIdArray = Input.GetOptional<JArray>("legacy_id");
if (legacyIdArray is not null)
{
string legacyId = legacyIdArray[0].ToString();
if (LegacyAliases.TryGetValue(legacyId, out var legacyName))
{
if (legacyName != Entity.Name)
{
EntityAlias legacyAlias = new()
{
Type = AliasType.LegacyEnglish,
Alias = legacyName,
Entity = Entity
};
Context.EntityAliases.Add(legacyAlias);
}
LegacyAliases.Remove(legacyId);
}
else
{
RemasterWithoutLegacy.Add(legacyId, Entity);
}
}
}
protected virtual void AddSource()
{
string name = Input.GetRequired<string>("source[0]");
Source? source = Context.Sources.FirstOrDefault(s => s.Name == name);
if (source == null)
{
source = new()
{
Name = name,
Category = Input.EnumRequired<SourceCategory>("primary_source_category"),
ReleaseDate = DateOnly.Parse(Input.GetRequired<string>("release_date")),
};
Context.Sources.Add(source);
}
string sourceMarkdown = Input.GetRequired<string>("source_markdown");
Match match = SourceSuffixRegex().Match(sourceMarkdown);
EntitySource entitySource = new()
{
Entity = Entity,
Source = source,
Suffix = ((match?.Captures.Count > 0) ? match?.Captures[0]?.Value : "") ?? "",
IsRemaster = Input.GetOptional<JArray>("legacy_id") is not null
};
Context.EntitySources.Add(entitySource);
}
protected virtual void AddExternal()
{
if (AonprdTarget is null)
{
AonprdTarget = Context.ExternalTargets.FirstOrDefault(t => t.Name == AonprdImporter.SourceName);
AonprdTarget ??= new()
{
Name = AonprdImporter.SourceName,
Icon = "http://www.google.com/s2/favicons?domain=2e.aonprd.com",
Prefix = "https://2e.aonprd.com",
};
}
EntityExternal external = new()
{
Entity = Entity,
Target = AonprdTarget,
Suffix = Input.GetRequired<string>("url"),
Md5 = Md5(Input.Input.ToString())
};
Context.EntityExternals.Add(external);
}
protected virtual void AddTraits()
{
JToken? traitsJson = Input.Input.SelectToken("trait");
if (traitsJson?.Type != JTokenType.Array)
{
throw new Exception("'trait' is expected to be an array");
}
var names = traitsJson.ToArray().Select(jToken => jToken.ToString());
var traitEntities = Context.Traits
.SelectMany(t => t.Entity.Aliases)
.Where(a => names.Contains(a.Alias))
.Select(a => a.Entity)
.ToList();
var traits = Context.Traits
.Where(t => traitEntities.Contains(t.Entity))
.ToList();
foreach (string name in names)
{
if (!traits.Any(t => t.Entity.Aliases.Select(a => a.Alias).Contains(name)))
{
throw new Exception($"Trait '{name}' is not found!!!");
}
}
foreach (Trait trait in traits)
{
Entity.Traits.Add(trait);
}
}
protected IEnumerable<Trait> GetTraits(IEnumerable<string> names)
{
List<Trait> result = Context.Traits.Where(t => names.Contains(t.Entity.Name)).ToList();
foreach (string name in names)
{
if (result.Any(t => t.Entity.Name == name))
{
continue;
}
/*
Trait trait = new()
{
Name = name,
Slug = name,
Type = TraitType.Regular,
Description = "",
};
Context.Traits.Add(trait);
result.Add(trait);
*/
}
return result;
}
protected void ProcessLegacy(string id, string name)
{
if (RemasterWithoutLegacy.TryGetValue(id, out Entity? remastered))
{
if (remastered.Name != name)
{
EntityAlias alias = new()
{
Type = AliasType.LegacyEnglish,
Alias = name,
Entity = remastered!
};
Context.EntityAliases.Add(alias);
}
}
else
{
LegacyAliases.Add(id, name);
}
}
public static string Md5(string input, bool isLowercase = false)
{
using MD5 md5 = MD5.Create();
byte[] byteHash = md5.ComputeHash(Encoding.UTF8.GetBytes(input));
string hash = BitConverter.ToString(byteHash).Replace("-", "");
return (isLowercase) ? hash.ToLower() : hash;
}
protected static ExternalTarget? AonprdTarget = null;
protected static Dictionary<string, string> LegacyAliases = [];
protected static Dictionary<string, Entity> RemasterWithoutLegacy = [];
[GeneratedRegex(@"^\[.*?\]\(.*?\)\s+(.*)$")]
private static partial Regex SourceSuffixRegex();
public class LegacyItemException(string name) : Exception($"Item '{name}' is linked with newer version, skipping.") { }
}
@@ -0,0 +1,84 @@
using Konsole;
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium;
using Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.Compendium;
using Pf2eDataScrapper.Model.Base;
using System;
using System.ComponentModel;
using System.Reflection;
using static Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.AbstractProcessor;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
internal class AonprdDataBuilder(AonprdLoader loader)
{
public Pf2eDatabase Database = Pf2eDatabase.Instance;
/// <summary>
/// Загрузчик данных.
/// </summary>
public readonly AonprdLoader Loader = loader;
/// <summary>
/// Коллекция папок компендиума.
/// </summary>
public AonprdCompendium Compendium => Loader.Compendium;
public AonprdProcessorCollection Processors = new();
public void TruncateTables()
{
Console.WriteLine("Truncating all old data...");
Database.ExecuteCommand("SELECT f_truncate_tables();");
Console.WriteLine("Truncation completed!");
}
public void Build()
{
Console.WriteLine("Building data...");
var window = new Window(0, 0, Console.WindowWidth, Console.WindowHeight).Concurrent();
var bars = window.OpenBox("Progress", Console.WindowWidth, 4, new BoxStyle { Body = Colors.WhiteOnBlack });
var output = new Window(0, 4, Console.WindowWidth, Console.WindowHeight - 4, window);
ProgressBar bar1 = new(bars, Loader.ItemCount, 15);
ProgressBar bar2 = new(bars, 1, 15);
int i = 0;
foreach (var item in Processors.Items)
{
bar1.Refresh(i++, $"{item.Attribute.Name}");
bar2.Max = Compendium.Count([item.Attribute.Type]);
int j = 0;
foreach(var entry in Loader.Entries(item.Attribute.Type))
{
bar2.Refresh(i++, $"{entry.Id}");
var input = new ProcessorInput(entry.Json);
var processor = (AbstractProcessor) item.Constructor.Invoke([input]);
try
{
processor.Process();
processor.Save();
}
catch (LegacyItemException ex)
{
output.WriteLine(ex.Message);
}
}
bar2.Refresh(j, "Processor complited");
}
bar1.Refresh(i, "Done!");
window.Clear();
}
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
[AttributeUsage(AttributeTargets.Field)]
internal class AonprdEnumAttribute(string value) : Attribute
{
public readonly string Value = value;
}
@@ -0,0 +1,21 @@
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
[AttributeUsage(AttributeTargets.Class)]
public class AonprdProcessorAttribute(string name, string type, string[] dependencies) : Attribute
{
public readonly string Name = name;
public readonly string Type = type;
public readonly IEnumerable<string> Dependencies = dependencies;
public AonprdProcessorAttribute(string type) : this(type, type, [])
{
}
public AonprdProcessorAttribute(string type, string[] dependencies) : this(type, type, dependencies)
{
}
public AonprdProcessorAttribute(string name, string type) : this(name, type, [])
{
}
}
@@ -0,0 +1,88 @@
using System.Reflection;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
internal class AonprdProcessorCollection
{
public class ProcessorItem(AonprdProcessorAttribute attribute, ConstructorInfo constructor)
{
public readonly AonprdProcessorAttribute Attribute = attribute;
public readonly ConstructorInfo Constructor = constructor;
public int Priority = -1;
}
public readonly List<ProcessorItem> Items = [];
public AonprdProcessorCollection()
{
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
{
if (type.GetCustomAttributes(typeof(AonprdProcessorAttribute), true).Length <= 0)
{
continue;
}
if (!type.IsSubclassOf(typeof(AbstractProcessor)))
{
throw new Exception($"'AonprdProcessor' attribute should only be applied to children of 'AbstractProcessor' class. '{type.FullName}' is not.");
}
AonprdProcessorAttribute attribute = type.GetCustomAttribute<AonprdProcessorAttribute>()!;
ConstructorInfo constructor = type.GetConstructor([typeof(ProcessorInput)])!;
var collision = Items.FirstOrDefault(i => i.Attribute.Name == attribute.Name);
if (collision is not null)
{
throw new Exception($"Multiply attributes 'AonprdProcessor' have same name '{attribute.Name}'." +
$" They are added to classes: '{type.FullName}' and '{collision.Constructor.DeclaringType!.FullName}'");
}
Items.Add(new ProcessorItem(attribute, constructor));
}
}
private void SortItems()
{
Dictionary<string, int> priorities = [];
while (priorities.Count < Items.Count)
{
foreach (var item in Items)
{
if (item.Priority > 0)
{
continue;
}
var dependencyPriorities = item.Attribute.Dependencies.Select(d => priorities.TryGetValue(d, out int value) ? value : -1);
if (dependencyPriorities.Any(p => p == -1))
{
continue;
}
item.Priority = dependencyPriorities.Any() ? dependencyPriorities.Max() + 1 : 1;
priorities.Add(item.Attribute.Name, item.Priority);
}
}
Items.Sort((a, b) => a.Priority - b.Priority);
}
public IEnumerable<ProcessorItem> Iterate()
{
SortItems();
foreach (var item in Items)
{
yield return item;
}
}
}
@@ -0,0 +1,65 @@
using Newtonsoft.Json.Linq;
using NpgsqlTypes;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
internal class ProcessorInput(JObject input)
{
public readonly JObject Input = input;
public T GetRequired<T>(string path)
{
JToken token = Input.SelectToken(path) ?? throw new NullReferenceException($"'{path}' is null");
return token.ToObject<T>() ?? throw new NullReferenceException($"'{path}' is null");
}
public T? GetOptional<T>(string path)
{
JToken? token = Input.SelectToken(path) ?? null;
return (token is null || token.Type == JTokenType.Null) ? default! : token.ToObject<T>() ?? default;
}
public T EnumRequired<T>(string path) where T : Enum
{
string value = GetOptional<string>(path) ?? throw new NullReferenceException($"Value in path {path} null or not exists");
return Enum<T>(value);
}
public T EnumOptional<T>(string path, T defaultValue) where T : Enum
{
string? value = GetOptional<string>(path);
return value is null ? defaultValue : Enum<T>(value);
}
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 pgAttribute)
{
variants.Add(pgAttribute.PgName);
}
if (Attribute.GetCustomAttribute(field, typeof(AonprdEnumAttribute)) is AonprdEnumAttribute aonprdAttribute)
{
variants.Add(aonprdAttribute.Value);
}
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}.")
{
}
}
@@ -0,0 +1,27 @@
using Pf2eDataScrapper.Model.Enum;
using Pf2eDataScrapper.Model.Structure;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors;
[AonprdProcessor("trait")]
internal class TraitProcessor(ProcessorInput input) : AbstractProcessor(input)
{
public override EntityType Type => EntityType.Trait;
public override Trait Object { get; } = new();
public override void Process()
{
base.Process();
Object.Type = TraitType.Regular;
Context.Traits.Add(Object);
}
protected override void AddTraits()
{
// Во втором проходе
}
}
@@ -0,0 +1,38 @@
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.Model.Enum;
using Pf2eDataScrapper.Model.Structure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors;
[AonprdProcessor("trait_traits", "trait", ["trait"])]
internal class TraitTraitsProcessor(ProcessorInput input) : AbstractProcessor(input)
{
public override EntityType Type => EntityType.Trait;
public override Trait Object { get; } = new();
public override void Process()
{
string id = Input.GetRequired<string>("id");
string name = Input.GetRequired<string>("name");
if (Input.GetOptional<JArray>("remaster_id") is not null)
{
throw new LegacyItemException(name);
}
// base.Process();
string url = Input.GetRequired<string>("url");
var external = Context.EntityExternals.FirstOrDefault(x => x.Suffix == url) ?? throw new Exception("Entity not found?");
Entity = external.Entity;
AddTraits();
}
}
@@ -1,12 +1,14 @@
using LinqToDB.Common;
using Newtonsoft.Json.Linq;
using NpgsqlTypes;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
using Pf2eDataScrapper.Model;
using Pf2eDataScrapper.Model.Base;
using Pf2eDataScrapper.Model.Base.Source;
using Pf2eDataScrapper.Model.Base.Targets;
using Pf2eDataScrapper.Model.Common;
using Pf2eDataScrapper.Model.Enum;
using Pf2eDataScrapper.Model.Structure;
using System.Security.Cryptography;
using System.Text;
using static LinqToDB.Reflection.Methods.LinqToDB.Insert;
@@ -15,9 +17,9 @@ namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder;
internal abstract class AbstractProcessor(JObject input)
{
protected DataBuilderHelper Helper = DataBuilderHelper.Instance;
protected DatabaseHelper Helper = DatabaseHelper.Instance;
public readonly Pf2eDbContext Context = DataBuilderHelper.DbContext;
public readonly Pf2eDbContext Context = DatabaseHelper.DbContext;
public readonly JObject Input = input;
@@ -29,7 +31,7 @@ internal abstract class AbstractProcessor(JObject input)
public virtual void Process()
{
Entity.Id = Helper.NextId;
Entity.Id = Helper.NextEntityId;
Entity.Type = Type;
Entity.Name = GetRequired<string>("name");
@@ -115,14 +117,14 @@ internal abstract class AbstractProcessor(JObject input)
{
string value = GetOptional<string>(path) ?? throw new NullReferenceException($"Value in path {path} null or not exists");
return DataBuilderHelper.Enum<T>(value);
return ProcessorInput.Enum<T>(value);
}
public T EnumOptional<T>(string path, T defaultValue) where T : Enum
{
string? value = GetOptional<string>(path);
return value is null ? defaultValue : DataBuilderHelper.Enum<T>(value);
return value is null ? defaultValue : ProcessorInput.Enum<T>(value);
}
protected Source GetSource(string name)
@@ -136,8 +138,7 @@ internal abstract class AbstractProcessor(JObject input)
source = new()
{
Name = name,
Url = ""
Name = name
};
Context.Sources.Add(source);
@@ -168,15 +169,15 @@ internal abstract class AbstractProcessor(JObject input)
protected IEnumerable<Trait> GetTraits(IEnumerable<string> names)
{
List<Trait> result = Context.Traits.Where(t => names.Contains(t.Name)).ToList();
List<Trait> result = Context.Traits.Where(t => names.Contains(t.Entity.Name)).ToList();
foreach (string name in names)
{
if (result.Any(t => t.Name == name))
if (result.Any(t => t.Entity.Name == name))
{
continue;
}
/*
Trait trait = new()
{
Name = name,
@@ -186,6 +187,7 @@ internal abstract class AbstractProcessor(JObject input)
};
Context.Traits.Add(trait);
result.Add(trait);
*/
}
return result;
@@ -1,58 +0,0 @@
using NpgsqlTypes;
using Pf2eDataScrapper.Model;
using Slugify;
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder;
internal class DataBuilderHelper
{
public Pf2eDatabase Database = Pf2eDatabase.Instance;
public Pf2eDbContext Context = new();
public SlugHelper Slugger = new();
private DataBuilderHelper()
{
}
private int _id = 0;
public int NextId { get => ++_id; }
public string GenerateSlug(string name)
{
return Slugger.GenerateSlug(name);
}
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 Pf2eDbContext DbContext = Instance.Context;
}
@@ -14,7 +14,6 @@ internal class ActionProcessor(JObject input) : AbstractProcessor(input)
{
base.Process();
Object.Type = EnumRequired<ActionType>("system.actionType.value");
Object.Category = EnumOptional<ActionCategory>("system.category", ActionCategory.Unknown);
Object.Actions = GetOptional<int>("system.actions.value");
@@ -15,7 +15,7 @@ internal class GitRepository(AbstractImporter importer, string url) : AbstractIm
/// </summary>
public override void Update()
{
string gitPath = Path.Combine(RepositoryDirPath, importer.Slug);
string gitPath = Path.Combine(RepositoryDirPath, Importer.Slug);
if (Directory.Exists(gitPath))
{
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,119 +0,0 @@
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");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,106 +0,0 @@
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");
}
}
}
@@ -1,42 +0,0 @@
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: "Контроль версии объекта");
}
}
}
@@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Pf2eDataScrapper.Migrations
{
/// <inheritdoc />
public partial class Typo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
@@ -1,4 +1,5 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
@@ -12,8 +13,8 @@ using Pf2eDataScrapper.Model.Enum;
namespace Pf2eDataScrapper.Migrations
{
[DbContext(typeof(Pf2eDbContext))]
[Migration("20250416152441_Md5Length")]
partial class Md5Length
[Migration("20250417082248_V2")]
partial class V2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -25,7 +26,7 @@ namespace Pf2eDataScrapper.Migrations
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_category", new[] { "unknown", "offensive", "defensive", "interaction", "familiar", "army_tactic", "army_war_action", "kingdom_activity", "kingdom_feat", "kingdom_feature" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_type", new[] { "action", "free", "reaction", "passive" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "alias_type", new[] { "old", "english", "old_english", "hobby", "other" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "alias_type", new[] { "legacy", "english", "legacy_english", "hobby", "other" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ancestry_vision", new[] { "normal", "low-light-vision", "darkvision" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "attribute_values", new[] { "any", "str", "dex", "con", "int", "wis", "cha" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "class_progression_type", new[] { "entity", "ancestry_feat", "class_feat", "general_feat", "skill_feat", "skill_increase" });
@@ -34,11 +35,11 @@ namespace Pf2eDataScrapper.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", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "enum_size", new[] { "med", "tiny" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "ancestryfeature", "classfeature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign_feature" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "med", "tiny" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "source_category", new[] { "rulebook", "adventure-path", "lost-omens" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_area_type", new[] { "burst", "emanation", "cone", "line", "square", "cube", "cylinder" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_damage_category", new[] { "persistent", "splash" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_damage_kinds", new[] { "damage", "healing", "any" });
@@ -296,6 +297,11 @@ namespace Pf2eDataScrapper.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<SourceCategory>("Category")
.HasColumnType("source_category")
.HasColumnName("category")
.HasColumnOrder(3);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
@@ -303,12 +309,10 @@ namespace Pf2eDataScrapper.Migrations
.HasColumnName("name")
.HasColumnOrder(2);
b.Property<string>("Url")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("url")
.HasColumnOrder(3);
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("timestamp with time zone")
.HasColumnName("release_date")
.HasColumnOrder(4);
b.HasKey("Id")
.HasName("pk_sources");
@@ -479,47 +483,6 @@ namespace Pf2eDataScrapper.Migrations
b.ToTable("trainings", (string)null);
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Common.Trait", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text")
.HasColumnName("description")
.HasColumnOrder(5);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("name")
.HasColumnOrder(2);
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("slug")
.HasColumnOrder(4);
b.Property<TraitType>("Type")
.HasColumnType("trait_type")
.HasColumnName("type")
.HasColumnOrder(3);
b.HasKey("Id")
.HasName("pk_traits");
b.ToTable("traits", (string)null);
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Structure.Action", b =>
{
b.Property<int>("Id")
@@ -576,7 +539,7 @@ namespace Pf2eDataScrapper.Migrations
.HasColumnOrder(4);
b.Property<Size>("Size")
.HasColumnType("enum_size")
.HasColumnType("size")
.HasColumnName("size")
.HasColumnOrder(2);
@@ -1458,6 +1421,24 @@ namespace Pf2eDataScrapper.Migrations
b.ToTable("spell_rituals", (string)null);
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Structure.Trait", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
b.Property<TraitType>("Type")
.HasColumnType("trait_type")
.HasColumnName("type")
.HasColumnOrder(2);
b.HasKey("Id")
.HasName("pk_traits");
b.ToTable("traits", (string)null);
});
modelBuilder.Entity("DeityTraining", b =>
{
b.HasOne("Pf2eDataScrapper.Model.Structure.Deity", null)
@@ -1501,7 +1482,7 @@ namespace Pf2eDataScrapper.Migrations
.IsRequired()
.HasConstraintName("fk_entity_trait_entities_entities_id");
b.HasOne("Pf2eDataScrapper.Model.Common.Trait", null)
b.HasOne("Pf2eDataScrapper.Model.Structure.Trait", null)
.WithMany()
.HasForeignKey("TraitsId")
.OnDelete(DeleteBehavior.Cascade)
@@ -1966,6 +1947,18 @@ namespace Pf2eDataScrapper.Migrations
b.Navigation("Spell");
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Structure.Trait", b =>
{
b.HasOne("Pf2eDataScrapper.Model.Base.Entity", "Entity")
.WithOne()
.HasForeignKey("Pf2eDataScrapper.Model.Structure.Trait", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_traits_entities_id");
b.Navigation("Entity");
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Base.Entity", b =>
{
b.Navigation("Aliases");
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Pf2eDataScrapper.Model.Enum;
@@ -7,28 +8,28 @@ using Pf2eDataScrapper.Model.Enum;
namespace Pf2eDataScrapper.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
public partial class V2 : 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_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: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", "senses,abilities,death,attitudes,detection")
.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: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")
@@ -62,7 +63,8 @@ namespace Pf2eDataScrapper.Migrations
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
icon = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false)
icon = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
prefix = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false)
},
constraints: table =>
{
@@ -119,7 +121,8 @@ namespace Pf2eDataScrapper.Migrations
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
url = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false)
category = table.Column<SourceCategory>(type: "source_category", nullable: false),
release_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
@@ -139,22 +142,6 @@ namespace Pf2eDataScrapper.Migrations
table.PrimaryKey("pk_trainings", x => x.id);
});
migrationBuilder.CreateTable(
name: "traits",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
type = table.Column<TraitType>(type: "trait_type", nullable: false),
slug = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
description = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_traits", x => x.id);
});
migrationBuilder.CreateTable(
name: "actions",
columns: table => new
@@ -182,7 +169,7 @@ namespace Pf2eDataScrapper.Migrations
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false),
size = table.Column<Size>(type: "enum_size", nullable: false),
size = table.Column<Size>(type: "size", nullable: false),
hp = table.Column<int>(type: "integer", nullable: false),
reach = table.Column<int>(type: "integer", nullable: false),
speed = table.Column<int>(type: "integer", nullable: false),
@@ -349,6 +336,24 @@ namespace Pf2eDataScrapper.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "traits",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false),
type = table.Column<TraitType>(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
@@ -356,7 +361,7 @@ namespace Pf2eDataScrapper.Migrations
entity_id = table.Column<int>(type: "integer", nullable: false),
target_id = table.Column<int>(type: "integer", nullable: false),
suffix = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Часть URL до объекта. Для источников Foundry - полный UUID объекта"),
md5 = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false, comment: "Контроль версии объекта")
md5 = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false, comment: "Контроль версии объекта")
},
constraints: table =>
{
@@ -445,30 +450,6 @@ namespace Pf2eDataScrapper.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "entity_trait",
columns: table => new
{
entities_id = table.Column<int>(type: "integer", nullable: false),
traits_id = table.Column<int>(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: "ancestry_boosts",
columns: table => new
@@ -928,6 +909,30 @@ namespace Pf2eDataScrapper.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "entity_trait",
columns: table => new
{
entities_id = table.Column<int>(type: "integer", nullable: false),
traits_id = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_entity_trait", x => new { x.entities_id, x.traits_id });
table.ForeignKey(
name: "fk_entity_trait_entities_entities_id",
column: x => x.entities_id,
principalTable: "entities",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_entity_trait_traits_traits_id",
column: x => x.traits_id,
principalTable: "traits",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_ancestry_boosts_ancestry_id",
table: "ancestry_boosts",
@@ -1058,7 +1063,6 @@ namespace Pf2eDataScrapper.Migrations
table: "spell_defenses",
column: "spell_id");
// Procedures
migrationBuilder.Sql("""
@@ -1243,12 +1247,6 @@ $func$;
migrationBuilder.DropTable(
name: "entities");
migrationBuilder.Sql("DROP FUNCTION IF EXISTS f_truncate_tables;");
migrationBuilder.Sql("DROP FUNCTION IF EXISTS f_drop_tables;");
migrationBuilder.Sql("DROP FUNCTION IF EXISTS f_permission_tables;");
}
}
}
@@ -1,4 +1,5 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
@@ -12,8 +13,8 @@ using Pf2eDataScrapper.Model.Enum;
namespace Pf2eDataScrapper.Migrations
{
[DbContext(typeof(Pf2eDbContext))]
[Migration("20250416202849_Typo")]
partial class Typo
[Migration("20250417085326_DateOnly")]
partial class DateOnly
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -25,7 +26,7 @@ namespace Pf2eDataScrapper.Migrations
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_category", new[] { "unknown", "offensive", "defensive", "interaction", "familiar", "army_tactic", "army_war_action", "kingdom_activity", "kingdom_feat", "kingdom_feature" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_type", new[] { "action", "free", "reaction", "passive" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "alias_type", new[] { "old", "english", "old_english", "hobby", "other" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "alias_type", new[] { "legacy", "english", "legacy_english", "hobby", "other" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ancestry_vision", new[] { "normal", "low-light-vision", "darkvision" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "attribute_values", new[] { "any", "str", "dex", "con", "int", "wis", "cha" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "class_progression_type", new[] { "entity", "ancestry_feat", "class_feat", "general_feat", "skill_feat", "skill_increase" });
@@ -34,11 +35,11 @@ namespace Pf2eDataScrapper.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", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "enum_size", new[] { "med", "tiny" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "ancestryfeature", "classfeature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign_feature" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "med", "tiny" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "source_category", new[] { "rulebook", "adventure-path", "lost-omens" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_area_type", new[] { "burst", "emanation", "cone", "line", "square", "cube", "cylinder" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_damage_category", new[] { "persistent", "splash" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_damage_kinds", new[] { "damage", "healing", "any" });
@@ -296,6 +297,11 @@ namespace Pf2eDataScrapper.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<SourceCategory>("Category")
.HasColumnType("source_category")
.HasColumnName("category")
.HasColumnOrder(3);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
@@ -303,12 +309,10 @@ namespace Pf2eDataScrapper.Migrations
.HasColumnName("name")
.HasColumnOrder(2);
b.Property<string>("Url")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("url")
.HasColumnOrder(3);
b.Property<DateOnly?>("ReleaseDate")
.HasColumnType("date")
.HasColumnName("release_date")
.HasColumnOrder(4);
b.HasKey("Id")
.HasName("pk_sources");
@@ -390,47 +394,6 @@ namespace Pf2eDataScrapper.Migrations
b.ToTable("external_targets", (string)null);
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Base.Trait", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text")
.HasColumnName("description")
.HasColumnOrder(5);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("name")
.HasColumnOrder(2);
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("slug")
.HasColumnOrder(4);
b.Property<TraitType>("Type")
.HasColumnType("trait_type")
.HasColumnName("type")
.HasColumnOrder(3);
b.HasKey("Id")
.HasName("pk_traits");
b.ToTable("traits", (string)null);
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Common.Frequency", b =>
{
b.Property<int>("Id")
@@ -576,7 +539,7 @@ namespace Pf2eDataScrapper.Migrations
.HasColumnOrder(4);
b.Property<Size>("Size")
.HasColumnType("enum_size")
.HasColumnType("size")
.HasColumnName("size")
.HasColumnOrder(2);
@@ -1458,6 +1421,24 @@ namespace Pf2eDataScrapper.Migrations
b.ToTable("spell_rituals", (string)null);
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Structure.Trait", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
b.Property<TraitType>("Type")
.HasColumnType("trait_type")
.HasColumnName("type")
.HasColumnOrder(2);
b.HasKey("Id")
.HasName("pk_traits");
b.ToTable("traits", (string)null);
});
modelBuilder.Entity("DeityTraining", b =>
{
b.HasOne("Pf2eDataScrapper.Model.Structure.Deity", null)
@@ -1501,7 +1482,7 @@ namespace Pf2eDataScrapper.Migrations
.IsRequired()
.HasConstraintName("fk_entity_trait_entities_entities_id");
b.HasOne("Pf2eDataScrapper.Model.Base.Trait", null)
b.HasOne("Pf2eDataScrapper.Model.Structure.Trait", null)
.WithMany()
.HasForeignKey("TraitsId")
.OnDelete(DeleteBehavior.Cascade)
@@ -1557,7 +1538,7 @@ namespace Pf2eDataScrapper.Migrations
modelBuilder.Entity("Pf2eDataScrapper.Model.Base.Targets.EntityExternal", b =>
{
b.HasOne("Pf2eDataScrapper.Model.Base.Entity", "Entity")
.WithMany("Externals")
.WithMany("Extrnals")
.HasForeignKey("EntityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
@@ -1966,11 +1947,23 @@ namespace Pf2eDataScrapper.Migrations
b.Navigation("Spell");
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Structure.Trait", b =>
{
b.HasOne("Pf2eDataScrapper.Model.Base.Entity", "Entity")
.WithOne()
.HasForeignKey("Pf2eDataScrapper.Model.Structure.Trait", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_traits_entities_id");
b.Navigation("Entity");
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Base.Entity", b =>
{
b.Navigation("Aliases");
b.Navigation("Externals");
b.Navigation("Extrnals");
b.Navigation("Sources");
});
@@ -0,0 +1,37 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Pf2eDataScrapper.Migrations
{
/// <inheritdoc />
public partial class DateOnly : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateOnly>(
name: "release_date",
table: "sources",
type: "date",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "release_date",
table: "sources",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateOnly),
oldType: "date",
oldNullable: true);
}
}
}
@@ -1,4 +1,5 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@@ -22,7 +23,7 @@ namespace Pf2eDataScrapper.Migrations
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_category", new[] { "unknown", "offensive", "defensive", "interaction", "familiar", "army_tactic", "army_war_action", "kingdom_activity", "kingdom_feat", "kingdom_feature" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "action_type", new[] { "action", "free", "reaction", "passive" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "alias_type", new[] { "old", "english", "old_english", "hobby", "other" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "alias_type", new[] { "legacy", "english", "legacy_english", "hobby", "other" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ancestry_vision", new[] { "normal", "low-light-vision", "darkvision" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "attribute_values", new[] { "any", "str", "dex", "con", "int", "wis", "cha" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "class_progression_type", new[] { "entity", "ancestry_feat", "class_feat", "general_feat", "skill_feat", "skill_increase" });
@@ -31,11 +32,11 @@ namespace Pf2eDataScrapper.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", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "enum_size", new[] { "med", "tiny" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "ancestryfeature", "classfeature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign_feature" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "med", "tiny" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "source_category", new[] { "rulebook", "adventure-path", "lost-omens" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_area_type", new[] { "burst", "emanation", "cone", "line", "square", "cube", "cylinder" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_damage_category", new[] { "persistent", "splash" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "spell_damage_kinds", new[] { "damage", "healing", "any" });
@@ -293,6 +294,11 @@ namespace Pf2eDataScrapper.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<SourceCategory>("Category")
.HasColumnType("source_category")
.HasColumnName("category")
.HasColumnOrder(3);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
@@ -300,12 +306,10 @@ namespace Pf2eDataScrapper.Migrations
.HasColumnName("name")
.HasColumnOrder(2);
b.Property<string>("Url")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("url")
.HasColumnOrder(3);
b.Property<DateOnly?>("ReleaseDate")
.HasColumnType("date")
.HasColumnName("release_date")
.HasColumnOrder(4);
b.HasKey("Id")
.HasName("pk_sources");
@@ -387,47 +391,6 @@ namespace Pf2eDataScrapper.Migrations
b.ToTable("external_targets", (string)null);
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Base.Trait", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text")
.HasColumnName("description")
.HasColumnOrder(5);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("name")
.HasColumnOrder(2);
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("slug")
.HasColumnOrder(4);
b.Property<TraitType>("Type")
.HasColumnType("trait_type")
.HasColumnName("type")
.HasColumnOrder(3);
b.HasKey("Id")
.HasName("pk_traits");
b.ToTable("traits", (string)null);
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Common.Frequency", b =>
{
b.Property<int>("Id")
@@ -573,7 +536,7 @@ namespace Pf2eDataScrapper.Migrations
.HasColumnOrder(4);
b.Property<Size>("Size")
.HasColumnType("enum_size")
.HasColumnType("size")
.HasColumnName("size")
.HasColumnOrder(2);
@@ -1455,6 +1418,24 @@ namespace Pf2eDataScrapper.Migrations
b.ToTable("spell_rituals", (string)null);
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Structure.Trait", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
b.Property<TraitType>("Type")
.HasColumnType("trait_type")
.HasColumnName("type")
.HasColumnOrder(2);
b.HasKey("Id")
.HasName("pk_traits");
b.ToTable("traits", (string)null);
});
modelBuilder.Entity("DeityTraining", b =>
{
b.HasOne("Pf2eDataScrapper.Model.Structure.Deity", null)
@@ -1498,7 +1479,7 @@ namespace Pf2eDataScrapper.Migrations
.IsRequired()
.HasConstraintName("fk_entity_trait_entities_entities_id");
b.HasOne("Pf2eDataScrapper.Model.Base.Trait", null)
b.HasOne("Pf2eDataScrapper.Model.Structure.Trait", null)
.WithMany()
.HasForeignKey("TraitsId")
.OnDelete(DeleteBehavior.Cascade)
@@ -1554,7 +1535,7 @@ namespace Pf2eDataScrapper.Migrations
modelBuilder.Entity("Pf2eDataScrapper.Model.Base.Targets.EntityExternal", b =>
{
b.HasOne("Pf2eDataScrapper.Model.Base.Entity", "Entity")
.WithMany("Externals")
.WithMany("Extrnals")
.HasForeignKey("EntityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
@@ -1963,11 +1944,23 @@ namespace Pf2eDataScrapper.Migrations
b.Navigation("Spell");
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Structure.Trait", b =>
{
b.HasOne("Pf2eDataScrapper.Model.Base.Entity", "Entity")
.WithOne()
.HasForeignKey("Pf2eDataScrapper.Model.Structure.Trait", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_traits_entities_id");
b.Navigation("Entity");
});
modelBuilder.Entity("Pf2eDataScrapper.Model.Base.Entity", b =>
{
b.Navigation("Aliases");
b.Navigation("Externals");
b.Navigation("Extrnals");
b.Navigation("Sources");
});
+3 -1
View File
@@ -2,7 +2,9 @@
using Pf2eDataScrapper.Model.Base.Keywords;
using Pf2eDataScrapper.Model.Base.Source;
using Pf2eDataScrapper.Model.Base.Targets;
using Pf2eDataScrapper.Model.Common;
using Pf2eDataScrapper.Model.Enum;
using Pf2eDataScrapper.Model.Structure;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -56,5 +58,5 @@ public class Entity
public virtual ICollection<EntitySource> Sources { get; set; } = [];
public virtual ICollection<EntityExternal> Externals { get; set; } = [];
public virtual ICollection<EntityExternal> Extrnals { get; set; } = [];
}
+7 -3
View File
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using Pf2eDataScrapper.Model.Enum;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Pf2eDataScrapper.Model.Base.Source;
@@ -15,8 +16,11 @@ public partial class Source
public string Name { get; set; } = null!;
[Column(Order = 3)]
[MaxLength(255)]
public string Url { get; set; } = null!;
public SourceCategory Category { get; set; }
[Column(Order = 4)]
public DateOnly? ReleaseDate { get; set; }
public ICollection<EntitySource> EntitySources { get; set; } = [];
}
-29
View File
@@ -1,29 +0,0 @@
using Pf2eDataScrapper.Model.Enum;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Pf2eDataScrapper.Model.Base;
public partial class Trait
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column(Order = 1)]
public int Id { get; set; }
[Column(Order = 2)]
[MaxLength(Pf2eDbContext.NameLength)]
public string Name { get; set; } = null!;
[Column(Order = 3)]
public TraitType Type { get; set; }
[Column(Order = 4)]
[MaxLength(Pf2eDbContext.NameLength)]
public string Slug { get; set; } = null!;
[Column(Order = 5)]
public string Description { get; set; } = null!;
public virtual ICollection<Entity> Entities { get; set; } = [];
}
@@ -1,4 +1,5 @@
using NpgsqlTypes;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
namespace Pf2eDataScrapper.Model.Enum;
+4 -4
View File
@@ -4,14 +4,14 @@ namespace Pf2eDataScrapper.Model.Enum;
public enum AliasType
{
[PgName("old")]
Old,
[PgName("legacy")]
Legacy,
[PgName("english")]
English,
[PgName("old_english")]
OldEnglish,
[PgName("legacy_english")]
LegacyEnglish,
[PgName("hobby")]
Hobby,
@@ -7,6 +7,9 @@ public enum EntityType
[PgName("unknown")]
Unknown,
[PgName("trait")]
Trait,
[PgName("action")]
Action,
@@ -0,0 +1,18 @@
using NpgsqlTypes;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
namespace Pf2eDataScrapper.Model.Enum;
public enum SourceCategory
{
[PgName("rulebook")]
[AonprdEnum("Rulebooks")]
Rulebooks,
[PgName("adventure-path")]
[AonprdEnum("Adventure Paths")]
AdventurePaths,
[PgName("lost-omens")]
[AonprdEnum("Lost Omens")]
LostOmens,
}
+19 -18
View File
@@ -117,26 +117,27 @@ public partial class Pf2eDbContext : DbContext
builder =>
{
builder
.MapEnum<EntityType>("entity_type")
.MapEnum<EntityRarity>("entity_rarity")
.MapEnum<AliasType>("alias_type")
.MapEnum<TraitType>("trait_type")
.MapEnum<ActionType>("action_type")
.MapEnum<ActionCategory>("action_category")
.MapEnum<Size>("enum_size")
.MapEnum<AncestryVision>("ancestry_vision")
.MapEnum<ClassProgressionType>("class_progression_type")
.MapEnum<ConditionGroup>("condition_group")
.MapEnum<DeityCategory>("deity_category")
.MapEnum<DeityFonts>("deity_fonts")
.MapEnum<DeitySanctification>("deity_sanctification")
.MapEnum<FeatActionType>("feat_action_type")
.MapEnum<FeatCategory>("feat_category")
.MapEnum<SpellAreaType>("spell_area_type")
.MapEnum<SpellDamageCategory>("spell_damage_category")
.MapEnum<SpellDamageKinds>("spell_damage_kinds")
.MapEnum<EntityType>()
.MapEnum<EntityRarity>()
.MapEnum<AliasType>()
.MapEnum<TraitType>()
.MapEnum<ActionType>()
.MapEnum<ActionCategory>()
.MapEnum<Size>()
.MapEnum<AncestryVision>()
.MapEnum<ClassProgressionType>()
.MapEnum<ConditionGroup>()
.MapEnum<DeityCategory>()
.MapEnum<DeityFonts>()
.MapEnum<DeitySanctification>()
.MapEnum<FeatActionType>()
.MapEnum<FeatCategory>()
.MapEnum<SpellAreaType>()
.MapEnum<SpellDamageCategory>()
.MapEnum<SpellDamageKinds>()
.MapEnum<AttributeValues>()
.MapEnum<TrainingStage>()
.MapEnum<SourceCategory>()
;
}
);
+8 -6
View File
@@ -28,8 +28,6 @@ public partial class Pf2eDbContext
DefineBase(modelBuilder);
DefineCommon(modelBuilder);
DefineStructure(modelBuilder);
}
private void DefineEnums(ModelBuilder modelBuilder)
@@ -55,6 +53,7 @@ public partial class Pf2eDbContext
.HasPostgresEnum<SpellDamageKinds>()
.HasPostgresEnum<AttributeValues>()
.HasPostgresEnum<TrainingStage>()
.HasPostgresEnum<SourceCategory>()
;
}
@@ -77,7 +76,7 @@ public partial class Pf2eDbContext
.OnDelete(DeleteBehavior.Cascade);
// EntityExternal
entity.HasMany(e => e.Externals).WithOne(e => e.Entity)
entity.HasMany(e => e.Extrnals).WithOne(e => e.Entity)
.HasForeignKey(e => e.EntityId)
.OnDelete(DeleteBehavior.Cascade);
});
@@ -122,8 +121,6 @@ public partial class Pf2eDbContext
modelBuilder.Entity<Language>(entity => { });
modelBuilder.Entity<Training>(entity => { });
modelBuilder.Entity<Trait>(entity => { });
}
private void BindEntity<T>(EntityTypeBuilder<T> entity) where T : class, IEntity
@@ -316,10 +313,15 @@ public partial class Pf2eDbContext
.HasForeignKey(e => e.SpellId)
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<SpellArea>(entity => { });
modelBuilder.Entity<SpellDamage>(entity => { });
modelBuilder.Entity<SpellDefense>(entity => { });
modelBuilder.Entity<SpellRitual>(entity => { });
// Trait
modelBuilder.Entity<Trait>(entity =>
{
BindEntity(entity);
});
}
}
+21
View File
@@ -0,0 +1,21 @@
using Pf2eDataScrapper.Model.Base;
using Pf2eDataScrapper.Model.Enum;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Pf2eDataScrapper.Model.Structure;
public partial class Trait : IEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Column(Order = 1)]
public int Id { get; set; }
public Entity Entity { get; set; } = null!;
[Column(Order = 2)]
public TraitType Type { get; set; }
public virtual ICollection<Entity> Entities { get; set; } = [];
}
+5 -1
View File
@@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="dotenv.net" Version="3.2.1" />
<PackageReference Include="EFCore.NamingConventions" Version="9.0.0" />
<PackageReference Include="Goblinfactory.ProgressBar" Version="1.0.0" />
<PackageReference Include="Goblinfactory.Konsole" Version="6.2.2" />
<PackageReference Include="linq2db" Version="5.4.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4">
@@ -33,4 +33,8 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>
+3 -6
View File
@@ -1,15 +1,12 @@
using Pf2eDataScrapper;
using Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry;
using Pf2eDataScrapper.Importers.Implementations.Aonprd;
EnvSettings.Load();
/*
AonprdImporter importer = new();
importer.Prepare();
importer.BuildSchemas();
Pf2EFoundryImporter importer = new();
*/
Pf2EFoundryImporter importer = new();
AonprdImporter importer = new();
importer.Prepare();
importer.Import();