Переход от наследования таблиц на 1-1 связи

This commit is contained in:
2025-04-15 11:55:10 +04:00
parent a087807fe4
commit 5475b6ab46
20 changed files with 491 additions and 752 deletions
@@ -1,4 +1,8 @@
using Newtonsoft.Json.Linq;
using NpgsqlTypes;
using Pf2eDataScrapper.Model;
using Pf2eDataScrapper.Model.Enum;
using System.ComponentModel;
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder
{
@@ -8,23 +12,49 @@ namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder
public readonly JObject Input = input;
public abstract void Process();
protected DataBuilderHelper Helper = DataBuilderHelper.Instance;
public Entity Entity { get; set; } = new Entity();
public abstract EntityType Type { get; }
public abstract IEntity Object { get; }
public virtual void Process()
{
Entity.Id = Helper.NextId;
Entity.Type = Type;
Entity.Name = GetRequired<string>("name");
Entity.Img = GetRequired<string>("img");
Entity.Description = GetRequired<string>("system.description.value");
Entity.DescriptionGm = GetOptional<string>("system.description.gm");
Entity.IsTranslated = false;
Entity.IsChecked = false;
Entity.Slug = Helper.GenerateSlug(Entity.Name);
Object.Id = Entity.Id;
Context.Entities.Add(Entity);
// TODO Traits, Alias
}
public void Save()
{
Context.SaveChanges();
}
protected T GetRequired<T>(string path)
public T GetRequired<T>(string path)
{
var token = Input.SelectToken(path) ?? throw new NullReferenceException($"'{path}' is null");
return token.ToObject<T>() ?? throw new NullReferenceException($"'{path}' is null");
}
protected T? GetOptional<T>(string path)
public T? GetOptional<T>(string path)
{
var token = Input.SelectToken(path) ?? null;
@@ -36,6 +66,39 @@ namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder
return token.ToObject<T>() ?? default;
}
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}");
}
public T? EnumOptional<T>(string path) where T : Enum
{
string? value = GetOptional<string>(path);
if (value == null)
{
return default;
}
foreach (var field in typeof(T).GetFields())
{
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;
}
}
}
@@ -1,5 +1,4 @@
using Newtonsoft.Json.Linq;
using Npgsql;
using Slugify;
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder
{
@@ -7,76 +6,23 @@ namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder
{
public Pf2eDatabase Database = Pf2eDatabase.Instance;
public SlugHelper Slugger = new();
private DataBuilderHelper()
{
}
public NpgsqlCommand PrepareInsert(string table, Dictionary<string, object?> data, bool returnId)
{
List<string> columns = [];
List<string> patterns = [];
private int _id = 0;
foreach (var key in data.Keys)
public int NextId { get => ++_id; }
public string GenerateSlug(string name)
{
columns.Add(key);
patterns.Add($":{key.ToUpper()}");
return Slugger.GenerateSlug(name);
}
string dml = $"INSERT INTO {table} (\"{string.Join("\", \"", columns)}\") VALUES ({string.Join(", ", patterns)})" + (returnId ? " RETURNING id" : "");
NpgsqlCommand cmd = Database.GetCommand(dml);
foreach (var kvp in data)
{
cmd.Parameters.AddWithValue(":" + kvp.Key.ToUpper(), kvp.Value ?? DBNull.Value);
}
Console.WriteLine(cmd.CommandText);
return cmd;
}
public int Insert(string table, Dictionary<string, object?> data)
{
var cmd = PrepareInsert(table, data, true);
return (int)(cmd.ExecuteScalar() ?? throw new Exception("Not a number"));
}
public void InsertBlind(string table, Dictionary<string, object?> data)
{
var cmd = PrepareInsert(table, data, false);
cmd.ExecuteNonQuery();
}
public static object? JsonGet(JObject root, string path)
{
var token = root.SelectToken(path);
if (token == null)
{
return null;
}
if (token.Type == JTokenType.String)
{
return token.ToString();
}
else if (token.Type == JTokenType.Integer)
{
return token.ToObject<int>();
}
else if (token.Type == JTokenType.Float)
{
return token.ToObject<float>();
}
else if (token.Type == JTokenType.Boolean)
{
return token.ToObject<bool>();
}
else
{
return token.ToString();
}
}
public static DataBuilderHelper Instance = new();
public readonly static DataBuilderHelper Instance = new();
}
}
@@ -1,9 +1,10 @@
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder
{
[AttributeUsage(AttributeTargets.Class)]
internal class Pf2eTypeProcessor(string type) : Attribute
internal class Pf2eTypeProcessor(string type, int priority = 0) : Attribute
{
public readonly string Type = type;
public readonly int Priority = priority;
}
}
@@ -1,39 +1,33 @@
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.Model;
using Pf2eDataScrapper.Model.Enum;
using Slugify;
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder.Processors
{
[Pf2eTypeProcessor("Item.condition")]
internal class ConditionProcessor(JObject input) : AbstractProcessor(input)
{
public override EntityType Type => EntityType.Condition;
public override Condition Object { get; } = new();
public override void Process()
{
base.Process();
JObject extra = new()
{
{ "duration", Input.SelectToken("duration") },
{ "overrides", Input.SelectToken("overrides") },
{ "references", Input.SelectToken("references") },
{ "value", Input.SelectToken("value") }
{ "duration", Input.SelectToken("system.duration") },
{ "overrides", Input.SelectToken("system.overrides") },
{ "references", Input.SelectToken("system.references") },
{ "value", Input.SelectToken("system.value") }
};
Condition condition = new()
{
Name = GetRequired<string>("name"),
Img = GetRequired<string>("img"),
Description = GetRequired<string>("system.description.value"),
DescriptionGm = GetOptional<string>("system.description.gm"),
Type = EntityType.Condition,
IsTranslated = false,
IsChecked = false,
Object.Extra = extra.ToString(Newtonsoft.Json.Formatting.Indented);
// Group = GetOptional<string>("system.group");
Extra = extra.ToString(Newtonsoft.Json.Formatting.Indented)
};
condition.Slug = new SlugHelper().GenerateSlug(condition.Name);
Object.Group = EnumOptional<ConditionGroup>("system.group");
Context.Conditions.Add(condition);
Context.Conditions.Add(Object);
}
}
}
+2 -14
View File
@@ -6,21 +6,9 @@ public partial class Action : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public Entity Entity { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.Action;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
// TODO ActionType
public int? Actions { get; set; }
+6 -18
View File
@@ -6,21 +6,9 @@ public partial class Ancestry : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public Entity Entity { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.Ancestry;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
// TODO Size Vision
public int Hp { get; set; }
@@ -28,11 +16,11 @@ public partial class Ancestry : IEntity
public int Speed { get; set; }
public virtual ICollection<AncestryBoost> AncestryBoosts { get; set; } = new List<AncestryBoost>();
public virtual ICollection<AncestryBoost> AncestryBoosts { get; set; } = [];
public virtual ICollection<AncestryItem> AncestryItems { get; set; } = new List<AncestryItem>();
public virtual ICollection<AncestryItem> AncestryItems { get; set; } = [];
public virtual ICollection<AncestryLanguage> AncestryLanguages { get; set; } = new List<AncestryLanguage>();
public virtual ICollection<AncestryLanguage> AncestryLanguages { get; set; } = [];
public virtual ICollection<Heritage> Heritages { get; set; } = new List<Heritage>();
public virtual ICollection<Heritage> Heritages { get; set; } = [];
}
+1 -15
View File
@@ -6,21 +6,7 @@ public partial class Background : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.Background;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
public Entity Entity { get; set; } = null!;
public virtual ICollection<BackgroundBoost> BackgroundBoosts { get; set; } = new List<BackgroundBoost>();
+2 -14
View File
@@ -6,21 +6,9 @@ public partial class CampaignFeature : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public Entity Entity { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.CampaignFeature;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
// TODO ActionType Category
public int? Level { get; set; }
+1 -15
View File
@@ -6,21 +6,7 @@ public partial class Class : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.Class;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
public Entity Entity { get; set; } = null!;
public int Hp { get; set; }
+3 -17
View File
@@ -4,25 +4,11 @@ namespace Pf2eDataScrapper.Model;
public partial class Condition : IEntity
{
public int Id { get; set; } = -1;
public int Id { get; set; }
public string Name { get; set; } = null!;
public Entity Entity { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.Condition;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
public ConditionGroup Group { get; set; }
public ConditionGroup? Group { get; set; }
public string? Extra { get; set; }
}
+2 -14
View File
@@ -6,21 +6,9 @@ public partial class Deity : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public Entity Entity { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.Deity;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
// TODO Category Font Sanctification
public bool SanctificationMust { get; set; }
+8 -4
View File
@@ -1,13 +1,17 @@
namespace Pf2eDataScrapper.Model;
using Pf2eDataScrapper.Model.Enum;
public partial class Entity : IEntity
namespace Pf2eDataScrapper.Model;
public class Entity
{
public int Id { get; set; } = -1;
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; }
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
@@ -18,5 +22,5 @@ public partial class Entity : IEntity
public bool? IsChecked { get; set; }
public virtual ICollection<Trait> Traits { get; set; } = new List<Trait>();
public virtual ICollection<Trait> Traits { get; set; } = [];
}
+2 -14
View File
@@ -6,21 +6,9 @@ public partial class Feat : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public Entity Entity { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.Feat;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
// TODO ActionType Category
public int? Actions { get; set; }
+1 -15
View File
@@ -6,21 +6,7 @@ public partial class Heritage : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.Heritage;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
public Entity Entity { get; set; } = null!;
public int? AncestryId { get; set; }
+1 -12
View File
@@ -4,18 +4,7 @@
{
public int Id { get; set; }
public string Name { get; set; }
public Entity Entity { get; set; }
public string Img { get; set; }
public string Description { get; set; }
public string? DescriptionGm { get; set; }
public string Slug { get; set; }
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
}
}
+1 -15
View File
@@ -6,21 +6,7 @@ public partial class Spell : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Img { get; set; } = null!;
public EntityType Type { get; set; } = EntityType.Spell;
public string Description { get; set; } = null!;
public string? DescriptionGm { get; set; }
public string Slug { get; set; } = null!;
public bool? IsTranslated { get; set; }
public bool? IsChecked { get; set; }
public Entity Entity { get; set; } = null!;
public int Level { get; set; }
+2 -2
View File
@@ -6,7 +6,7 @@ public partial class Trait
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public string Slug { get; set; } = null!;
public virtual ICollection<Entity> Entities { get; set; } = new List<Entity>();
public string Description { get; set; } = null!;
}
+329 -458
View File
@@ -18,6 +18,8 @@ public partial class Pf2eTestContext : DbContext
{
}
#region DbSets
public virtual DbSet<Model.Action> Actions { get; set; }
public virtual DbSet<Ancestry> Ancestries { get; set; }
@@ -100,6 +102,7 @@ public partial class Pf2eTestContext : DbContext
public virtual DbSet<Trait> Traits { get; set; }
#endregion
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(EnvSettings.DatabaseConnection,
@@ -160,15 +163,11 @@ public partial class Pf2eTestContext : DbContext
{
modelBuilder.UseIdentityByDefaultColumns();
modelBuilder.HasSequence<int>("entity_sequence");
modelBuilder
.HasPostgresEnum<EntityType>("entity_type")
.HasPostgresEnum<ConditionGroup>("condition_group")
;
modelBuilder
.HasPostgresEnum("action_category", new[] { "offensive", "defensive", "interaction", "familiar" })
.HasPostgresEnum("action_type", new[] { "action", "free", "reaction", "passive" })
@@ -189,23 +188,18 @@ public partial class Pf2eTestContext : DbContext
.HasPostgresEnum("spell_damage_kinds", new[] { "damage", "healing", "any" })
.HasPostgresEnum("trait_type", new[] { "regular", "tradition" });
modelBuilder.Entity<Model.Action>(entity =>
modelBuilder.Entity<Entity>(entity =>
{
entity.HasKey(e => e.Id).HasName("action_pkey");
entity.HasKey(e => e.Id).HasName("entity_pkey");
entity.ToTable("action");
entity.ToTable("entity");
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Type)
.HasConversion(GetEnumConverter<EntityType>())
.HasColumnName("type");
entity.Property(e => e.Actions).HasColumnName("actions");
entity.Property(e => e.DeathNote).HasColumnName("death_note");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.Property(e => e.Extra).HasColumnName("extra");
entity.Property(e => e.Type)
.HasColumnName("type");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
@@ -221,7 +215,261 @@ public partial class Pf2eTestContext : DbContext
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.HasMany(d => d.Traits).WithMany()
.UsingEntity<Dictionary<string, object>>(
"EntityTrait",
r => r.HasOne<Trait>().WithMany()
.HasForeignKey("TraitId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_traits_trait_id_fkey"),
l => l.HasOne<Entity>().WithMany()
.HasForeignKey("EntityId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_traits_entity_id_fkey"),
j =>
{
j.HasKey("EntityId", "TraitId").HasName("entity_traits_pkey");
j.ToTable("entity_traits");
j.IndexerProperty<int>("EntityId").HasColumnName("entity_id");
j.IndexerProperty<int>("TraitId").HasColumnName("trait_id");
});
});
modelBuilder.Entity<EntityAlias>(entity =>
{
entity.HasKey(e => e.Id).HasName("entity_aliases_pkey");
entity.ToTable("entity_aliases");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Alias)
.HasColumnType("character varying")
.HasColumnName("alias");
entity.Property(e => e.EntityId).HasColumnName("entity_id");
entity.HasOne(d => d.Entity).WithMany()
.HasForeignKey(d => d.EntityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_aliases_entity_id_fkey");
});
modelBuilder.Entity<EntityExternal>(entity =>
{
entity.HasKey(e => new { e.EntityId, e.TargetId }).HasName("entity_external_pkey");
entity.ToTable("entity_external");
entity.Property(e => e.EntityId).HasColumnName("entity_id");
entity.Property(e => e.TargetId).HasColumnName("target_id");
entity.Property(e => e.Md5)
.HasColumnType("character varying")
.HasColumnName("md5");
entity.Property(e => e.Path)
.HasColumnType("character varying")
.HasColumnName("path");
entity.Property(e => e.Suffix)
.HasDefaultValueSql("''::character varying")
.HasColumnType("character varying")
.HasColumnName("suffix");
entity.HasOne(d => d.Entity).WithMany()
.HasForeignKey(d => d.EntityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_external_entity_id_fkey");
entity.HasOne(d => d.Target).WithMany()
.HasForeignKey(d => d.TargetId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_external_target_id_fkey");
});
modelBuilder.Entity<EntityKeyword>(entity =>
{
entity
.HasNoKey()
.ToTable("entity_keywords");
entity.Property(e => e.EntityId).HasColumnName("entity_id");
entity.Property(e => e.KeywordId).HasColumnName("keyword_id");
entity.HasOne(d => d.Entity).WithMany()
.HasForeignKey(d => d.EntityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_keywords_entity_id_fkey");
entity.HasOne(d => d.Keyword).WithMany()
.HasForeignKey(d => d.KeywordId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_keywords_keyword_id_fkey");
});
modelBuilder.Entity<EntitySource>(entity =>
{
entity
.HasNoKey()
.ToTable("entity_sources");
entity.Property(e => e.EntityId).HasColumnName("entity_id");
entity.Property(e => e.IsRemaster).HasColumnName("is_remaster");
entity.Property(e => e.SourceId).HasColumnName("source_id");
entity.Property(e => e.Suffix)
.HasDefaultValueSql("''::character varying")
.HasColumnType("character varying")
.HasColumnName("suffix");
entity.HasOne(d => d.Entity).WithMany()
.HasForeignKey(d => d.EntityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_sources_entity_id_fkey");
entity.HasOne(d => d.Source).WithMany()
.HasForeignKey(d => d.SourceId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_sources_source_id_fkey");
});
modelBuilder.Entity<ExternalTarget>(entity =>
{
entity.HasKey(e => e.Id).HasName("external_target_pkey");
entity.ToTable("external_target");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Icon)
.HasColumnType("character varying")
.HasColumnName("icon");
entity.Property(e => e.Name)
.HasColumnType("character varying")
.HasColumnName("name");
});
modelBuilder.Entity<Frequency>(entity =>
{
entity.HasKey(e => e.Id).HasName("frequency_pkey");
entity.ToTable("frequency");
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Max).HasColumnName("max");
entity.Property(e => e.Per).HasColumnName("per");
entity.Property(e => e.Value).HasColumnName("value");
entity.HasOne(d => d.IdNavigation).WithOne()
.HasForeignKey<Frequency>(d => d.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("frequency_id_fkey");
});
modelBuilder.Entity<Keyword>(entity =>
{
entity.HasKey(e => e.Id).HasName("keyword_pkey");
entity.ToTable("keyword");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Slug)
.HasMaxLength(50)
.HasColumnName("slug");
});
modelBuilder.Entity<KeywordAlias>(entity =>
{
entity
.HasNoKey()
.ToTable("keyword_aliases");
entity.Property(e => e.KeywordId).HasColumnName("keyword_id");
entity.Property(e => e.Value)
.HasColumnType("character varying")
.HasColumnName("value");
entity.HasOne(d => d.Keyword).WithMany()
.HasForeignKey(d => d.KeywordId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("keyword_aliases_keyword_id_fkey");
});
modelBuilder.Entity<Language>(entity =>
{
entity.HasKey(e => e.Id).HasName("language_pkey");
entity.ToTable("language");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Name)
.HasColumnType("character varying")
.HasColumnName("name");
});
modelBuilder.Entity<Source>(entity =>
{
entity.HasKey(e => e.Id).HasName("source_pkey");
entity.ToTable("source");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Name)
.HasColumnType("character varying")
.HasColumnName("name");
entity.Property(e => e.Url)
.HasColumnType("character varying")
.HasColumnName("url");
});
modelBuilder.Entity<Training>(entity =>
{
entity.HasKey(e => e.Id).HasName("trainings_pkey");
entity.ToTable("trainings");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Key)
.HasColumnType("character varying")
.HasColumnName("key");
});
modelBuilder.Entity<Trait>(entity =>
{
entity.HasKey(e => e.Id).HasName("trait_pkey");
entity.ToTable("trait");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.Name)
.HasColumnType("character varying")
.HasColumnName("name");
entity.Property(e => e.Slug)
.HasColumnType("character varying")
.HasColumnName("slug");
});
modelBuilder.Entity<Model.Action>(entity =>
{
entity.HasKey(e => e.Id).HasName("action_pkey");
entity.ToTable("action");
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<Model.Action>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("action_id_fkey");
entity.Property(e => e.Actions).HasColumnName("actions");
entity.Property(e => e.DeathNote).HasColumnName("death_note");
});
modelBuilder.Entity<Ancestry>(entity =>
{
@@ -232,28 +480,12 @@ public partial class Pf2eTestContext : DbContext
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Type)
.HasConversion(GetEnumConverter<EntityType>())
.HasColumnName("type");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<Ancestry>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ancestry_id_fkey");
entity.Property(e => e.Hp).HasColumnName("hp");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.Property(e => e.Reach).HasColumnName("reach");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.Property(e => e.Speed).HasColumnName("speed");
});
@@ -293,7 +525,7 @@ public partial class Pf2eTestContext : DbContext
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ancestry_items_ancestry_id_fkey");
entity.HasOne(d => d.Item).WithMany(p => p.AncestryItems)
entity.HasOne(d => d.Item).WithMany()
.HasForeignKey(d => d.ItemId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ancestry_items_item_id_fkey");
@@ -320,6 +552,8 @@ public partial class Pf2eTestContext : DbContext
.HasConstraintName("ancestry_languages_language_id_fkey");
});
modelBuilder.Entity<Background>(entity =>
{
entity.HasKey(e => e.Id).HasName("background_pkey");
@@ -329,26 +563,10 @@ public partial class Pf2eTestContext : DbContext
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Type)
.HasConversion(GetEnumConverter<EntityType>())
.HasColumnName("type");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<Background>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("background_id_fkey");
});
modelBuilder.Entity<BackgroundBoost>(entity =>
@@ -384,7 +602,7 @@ public partial class Pf2eTestContext : DbContext
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("background_items_background_id_fkey");
entity.HasOne(d => d.Entity).WithMany(p => p.BackgroundItems)
entity.HasOne(d => d.Entity).WithMany()
.HasForeignKey(d => d.EntityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("background_items_entity_id_fkey");
@@ -409,6 +627,8 @@ public partial class Pf2eTestContext : DbContext
.HasConstraintName("background_skills_background_id_fkey");
});
modelBuilder.Entity<CampaignFeature>(entity =>
{
entity.HasKey(e => e.Id).HasName("campaign_feature_pkey");
@@ -418,31 +638,21 @@ public partial class Pf2eTestContext : DbContext
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Actions).HasColumnName("actions");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.Property(e => e.Extra).HasColumnName("extra");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<CampaignFeature>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("campaign_feature_id_fkey");
entity.Property(e => e.Level).HasColumnName("level");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.Property(e => e.Actions).HasColumnName("actions");
entity.Property(e => e.Prerequisites)
.HasColumnType("character varying")
.HasColumnName("prerequisites");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.Property(e => e.Extra).HasColumnName("extra");
});
modelBuilder.Entity<Class>(entity =>
{
entity.HasKey(e => e.Id).HasName("class_pkey");
@@ -452,30 +662,15 @@ public partial class Pf2eTestContext : DbContext
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Type)
.HasConversion(GetEnumConverter<EntityType>())
.HasColumnName("type");
entity.Property(e => e.AdditionalTrainedSkills).HasColumnName("additionalTrainedSkills");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<Class>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("class_id_fkey");
entity.Property(e => e.Hp).HasColumnName("hp");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.Property(e => e.Perception).HasColumnName("perception");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.Property(e => e.Spellcasting).HasColumnName("spellcasting");
entity.Property(e => e.AdditionalTrainedSkills).HasColumnName("additionalTrainedSkills");
});
modelBuilder.Entity<ClassKeyAbility>(entity =>
@@ -512,7 +707,7 @@ public partial class Pf2eTestContext : DbContext
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("class_progression_class_id_fkey");
entity.HasOne(d => d.Entity).WithMany(p => p.ClassProgressions)
entity.HasOne(d => d.Entity).WithMany()
.HasForeignKey(d => d.EntityId)
.HasConstraintName("class_progression_entity_id_fkey");
});
@@ -541,6 +736,8 @@ public partial class Pf2eTestContext : DbContext
.HasConstraintName("class_trainings_item_fkey");
});
modelBuilder.Entity<Condition>(entity =>
{
entity.HasKey(e => e.Id).HasName("condition_pkey");
@@ -548,37 +745,19 @@ public partial class Pf2eTestContext : DbContext
entity.ToTable("condition");
entity.Property(e => e.Id)
//.ValueGeneratedNever()
.HasDefaultValueSql("nextval('entity_sequence')")
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Type)
//.HasConversion(GetEnumConverter<EntityType>())
//.HasConversion<string>()
.HasColumnName("type");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<Condition>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("condition_id_fkey");
entity.Property(e => e.Group).HasColumnName("group");
entity.Property(e => e.Extra).HasColumnName("extra");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.Property(e => e.Group)
//.HasConversion(GetEnumConverter<ConditionGroup>())
//.HasConversion<string>()
.HasColumnName("group");
});
modelBuilder.Entity<Deity>(entity =>
{
entity.HasKey(e => e.Id).HasName("deity_pkey");
@@ -588,27 +767,12 @@ public partial class Pf2eTestContext : DbContext
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Type)
.HasConversion(GetEnumConverter<EntityType>())
.HasColumnName("type");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<Deity>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("deity_id_fkey");
entity.Property(e => e.SanctificationMust).HasColumnName("sanctification_must");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.HasMany(d => d.Skills).WithMany(p => p.Deities)
.UsingEntity<Dictionary<string, object>>(
@@ -706,158 +870,7 @@ public partial class Pf2eTestContext : DbContext
.HasConstraintName("deity_weapons_deity_id_fkey");
});
modelBuilder.Entity<Entity>(entity =>
{
entity.HasKey(e => e.Id).HasName("entity_pkey");
entity.ToTable("entity");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.HasMany(d => d.Traits).WithMany(p => p.Entities)
.UsingEntity<Dictionary<string, object>>(
"EntityTrait",
r => r.HasOne<Trait>().WithMany()
.HasForeignKey("TraitId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_traits_trait_id_fkey"),
l => l.HasOne<Entity>().WithMany()
.HasForeignKey("EntityId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_traits_entity_id_fkey"),
j =>
{
j.HasKey("EntityId", "TraitId").HasName("entity_traits_pkey");
j.ToTable("entity_traits");
j.IndexerProperty<int>("EntityId").HasColumnName("entity_id");
j.IndexerProperty<int>("TraitId").HasColumnName("trait_id");
});
});
modelBuilder.Entity<EntityAlias>(entity =>
{
entity.HasKey(e => e.Id).HasName("entity_aliases_pkey");
entity.ToTable("entity_aliases");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Alias)
.HasColumnType("character varying")
.HasColumnName("alias");
entity.Property(e => e.EntityId).HasColumnName("entity_id");
entity.HasOne(d => d.Entity).WithMany(p => p.EntityAliases)
.HasForeignKey(d => d.EntityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_aliases_entity_id_fkey");
});
modelBuilder.Entity<EntityExternal>(entity =>
{
entity.HasKey(e => new { e.EntityId, e.TargetId }).HasName("entity_external_pkey");
entity.ToTable("entity_external");
entity.Property(e => e.EntityId).HasColumnName("entity_id");
entity.Property(e => e.TargetId).HasColumnName("target_id");
entity.Property(e => e.Md5)
.HasColumnType("character varying")
.HasColumnName("md5");
entity.Property(e => e.Path)
.HasColumnType("character varying")
.HasColumnName("path");
entity.Property(e => e.Suffix)
.HasDefaultValueSql("''::character varying")
.HasColumnType("character varying")
.HasColumnName("suffix");
entity.HasOne(d => d.Entity).WithMany(p => p.EntityExternals)
.HasForeignKey(d => d.EntityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_external_entity_id_fkey");
entity.HasOne(d => d.Target).WithMany(p => p.EntityExternals)
.HasForeignKey(d => d.TargetId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_external_target_id_fkey");
});
modelBuilder.Entity<EntityKeyword>(entity =>
{
entity
.HasNoKey()
.ToTable("entity_keywords");
entity.Property(e => e.EntityId).HasColumnName("entity_id");
entity.Property(e => e.KeywordId).HasColumnName("keyword_id");
entity.HasOne(d => d.Entity).WithMany()
.HasForeignKey(d => d.EntityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_keywords_entity_id_fkey");
entity.HasOne(d => d.Keyword).WithMany()
.HasForeignKey(d => d.KeywordId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_keywords_keyword_id_fkey");
});
modelBuilder.Entity<EntitySource>(entity =>
{
entity
.HasNoKey()
.ToTable("entity_sources");
entity.Property(e => e.EntityId).HasColumnName("entity_id");
entity.Property(e => e.IsRemaster).HasColumnName("is_remaster");
entity.Property(e => e.SourceId).HasColumnName("source_id");
entity.Property(e => e.Suffix)
.HasDefaultValueSql("''::character varying")
.HasColumnType("character varying")
.HasColumnName("suffix");
entity.HasOne(d => d.Entity).WithMany()
.HasForeignKey(d => d.EntityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_sources_entity_id_fkey");
entity.HasOne(d => d.Source).WithMany()
.HasForeignKey(d => d.SourceId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("entity_sources_source_id_fkey");
});
modelBuilder.Entity<ExternalTarget>(entity =>
{
entity.HasKey(e => e.Id).HasName("external_target_pkey");
entity.ToTable("external_target");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Icon)
.HasColumnType("character varying")
.HasColumnName("icon");
entity.Property(e => e.Name)
.HasColumnType("character varying")
.HasColumnName("name");
});
modelBuilder.Entity<Feat>(entity =>
{
@@ -868,35 +881,19 @@ public partial class Pf2eTestContext : DbContext
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Type)
.HasConversion(GetEnumConverter<EntityType>())
.HasColumnName("type");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<Feat>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("feat_id_fkey");
entity.Property(e => e.Actions).HasColumnName("actions");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.Property(e => e.Extra).HasColumnName("extra");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.Property(e => e.Level).HasColumnName("level");
entity.Property(e => e.LevelTaken).HasColumnName("level_taken");
entity.Property(e => e.MaxTakable).HasColumnName("max_takable");
entity.Property(e => e.Location)
.HasMaxLength(12)
.HasColumnName("location");
entity.Property(e => e.MaxTakable).HasColumnName("max_takable");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.Property(e => e.OnlyLevel1).HasColumnName("only_level_1");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
});
modelBuilder.Entity<FeatPrerequisite>(entity =>
@@ -917,24 +914,7 @@ public partial class Pf2eTestContext : DbContext
.HasConstraintName("feat_prerequisites_feat_id_fkey");
});
modelBuilder.Entity<Frequency>(entity =>
{
entity.HasKey(e => e.Id).HasName("frequency_pkey");
entity.ToTable("frequency");
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Max).HasColumnName("max");
entity.Property(e => e.Per).HasColumnName("per");
entity.Property(e => e.Value).HasColumnName("value");
entity.HasOne(d => d.IdNavigation).WithOne(p => p.Frequency)
.HasForeignKey<Frequency>(d => d.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("frequency_id_fkey");
});
modelBuilder.Entity<Heritage>(entity =>
{
@@ -945,88 +925,18 @@ public partial class Pf2eTestContext : DbContext
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Type)
.HasConversion(GetEnumConverter<EntityType>())
.HasColumnName("type");
entity.Property(e => e.AncestryId).HasColumnName("ancestry_id");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<Heritage>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("heritage_id_fkey");
entity.Property(e => e.AncestryId).HasColumnName("ancestry_id");
entity.HasOne(d => d.Ancestry).WithMany(p => p.Heritages)
.HasForeignKey(d => d.AncestryId)
.HasConstraintName("heritage_ancestry_id_fkey");
});
modelBuilder.Entity<Keyword>(entity =>
{
entity.HasKey(e => e.Id).HasName("keyword_pkey");
entity.ToTable("keyword");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Slug)
.HasMaxLength(50)
.HasColumnName("slug");
});
modelBuilder.Entity<KeywordAlias>(entity =>
{
entity
.HasNoKey()
.ToTable("keyword_aliases");
entity.Property(e => e.KeywordId).HasColumnName("keyword_id");
entity.Property(e => e.Value)
.HasColumnType("character varying")
.HasColumnName("value");
entity.HasOne(d => d.Keyword).WithMany()
.HasForeignKey(d => d.KeywordId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("keyword_aliases_keyword_id_fkey");
});
modelBuilder.Entity<Language>(entity =>
{
entity.HasKey(e => e.Id).HasName("language_pkey");
entity.ToTable("language");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Name)
.HasColumnType("character varying")
.HasColumnName("name");
});
modelBuilder.Entity<Source>(entity =>
{
entity.HasKey(e => e.Id).HasName("source_pkey");
entity.ToTable("source");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Name)
.HasColumnType("character varying")
.HasColumnName("name");
entity.Property(e => e.Url)
.HasColumnType("character varying")
.HasColumnName("url");
});
modelBuilder.Entity<Spell>(entity =>
{
@@ -1037,46 +947,31 @@ public partial class Pf2eTestContext : DbContext
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Type)
.HasConversion(GetEnumConverter<EntityType>())
.HasColumnName("type");
entity.Property(e => e.CanHeightening).HasColumnName("can_heightening");
entity.HasOne(e => e.Entity).WithOne()
.HasForeignKey<Spell>(e => e.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("spell_id_fkey");
entity.Property(e => e.Level).HasColumnName("level");
entity.Property(e => e.Cost).HasColumnName("cost");
entity.Property(e => e.Counteraction).HasColumnName("counteraction");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.DescriptionGm).HasColumnName("description_gm");
entity.Property(e => e.Sustained).HasColumnName("sustained");
entity.Property(e => e.Duration)
.HasColumnType("character varying")
.HasColumnName("duration");
entity.Property(e => e.Img)
.HasMaxLength(150)
.HasColumnName("img");
entity.Property(e => e.IsChecked)
.HasDefaultValue(false)
.HasColumnName("is_checked");
entity.Property(e => e.IsTranslated)
.HasDefaultValue(false)
.HasColumnName("is_translated");
entity.Property(e => e.Level).HasColumnName("level");
entity.Property(e => e.Name)
.HasMaxLength(150)
.HasColumnName("name");
entity.Property(e => e.Range)
.HasColumnType("character varying")
.HasColumnName("range");
entity.Property(e => e.Requirements)
.HasColumnType("character varying")
.HasColumnName("requirements");
entity.Property(e => e.Slug)
.HasMaxLength(150)
.HasColumnName("slug");
entity.Property(e => e.Sustained).HasColumnName("sustained");
entity.Property(e => e.Target)
.HasColumnType("character varying")
.HasColumnName("target");
entity.Property(e => e.Time)
.HasColumnType("character varying")
.HasColumnName("time");
entity.Property(e => e.CanHeightening).HasColumnName("can_heightening");
});
modelBuilder.Entity<SpellArea>(entity =>
@@ -1170,30 +1065,6 @@ public partial class Pf2eTestContext : DbContext
.HasConstraintName("spell_ritual_spell_id_fkey");
});
modelBuilder.Entity<Training>(entity =>
{
entity.HasKey(e => e.Id).HasName("trainings_pkey");
entity.ToTable("trainings");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Key)
.HasColumnType("character varying")
.HasColumnName("key");
});
modelBuilder.Entity<Trait>(entity =>
{
entity.HasKey(e => e.Id).HasName("trait_pkey");
entity.ToTable("trait");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.Name)
.HasColumnType("character varying")
.HasColumnName("name");
});
OnModelCreatingPartial(modelBuilder);
}
+33 -31
View File
@@ -142,6 +142,7 @@ CREATE TYPE "trait_type" AS ENUM (
CREATE TABLE "trait" (
"id" INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
"name" varchar NOT NULL,
"slug" varchar NOT NULL,
"description" text NOT NULL,
"type" trait_type NOT NULL
);
@@ -210,7 +211,7 @@ CREATE TYPE "spell_damage_kinds" AS ENUM (
);
CREATE TABLE "spell" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY,
"id" int PRIMARY KEY,
"level" int NOT NULL,
"cost" int NOT NULL,
"counteraction" bool NOT NULL,
@@ -221,8 +222,8 @@ CREATE TABLE "spell" (
"target" varchar NOT NULL,
"time" varchar NOT NULL,
"can_heightening" bool NOT NULL
) INHERITS ("entity");
-- ALTER TABLE "spell" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
);
ALTER TABLE "spell" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
CREATE TABLE "spell_area" (
"spell_id" int PRIMARY KEY,
@@ -287,27 +288,27 @@ CREATE TYPE "ancestry_vision" AS ENUM (
);
CREATE TABLE "action" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY,
"id" int PRIMARY KEY,
"action_type" action_type NOT NULL,
"actions" int,
"category" action_category,
"death_note" bool,
"extra" text
) INHERITS ("entity");
-- ALTER TABLE "action" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
);
ALTER TABLE "action" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
-- Ancestry
CREATE TABLE "ancestry" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY,
"id" int PRIMARY KEY,
"hp" int NOT NULL,
"reach" int NOT NULL,
"size" enum_size NOT NULL,
"speed" int NOT NULL,
"vision" ancestry_vision NOT NULL
) INHERITS ("entity");
-- ALTER TABLE "ancestry" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
);
ALTER TABLE "ancestry" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
CREATE TABLE "ancestry_languages" (
"ancestry_id" int,
@@ -339,9 +340,9 @@ ALTER TABLE "ancestry_items" ADD FOREIGN KEY ("item_id") REFERENCES "entity" ("i
-- Background
CREATE TABLE "background" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY
) INHERITS ("entity");
-- ALTER TABLE "background" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
"id" int PRIMARY KEY
);
ALTER TABLE "background" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
CREATE TABLE "background_items" (
"background_id" int,
@@ -380,15 +381,15 @@ CREATE TYPE "campaign_feature_category" AS ENUM (
);
CREATE TABLE "campaign_feature" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY,
"id" int PRIMARY KEY,
"level" int,
"action_type" action_type NOT NULL,
"actions" int NOT NULL,
"category" campaign_feature_category NOT NULL,
"prerequisites" varchar,
"extra" text
) INHERITS ("entity");
-- ALTER TABLE "campaign_feature" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
);
ALTER TABLE "campaign_feature" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
-- Class
@@ -404,13 +405,13 @@ CREATE TYPE "class_progression_type" AS ENUM (
);
CREATE TABLE "class" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY,
"id" int PRIMARY KEY,
"hp" int NOT NULL,
"perception" int NOT NULL,
"spellcasting" bool NOT NULL,
"additionalTrainedSkills" int NOT NULL
) INHERITS ("entity");
-- ALTER TABLE "class" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
);
ALTER TABLE "class" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
CREATE TABLE "class_key_abilities" (
"id" INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
@@ -452,11 +453,11 @@ CREATE TYPE "condition_group" AS ENUM (
);
CREATE TABLE "condition" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY,
"id" int PRIMARY KEY,
"group" condition_group,
"extra" text
) INHERITS ("entity");
-- ALTER TABLE "condition" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
);
ALTER TABLE "condition" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
-- Deity
@@ -483,13 +484,13 @@ CREATE TYPE "deity_sanctification" AS ENUM (
);
CREATE TABLE "deity" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY,
"id" int PRIMARY KEY,
"category" deity_category NOT NULL,
"font" deity_fonts NOT NULL,
"sanctification_must" bool NOT NULL,
"sanctification_type" deity_sanctification NOT NULL
) INHERITS ("entity");
-- ALTER TABLE "deity" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
);
ALTER TABLE "deity" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
CREATE TABLE "deity_attributes" (
"deity_id" int,
@@ -549,7 +550,7 @@ CREATE TYPE "feat_category" AS ENUM (
);
CREATE TABLE "feat" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY,
"id" int PRIMARY KEY,
"action_type" action_type NOT NULL,
"actions" int,
"category" feat_category NOT NULL,
@@ -559,8 +560,8 @@ CREATE TABLE "feat" (
"location" varchar(12),
"only_level_1" bool,
"extra" text
) INHERITS ("entity");
-- ALTER TABLE "feat" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
);
ALTER TABLE "feat" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
CREATE TABLE "feat_prerequisites" (
"id" INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
@@ -573,10 +574,10 @@ ALTER TABLE "feat_prerequisites" ADD FOREIGN KEY ("feat_id") REFERENCES "feat" (
-- Heritage
CREATE TABLE "heritage" (
"id" int DEFAULT nextval('entity_sequence') PRIMARY KEY,
"id" int PRIMARY KEY,
"ancestry_id" int
) INHERITS ("entity");
-- ALTER TABLE "heritage" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
);
ALTER TABLE "heritage" ADD FOREIGN KEY ("id") REFERENCES "entity" ("id");
ALTER TABLE "heritage" ADD FOREIGN KEY ("ancestry_id") REFERENCES "ancestry" ("id");
@@ -599,6 +600,7 @@ $func$;
----------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION f_drop_tables()
RETURNS void
LANGUAGE plpgsql AS
@@ -616,7 +618,7 @@ $func$;
----------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION f_drop_tables(_username text)
CREATE OR REPLACE FUNCTION f_permission_tables(_username text)
RETURNS void
LANGUAGE plpgsql AS
$func$
+2 -3
View File
@@ -14,8 +14,6 @@ Table entity {
is_translated bool [default: false, note: "Первичный импорт идёт из англоязычного источника, перевод приходит вторым"]
is_checked bool [default: false, note: "Флаг, указывающий, что перевод был проверен вручную и не требует обновления парсером"]
}
Enum entity_type {
action
@@ -98,6 +96,7 @@ Table entity_external {
Table trait {
id int [pk, increment]
name varchar [not null]
slug varchar [not null]
description text [not null]
type trait_type [not null]
}
@@ -369,7 +368,7 @@ Enum class_progression_type {
Table condition {
id int [pk, ref: - entity.id]
group condition_group [null]
group condition_group [null, note: "{}.group"]
extra text [null, note: "json для того, что надо рассмотреть"]