mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-15 13:55:42 +00:00
Re-scaffold C# db
This commit is contained in:
@@ -252,6 +252,8 @@ public partial class SpacebarDbContext : DbContext
|
||||
modelBuilder.Entity<EmbedCache>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_0abb7581d4efc5a8b1361389c5e");
|
||||
|
||||
entity.Property(e => e.CreatedAt).HasDefaultValueSql("now()");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Emoji>(entity =>
|
||||
@@ -286,6 +288,12 @@ public partial class SpacebarDbContext : DbContext
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_3aa6e80a6d325601054892b1340");
|
||||
|
||||
entity.HasIndex(e => e.Fingerprint, "instance_bans_fingerprint_idx").HasMethod("hash");
|
||||
|
||||
entity.HasIndex(e => e.IpAddress, "instance_bans_ip_address_idx").HasMethod("hash");
|
||||
|
||||
entity.HasIndex(e => e.UserId, "instance_bans_user_id_idx").HasMethod("hash");
|
||||
|
||||
entity.Property(e => e.CreatedAt).HasDefaultValueSql("now()");
|
||||
|
||||
entity.HasOne(d => d.OriginInstanceBan).WithOne(p => p.InverseOriginInstanceBan)
|
||||
|
||||
@@ -37,9 +37,6 @@ public partial class Channel
|
||||
[Column("owner_id", TypeName = "character varying")]
|
||||
public string? OwnerId { get; set; }
|
||||
|
||||
[Column("last_pin_timestamp")]
|
||||
public int? LastPinTimestamp { get; set; }
|
||||
|
||||
[Column("default_auto_archive_duration")]
|
||||
public int? DefaultAutoArchiveDuration { get; set; }
|
||||
|
||||
@@ -88,6 +85,12 @@ public partial class Channel
|
||||
[Column("applied_tags")]
|
||||
public List<string>? AppliedTags { get; set; }
|
||||
|
||||
[Column("last_pin_timestamp")]
|
||||
public DateTime? LastPinTimestamp { get; set; }
|
||||
|
||||
[Column("status")]
|
||||
public string? Status { get; set; }
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<CloudAttachment> CloudAttachments { get; set; } = new List<CloudAttachment>();
|
||||
|
||||
|
||||
@@ -17,5 +17,11 @@ public partial class EmbedCache
|
||||
public string Url { get; set; } = null!;
|
||||
|
||||
[Column("embed")]
|
||||
public string Embed { get; set; } = null!;
|
||||
public string? Embed { get; set; }
|
||||
|
||||
[Column("created_at")]
|
||||
public DateTime? CreatedAt { get; set; }
|
||||
|
||||
[Column("embeds")]
|
||||
public string? Embeds { get; set; }
|
||||
}
|
||||
|
||||
@@ -74,6 +74,9 @@ public partial class Member
|
||||
[Column("collectibles")]
|
||||
public string? Collectibles { get; set; }
|
||||
|
||||
[Column("flags")]
|
||||
public int Flags { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Members")]
|
||||
public virtual Guild Guild { get; set; } = null!;
|
||||
|
||||
@@ -23,9 +23,6 @@ public partial class ReadState
|
||||
[Column("last_message_id", TypeName = "character varying")]
|
||||
public string? LastMessageId { get; set; }
|
||||
|
||||
[Column("public_ack", TypeName = "character varying")]
|
||||
public string? PublicAck { get; set; }
|
||||
|
||||
[Column("notifications_cursor", TypeName = "character varying")]
|
||||
public string? NotificationsCursor { get; set; }
|
||||
|
||||
@@ -33,7 +30,19 @@ public partial class ReadState
|
||||
public DateTime? LastPinTimestamp { get; set; }
|
||||
|
||||
[Column("mention_count")]
|
||||
public int? MentionCount { get; set; }
|
||||
public int MentionCount { get; set; }
|
||||
|
||||
[Column("last_acked_id", TypeName = "character varying")]
|
||||
public string? LastAckedId { get; set; }
|
||||
|
||||
[Column("badge_count")]
|
||||
public int BadgeCount { get; set; }
|
||||
|
||||
[Column("read_state_type")]
|
||||
public int ReadStateType { get; set; }
|
||||
|
||||
[Column("flags")]
|
||||
public int Flags { get; set; }
|
||||
|
||||
[ForeignKey("ChannelId")]
|
||||
[InverseProperty("ReadStates")]
|
||||
|
||||
@@ -7,11 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.3">-->
|
||||
<!-- <PrivateAssets>all</PrivateAssets>-->
|
||||
<!-- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>-->
|
||||
<!-- </PackageReference>-->
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="*" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,59 +1,154 @@
|
||||
[
|
||||
{
|
||||
"pname": "Humanizer.Core",
|
||||
"version": "2.14.1",
|
||||
"hash": "sha256-EXvojddPu+9JKgOG9NSQgUTfWq1RpOYw7adxDPKDJ6o="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Build.Framework",
|
||||
"version": "17.11.31",
|
||||
"hash": "sha256-YS4oASrmC5dmZrx5JPS7SfKmUpIJErlUpVDsU3VrfFE="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Build.Framework",
|
||||
"version": "18.0.2",
|
||||
"hash": "sha256-fO31KAdDs2J0RUYD1ov9UB3ucsbALan7K0YdWW+yg7A="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.CodeAnalysis.Analyzers",
|
||||
"version": "3.11.0",
|
||||
"hash": "sha256-hQ2l6E6PO4m7i+ZsfFlEx+93UsLPo4IY3wDkNG11/Sw="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.CodeAnalysis.Common",
|
||||
"version": "5.0.0",
|
||||
"hash": "sha256-g4ALvBSNyHEmSb1l5TFtWW7zEkiRmhqLx4XWZu9sr2U="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.CodeAnalysis.CSharp",
|
||||
"version": "5.0.0",
|
||||
"hash": "sha256-ctBCkQGFpH/xT5rRE3xibu9YxPD108RuC4a4Z25koG8="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.CodeAnalysis.CSharp.Workspaces",
|
||||
"version": "5.0.0",
|
||||
"hash": "sha256-yWVcLt/f2CouOfFy966glGdtSFy+RcgrU1dd9UtlL/Q="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.CodeAnalysis.Workspaces.Common",
|
||||
"version": "5.0.0",
|
||||
"hash": "sha256-Bir5e1gEhgQQ6upQmVKQHAKLRfenAu60DAzNupNnZsQ="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.CodeAnalysis.Workspaces.MSBuild",
|
||||
"version": "5.0.0",
|
||||
"hash": "sha256-+58+iqTayTiE0pDaog1U8mjaDA8bNNDLA8gjCQZZudo="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-V3Vwl1MtVMRTPo7a9lAgs6UaeMnFV3eEsKnLyPaPMHA="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore",
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-SR8KBOuIx9e1j/cMwYRCO62WEB+CUrGptexl9MSgp8M="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-so4y7Wrp/oWhQ7wd1rK9ha9GtPme1l5H8SrQz7sf8MQ="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Abstractions",
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-qMKa7YGJUfaPTRMsAYYPlLxXdhZeyAZLiOSDcNFzDnA="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Analyzers",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-Wed75M4RdQ7bCUWSc+q/0YqL6R5CrIZ2X0t/LpU7ZZA="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Analyzers",
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-jPTN3RkI1J7vb7O4xiCHjMczMKh//NnKhJAGTuT7v88="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Design",
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-+D17/sNpPhhDaLJJR4fFjSMySFU4yKQzHgzPcAJAdR0="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Relational",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-WwGoCwNxDXyqfBvUX9fGa/6X+yiDBuE7hf3csU78+Os="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Relational",
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-5jfkvUKSexKCbCsYZYkBAWd4BIN48dlF5pP6htfDMMQ="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Caching.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-/vLXWvT42HQAm/JLjWGeFo9AvLn/mu4nCNjabm+wABE="
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-3rW3DjoyIIgfeJOHvdZJSrtsZ76V3MNxH5RLICRXWv4="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Caching.Memory",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-+0sK/vSyB4KFC9kliECROfK1WaiWwlRrhLpi03pT+3w="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Caching.Memory",
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-WP2/64G4k48qdIohuOOgln9p0b2SJzxWzECfPqX6lQk="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Configuration.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-bvEQLGSOpJHKdPD6kd59IIi4x57lKapVMgOORtcjJPs="
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-DNK+lL2jeHFYyd43zfgVY32UskEfQ4YsTapztuQbYwo="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.DependencyInjection",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-hbpKNzN0KIszhlpM5iAT/V3B7QRs3FGTZI9Wq/cYc1A="
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-ofDRirUV9XLSz4oksCqErwBJFtAieHACFfyZukHKFng="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.DependencyInjection",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-dAH52PPlTLn7X+1aI/7npdrDzMEFPMXRv4isV1a+14k="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.DependencyInjection.Abstractions",
|
||||
"version": "10.0.0",
|
||||
"hash": "sha256-9iodXP39YqgxomnOPOxd/mzbG0JfOSXzFoNU3omT2Ps="
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-KrP+hE3gk7pATbJYZsJ1LHiXjzLA+ntHW7G/VGgHk2g="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.DependencyInjection.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-0QhVYjk9Cxy6NFef9VKftGmscTZnvcD1bhBQoXz3mwA="
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-CncVwkKZ5CsIG2O0+OM9qXuYXh3p6UGyueTHSLDVL+c="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.DependencyModel",
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-UfG98EJ+0JTQA8Kx8yxt9mg19s0RSIOO+pG9JJy8uB0="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Logging",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-eneXBu83dGBiWMFabheGFPYiZJQ+WMewG6bTs2oJ7RA="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Logging",
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-4gVrKZfo/YHZKgKNsgGZZYqa79XWK9wDUuiVfguUV6U="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Logging",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-kR16c+N8nQrWeYLajqnXPg7RiXjZMSFLnKLEs4VfjcM="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Logging.Abstractions",
|
||||
"version": "10.0.0",
|
||||
@@ -61,18 +156,48 @@
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Logging.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-dvBRBgEf4Bw9NW2J2XDlEeJw2TNhJ+6gV98dPE13/J0="
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-e3A/l+II+n+D7/OPwjdyQM1IBtKHfHeIdlkJmuRw77w="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Logging.Abstractions",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-iBTs9twjWXFeERt4CErkIIcoJZU1jrd1RWCI8V5j7KU="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Options",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-ybyUtpSs/irdarkVjsGhqDcj0w8TNUgh0Kp0j3EVfIA="
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-nw+m6VWXjmaBqZ1aH/l9SR9Oy62N9dmiMKloJ78kxv8="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Options",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-DT5euAQY/ItB5LPI8WIp6Dnd0lSvBRP35vFkOXC68ck="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Primitives",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-ePpEFzrKQbEMY6Kh/xyxKHq6txNru62Vh4LVZO5Rrvg="
|
||||
"version": "10.0.5",
|
||||
"hash": "sha256-uvrur+0dg4zAAQcpLkkhPA77ST0tA3+EpGdDlCckC+E="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Primitives",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-ZNLusK1CRuq5BZYZMDqaz04PIKScE2Z7sS2tehU7EJs="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.VisualStudio.SolutionPersistence",
|
||||
"version": "1.0.52",
|
||||
"hash": "sha256-KZGPtOXe6Hv8RrkcsgoLKTRyaCScIpQEa2NhNB3iOXw="
|
||||
},
|
||||
{
|
||||
"pname": "Mono.TextTemplating",
|
||||
"version": "3.0.0",
|
||||
"hash": "sha256-VlgGDvgNZb7MeBbIZ4DE2Nn/j2aD9k6XqNHnASUSDr0="
|
||||
},
|
||||
{
|
||||
"pname": "Newtonsoft.Json",
|
||||
"version": "13.0.3",
|
||||
"hash": "sha256-hy/BieY4qxBWVVsDqqOPaLy1QobiIapkbrESm6v2PHc="
|
||||
},
|
||||
{
|
||||
"pname": "Npgsql",
|
||||
@@ -83,5 +208,40 @@
|
||||
"pname": "Npgsql.EntityFrameworkCore.PostgreSQL",
|
||||
"version": "10.0.1",
|
||||
"hash": "sha256-G5WmWoc02gHTsdBLXESFQ5eMV+liwiO8YjzFKg4NDEk="
|
||||
},
|
||||
{
|
||||
"pname": "System.CodeDom",
|
||||
"version": "6.0.0",
|
||||
"hash": "sha256-uPetUFZyHfxjScu5x4agjk9pIhbCkt5rG4Axj25npcQ="
|
||||
},
|
||||
{
|
||||
"pname": "System.Composition",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-FehOkQ2u1p8mQ0/wn3cZ+24HjhTLdck8VZYWA1CcgbM="
|
||||
},
|
||||
{
|
||||
"pname": "System.Composition.AttributedModel",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-a7y7H6zj+kmYkllNHA402DoVfY9IaqC3Ooys8Vzl24M="
|
||||
},
|
||||
{
|
||||
"pname": "System.Composition.Convention",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-tw4vE5JRQ60ubTZBbxoMPhtjOQCC3XoDFUH7NHO7o8U="
|
||||
},
|
||||
{
|
||||
"pname": "System.Composition.Hosting",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-oOxU+DPEEfMCuNLgW6wSkZp0JY5gYt44FJNnWt+967s="
|
||||
},
|
||||
{
|
||||
"pname": "System.Composition.Runtime",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-AyIe+di1TqwUBbSJ/sJ8Q8tzsnTN+VBdJw4K8xZz43s="
|
||||
},
|
||||
{
|
||||
"pname": "System.Composition.TypedParts",
|
||||
"version": "9.0.0",
|
||||
"hash": "sha256-F5fpTUs3Rr7yP/NyIzr+Xn5NdTXXp8rrjBnF9UBBUog="
|
||||
}
|
||||
]
|
||||
|
||||
@@ -21,10 +21,10 @@ pushd Models
|
||||
dotnet new classlib --no-restore -o Spacebar.Models.Db
|
||||
pushd Spacebar.Models.Db
|
||||
rm Class1.cs
|
||||
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL -n -f net9.0
|
||||
dotnet add package Microsoft.EntityFrameworkCore.Design -n -f net9.0
|
||||
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL -n -f net10.0
|
||||
dotnet add package Microsoft.EntityFrameworkCore.Design -n -f net10.0
|
||||
|
||||
dotnet restore
|
||||
dotnet build
|
||||
|
||||
dotnet-ef dbcontext scaffold "Host=127.0.0.1; Username=postgres; Database=sb-server-scaffold" \
|
||||
Npgsql.EntityFrameworkCore.PostgreSQL \
|
||||
@@ -33,7 +33,11 @@ dotnet-ef dbcontext scaffold "Host=127.0.0.1; Username=postgres; Database=sb-ser
|
||||
--context-dir Contexts \
|
||||
--force \
|
||||
--no-onconfiguring \
|
||||
--data-annotations
|
||||
--data-annotations \
|
||||
--no-build
|
||||
|
||||
|
||||
echo 'Patching results...'
|
||||
|
||||
for f in **/*.cs; do
|
||||
dos2unix --verbose --keepdate "$f"
|
||||
@@ -43,4 +47,11 @@ for patch in ../db-patches/*.patch; do
|
||||
patch --verbose -p2 < $patch
|
||||
done
|
||||
|
||||
echo '[]' > deps.json
|
||||
git add .
|
||||
popd
|
||||
popd
|
||||
echo 'Updating deps.json...'
|
||||
./update-deps.cs Spacebar-Models-Db
|
||||
|
||||
echo 'Scaffolded database and applied patches. Dont forget to generate new patches with `cd Models && git diff --relative Spacebar.Models.Db/path/xyz > db-patches/001-your-patch-name.patch!`'
|
||||
|
||||
Reference in New Issue
Block a user