Исправление БД (перечисление)

This commit is contained in:
2025-04-18 21:51:56 +04:00
parent 38bc6152ed
commit 29aee61d4c
3 changed files with 125 additions and 116 deletions
@@ -13,7 +13,7 @@ using Pf2eModel.Model.Enum;
namespace Pf2eModel.Migrations namespace Pf2eModel.Migrations
{ {
[DbContext(typeof(Pf2eDbContext))] [DbContext(typeof(Pf2eDbContext))]
[Migration("20250418160209_1")] [Migration("20250418174520_1")]
partial class _1 partial class _1
{ {
/// <inheritdoc /> /// <inheritdoc />
@@ -35,7 +35,7 @@ namespace Pf2eModel.Migrations
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell", "language" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" }); 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, "feat_category", new[] { "ancestryfeature", "classfeature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign_feature" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "tiny", "small", "medium", "large" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "tiny", "small", "medium", "large" });
@@ -425,41 +425,6 @@ namespace Pf2eModel.Migrations
b.ToTable("frequencies", (string)null); b.ToTable("frequencies", (string)null);
}); });
modelBuilder.Entity("Pf2eModel.Model.Common.Language", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("name")
.HasColumnOrder(2);
b.Property<EntityRarity>("Rarity")
.HasColumnType("entity_rarity")
.HasColumnName("rarity")
.HasColumnOrder(4);
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("slug")
.HasColumnOrder(3);
b.HasKey("Id")
.HasName("pk_languages");
b.ToTable("languages", (string)null);
});
modelBuilder.Entity("Pf2eModel.Model.Common.Training", b => modelBuilder.Entity("Pf2eModel.Model.Common.Training", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -1186,6 +1151,29 @@ namespace Pf2eModel.Migrations
b.ToTable("heritages", (string)null); b.ToTable("heritages", (string)null);
}); });
modelBuilder.Entity("Pf2eModel.Model.Structure.Language", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("EntityId")
.HasColumnType("integer")
.HasColumnName("entity_id");
b.HasKey("Id")
.HasName("pk_languages");
b.HasIndex("EntityId")
.HasDatabaseName("ix_languages_entity_id");
b.ToTable("languages", (string)null);
});
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b => modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -1628,7 +1616,7 @@ namespace Pf2eModel.Migrations
.IsRequired() .IsRequired()
.HasConstraintName("fk_ancestry_languages_ancestries_ancestry_id"); .HasConstraintName("fk_ancestry_languages_ancestries_ancestry_id");
b.HasOne("Pf2eModel.Model.Common.Language", "Language") b.HasOne("Pf2eModel.Model.Structure.Language", "Language")
.WithMany() .WithMany()
.HasForeignKey("LanguageId") .HasForeignKey("LanguageId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -1895,6 +1883,18 @@ namespace Pf2eModel.Migrations
b.Navigation("Entity"); b.Navigation("Entity");
}); });
modelBuilder.Entity("Pf2eModel.Model.Structure.Language", b =>
{
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
.WithMany()
.HasForeignKey("EntityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_languages_entities_entity_id");
b.Navigation("Entity");
});
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b => modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
{ {
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity") b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
@@ -25,7 +25,7 @@ namespace Pf2eModel.Migrations
.Annotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any") .Annotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any")
.Annotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any") .Annotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any")
.Annotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique") .Annotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique")
.Annotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell") .Annotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,background,backpack,campaign_feature,class,condition,deity,feat,heritage,spell,language")
.Annotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free") .Annotation("Npgsql:Enum:feat_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:feat_category", "ancestryfeature,classfeature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign_feature")
.Annotation("Npgsql:Enum:size", "tiny,small,medium,large") .Annotation("Npgsql:Enum:size", "tiny,small,medium,large")
@@ -99,21 +99,6 @@ namespace Pf2eModel.Migrations
table.PrimaryKey("pk_keywords", x => x.id); table.PrimaryKey("pk_keywords", x => x.id);
}); });
migrationBuilder.CreateTable(
name: "languages",
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),
slug = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
rarity = table.Column<EntityRarity>(type: "entity_rarity", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_languages", x => x.id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "sources", name: "sources",
columns: table => new columns: table => new
@@ -310,6 +295,25 @@ namespace Pf2eModel.Migrations
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable(
name: "languages",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
entity_id = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_languages", x => x.id);
table.ForeignKey(
name: "fk_languages_entities_entity_id",
column: x => x.entity_id,
principalTable: "entities",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "spells", name: "spells",
columns: table => new columns: table => new
@@ -497,31 +501,6 @@ namespace Pf2eModel.Migrations
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable(
name: "ancestry_languages",
columns: table => new
{
ancestry_id = table.Column<int>(type: "integer", nullable: false),
language_id = table.Column<int>(type: "integer", nullable: false),
is_additional = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_ancestry_languages", x => new { x.ancestry_id, x.language_id });
table.ForeignKey(
name: "fk_ancestry_languages_ancestries_ancestry_id",
column: x => x.ancestry_id,
principalTable: "ancestries",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_ancestry_languages_languages_language_id",
column: x => x.language_id,
principalTable: "languages",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "heritages", name: "heritages",
columns: table => new columns: table => new
@@ -795,6 +774,31 @@ namespace Pf2eModel.Migrations
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable(
name: "ancestry_languages",
columns: table => new
{
ancestry_id = table.Column<int>(type: "integer", nullable: false),
language_id = table.Column<int>(type: "integer", nullable: false),
is_additional = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_ancestry_languages", x => new { x.ancestry_id, x.language_id });
table.ForeignKey(
name: "fk_ancestry_languages_ancestries_ancestry_id",
column: x => x.ancestry_id,
principalTable: "ancestries",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_ancestry_languages_languages_language_id",
column: x => x.language_id,
principalTable: "languages",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "deity_spells", name: "deity_spells",
columns: table => new columns: table => new
@@ -1054,6 +1058,11 @@ namespace Pf2eModel.Migrations
table: "keyword_aliases", table: "keyword_aliases",
column: "keyword_id"); column: "keyword_id");
migrationBuilder.CreateIndex(
name: "ix_languages_entity_id",
table: "languages",
column: "entity_id");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "ix_spell_damages_spell_id", name: "ix_spell_damages_spell_id",
table: "spell_damages", table: "spell_damages",
@@ -32,7 +32,7 @@ namespace Pf2eModel.Migrations
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell", "language" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" }); 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, "feat_category", new[] { "ancestryfeature", "classfeature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign_feature" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "tiny", "small", "medium", "large" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "size", new[] { "tiny", "small", "medium", "large" });
@@ -422,41 +422,6 @@ namespace Pf2eModel.Migrations
b.ToTable("frequencies", (string)null); b.ToTable("frequencies", (string)null);
}); });
modelBuilder.Entity("Pf2eModel.Model.Common.Language", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("name")
.HasColumnOrder(2);
b.Property<EntityRarity>("Rarity")
.HasColumnType("entity_rarity")
.HasColumnName("rarity")
.HasColumnOrder(4);
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("slug")
.HasColumnOrder(3);
b.HasKey("Id")
.HasName("pk_languages");
b.ToTable("languages", (string)null);
});
modelBuilder.Entity("Pf2eModel.Model.Common.Training", b => modelBuilder.Entity("Pf2eModel.Model.Common.Training", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -1183,6 +1148,29 @@ namespace Pf2eModel.Migrations
b.ToTable("heritages", (string)null); b.ToTable("heritages", (string)null);
}); });
modelBuilder.Entity("Pf2eModel.Model.Structure.Language", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasColumnOrder(1);
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("EntityId")
.HasColumnType("integer")
.HasColumnName("entity_id");
b.HasKey("Id")
.HasName("pk_languages");
b.HasIndex("EntityId")
.HasDatabaseName("ix_languages_entity_id");
b.ToTable("languages", (string)null);
});
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b => modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -1625,7 +1613,7 @@ namespace Pf2eModel.Migrations
.IsRequired() .IsRequired()
.HasConstraintName("fk_ancestry_languages_ancestries_ancestry_id"); .HasConstraintName("fk_ancestry_languages_ancestries_ancestry_id");
b.HasOne("Pf2eModel.Model.Common.Language", "Language") b.HasOne("Pf2eModel.Model.Structure.Language", "Language")
.WithMany() .WithMany()
.HasForeignKey("LanguageId") .HasForeignKey("LanguageId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -1892,6 +1880,18 @@ namespace Pf2eModel.Migrations
b.Navigation("Entity"); b.Navigation("Entity");
}); });
modelBuilder.Entity("Pf2eModel.Model.Structure.Language", b =>
{
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
.WithMany()
.HasForeignKey("EntityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_languages_entities_entity_id");
b.Navigation("Entity");
});
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b => modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
{ {
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity") b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")