diff --git a/Directory.Packages.props b/Directory.Packages.props
index 3c60acd..be8b079 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -37,6 +37,7 @@
+
diff --git a/src/Infrastructure/DependencyInjection.cs b/src/Infrastructure/DependencyInjection.cs
index 4aae695..c4abf71 100644
--- a/src/Infrastructure/DependencyInjection.cs
+++ b/src/Infrastructure/DependencyInjection.cs
@@ -21,8 +21,8 @@ public static class DependencyInjection
{
// Replace password in the connection string with env var in local environment.
// Prod will use the connectionString stored in the vault with password in it directly.
- var connectionString = configuration.GetConnectionString("DefaultConnection")
- ?? throw new InvalidOperationException("Missing ConnectionString: DefaultConnection");
+ var connectionString = configuration.GetConnectionString("MssqlConnection")
+ ?? throw new InvalidOperationException("Missing ConnectionStrings:MssqlConnection");
services.AddScoped();
services.AddScoped();
diff --git a/src/Web/Contents/Data/Content.cs b/src/Web/Contents/Data/Content.cs
index c13bd0b..b67a92f 100644
--- a/src/Web/Contents/Data/Content.cs
+++ b/src/Web/Contents/Data/Content.cs
@@ -4,10 +4,9 @@ public class Content
{
public Guid Id { get; init; }
public Guid CreatedBy { get; init; }
- public DateTime CreatedAt { get; }
+ public DateTimeOffset CreatedAt { get; }
- public string? Title { get; init; } = null!;
- public string? Description { get; init; } = null!;
- public string? Uri { get; init; } = null!;
+ public string? Title { get; init; }
+ public string? Description { get; init; }
+ public string? Uri { get; init; }
}
-
diff --git a/src/Web/Contents/Handlers/GetContentsByUser.cs b/src/Web/Contents/Handlers/GetContentsByUser.cs
index a5e0a8f..50cb478 100644
--- a/src/Web/Contents/Handlers/GetContentsByUser.cs
+++ b/src/Web/Contents/Handlers/GetContentsByUser.cs
@@ -31,9 +31,9 @@ public class GetContentsByUser(
.Where(c => c.CreatedBy == req.UserId);
if (req.LastId is not null)
- query = query.OrderBy(c => c.Id).Where(c => c.Id > req.LastId.Value);
+ query = query.OrderByDescending(c => c.Id).Where(c => c.Id < req.LastId.Value);
else
- query = query.OrderBy(c => c.Id);
+ query = query.OrderByDescending(c => c.Id);
query = query.Take(req.MaxItems);
diff --git a/src/Web/Contents/Handlers/PostContent.cs b/src/Web/Contents/Handlers/PostContent.cs
index fd8ecbd..e741c18 100644
--- a/src/Web/Contents/Handlers/PostContent.cs
+++ b/src/Web/Contents/Handlers/PostContent.cs
@@ -26,6 +26,7 @@ public class PostContent(
await context.Contents.AddAsync(
new Content
{
+ Id = GuidHelper.GenerateUuidV7(),
CreatedBy = User.GetUserId(),
Title = req.Title,
Description = req.Description,
diff --git a/src/Web/Contents/Migrations/20240702034957_Initial.Designer.cs b/src/Web/Contents/Migrations/20240702034957_Initial.Designer.cs
deleted file mode 100644
index c63f6b4..0000000
--- a/src/Web/Contents/Migrations/20240702034957_Initial.Designer.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-using System;
-using Hutopy.Web.Contents.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace Hutopy.Web.Contents.Migrations
-{
- [DbContext(typeof(ContentDbContext))]
- [Migration("20240702034957_Initial")]
- partial class Initial
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("Hutopy.Web.Contents.Data.Content", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uniqueidentifier");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("datetime2")
- .HasDefaultValueSql("CURRENT_TIMESTAMP");
-
- b.Property("CreatedBy")
- .HasColumnType("uniqueidentifier");
-
- b.Property("Description")
- .HasColumnType("nvarchar(max)");
-
- b.Property("Title")
- .HasColumnType("nvarchar(max)");
-
- b.Property("Uri")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Contents");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/Web/Contents/Migrations/20240707030928_ChangingContentDefaultSchema.cs b/src/Web/Contents/Migrations/20240707030928_ChangingContentDefaultSchema.cs
deleted file mode 100644
index df1bb9f..0000000
--- a/src/Web/Contents/Migrations/20240707030928_ChangingContentDefaultSchema.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace Hutopy.Web.Contents.Migrations
-{
- ///
- public partial class ChangingContentDefaultSchema : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.EnsureSchema(
- name: "Content");
-
- migrationBuilder.RenameTable(
- name: "Contents",
- newName: "Contents",
- newSchema: "Content");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.RenameTable(
- name: "Contents",
- schema: "Content",
- newName: "Contents");
- }
- }
-}
diff --git a/src/Web/Contents/Migrations/20240707030928_ChangingContentDefaultSchema.Designer.cs b/src/Web/Contents/Migrations/20240718034516_Initial.Designer.cs
similarity index 65%
rename from src/Web/Contents/Migrations/20240707030928_ChangingContentDefaultSchema.Designer.cs
rename to src/Web/Contents/Migrations/20240718034516_Initial.Designer.cs
index 2555444..9fb4610 100644
--- a/src/Web/Contents/Migrations/20240707030928_ChangingContentDefaultSchema.Designer.cs
+++ b/src/Web/Contents/Migrations/20240718034516_Initial.Designer.cs
@@ -3,17 +3,17 @@ using System;
using Hutopy.Web.Contents.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Hutopy.Web.Contents.Migrations
{
[DbContext(typeof(ContentDbContext))]
- [Migration("20240707030928_ChangingContentDefaultSchema")]
- partial class ChangingContentDefaultSchema
+ [Migration("20240718034516_Initial")]
+ partial class Initial
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -21,33 +21,33 @@ namespace Hutopy.Web.Contents.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Content")
- .HasAnnotation("ProductVersion", "8.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
+ .HasAnnotation("ProductVersion", "8.0.4")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Hutopy.Web.Contents.Data.Content", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
- b.Property("CreatedAt")
+ b.Property("CreatedAt")
.ValueGeneratedOnAdd()
- .HasColumnType("datetime2")
+ .HasColumnType("timestamp with time zone")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
b.Property("CreatedBy")
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
b.Property("Description")
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Title")
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Uri")
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.HasKey("Id");
diff --git a/src/Web/Contents/Migrations/20240702034957_Initial.cs b/src/Web/Contents/Migrations/20240718034516_Initial.cs
similarity index 51%
rename from src/Web/Contents/Migrations/20240702034957_Initial.cs
rename to src/Web/Contents/Migrations/20240718034516_Initial.cs
index 593cc49..d2ed5d8 100644
--- a/src/Web/Contents/Migrations/20240702034957_Initial.cs
+++ b/src/Web/Contents/Migrations/20240718034516_Initial.cs
@@ -11,16 +11,20 @@ namespace Hutopy.Web.Contents.Migrations
///
protected override void Up(MigrationBuilder migrationBuilder)
{
+ migrationBuilder.EnsureSchema(
+ name: "Content");
+
migrationBuilder.CreateTable(
name: "Contents",
+ schema: "Content",
columns: table => new
{
- Id = table.Column(type: "uniqueidentifier", nullable: false),
- CreatedBy = table.Column(type: "uniqueidentifier", nullable: false),
- CreatedAt = table.Column(type: "datetime2", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
- Title = table.Column(type: "nvarchar(max)", nullable: true),
- Description = table.Column(type: "nvarchar(max)", nullable: true),
- Uri = table.Column(type: "nvarchar(max)", nullable: true)
+ Id = table.Column(type: "uuid", nullable: false),
+ CreatedBy = table.Column(type: "uuid", nullable: false),
+ CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
+ Title = table.Column(type: "text", nullable: true),
+ Description = table.Column(type: "text", nullable: true),
+ Uri = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
@@ -32,7 +36,8 @@ namespace Hutopy.Web.Contents.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
- name: "Contents");
+ name: "Contents",
+ schema: "Content");
}
}
}
diff --git a/src/Web/Contents/Migrations/ContentDbContextModelSnapshot.cs b/src/Web/Contents/Migrations/ContentDbContextModelSnapshot.cs
index 4f2d601..5a7fbbf 100644
--- a/src/Web/Contents/Migrations/ContentDbContextModelSnapshot.cs
+++ b/src/Web/Contents/Migrations/ContentDbContextModelSnapshot.cs
@@ -3,8 +3,8 @@ using System;
using Hutopy.Web.Contents.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
@@ -18,33 +18,33 @@ namespace Hutopy.Web.Contents.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Content")
- .HasAnnotation("ProductVersion", "8.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
+ .HasAnnotation("ProductVersion", "8.0.4")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Hutopy.Web.Contents.Data.Content", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
- b.Property("CreatedAt")
+ b.Property("CreatedAt")
.ValueGeneratedOnAdd()
- .HasColumnType("datetime2")
+ .HasColumnType("timestamp with time zone")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
b.Property("CreatedBy")
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
b.Property("Description")
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Title")
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Uri")
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.HasKey("Id");
diff --git a/src/Web/Messages/Data/Message.cs b/src/Web/Messages/Data/Message.cs
index 3baf749..09d3b6b 100644
--- a/src/Web/Messages/Data/Message.cs
+++ b/src/Web/Messages/Data/Message.cs
@@ -5,7 +5,7 @@ public class Message
public Guid Id { get; init; }
public Guid SubjectId { get; init; }
public Guid CreatedBy { get; init; }
- public DateTime CreatedAt { get; }
+ public DateTimeOffset CreatedAt { get; }
public Guid ParentId { get; init; }
- public string Value { get; init; } = null!;
+ public string Value { get; init; }
}
diff --git a/src/Web/Messages/Data/MessagingDbContext.cs b/src/Web/Messages/Data/MessagingDbContext.cs
index e343a2b..7674b30 100644
--- a/src/Web/Messages/Data/MessagingDbContext.cs
+++ b/src/Web/Messages/Data/MessagingDbContext.cs
@@ -17,5 +17,5 @@ public class MessagingDbContext(
.HasDefaultValueSql("CURRENT_TIMESTAMP");
}
- public DbSet Messages { get; set; }
+ public DbSet Messages { get; set; }
}
diff --git a/src/Web/Messages/Handlers/PostMessage.cs b/src/Web/Messages/Handlers/PostMessage.cs
index d5d9202..65d7882 100644
--- a/src/Web/Messages/Handlers/PostMessage.cs
+++ b/src/Web/Messages/Handlers/PostMessage.cs
@@ -23,10 +23,13 @@ public class PostMessage(
CancellationToken ct)
{
await context.Messages.AddAsync(
- new Message {
- SubjectId = req.SubjectId,
- CreatedBy = User.GetUserId(),
- Value = req.Message },
+ new Message
+ {
+ Id = GuidHelper.GenerateUuidV7(),
+ SubjectId = req.SubjectId,
+ CreatedBy = User.GetUserId(),
+ Value = req.Message
+ },
ct);
await context.SaveChangesAsync(ct);
diff --git a/src/Web/Messages/Handlers/PostReplyMessage.cs b/src/Web/Messages/Handlers/PostReplyMessage.cs
index 975da57..6e7b995 100644
--- a/src/Web/Messages/Handlers/PostReplyMessage.cs
+++ b/src/Web/Messages/Handlers/PostReplyMessage.cs
@@ -26,6 +26,7 @@ public sealed class PostReplyMessage(
await context.Messages.AddAsync(
new Message
{
+ Id = GuidHelper.GenerateUuidV7(),
SubjectId = req.SubjectId,
ParentId = req.ParentId,
CreatedBy = User.GetUserId(),
diff --git a/src/Web/Messages/Migrations/20240627081653_Initial.Designer.cs b/src/Web/Messages/Migrations/20240627081653_Initial.Designer.cs
deleted file mode 100644
index 72d8e1c..0000000
--- a/src/Web/Messages/Migrations/20240627081653_Initial.Designer.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-using System;
-using Hutopy.Web.Messages.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace Hutopy.Web.Messages.Migrations
-{
- [DbContext(typeof(MessagingDbContext))]
- [Migration("20240627081653_Initial")]
- partial class Initial
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("Hutopy.Web.Messages.Data.Message", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uniqueidentifier");
-
- b.Property("ContentId")
- .HasColumnType("uniqueidentifier");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("datetime2")
- .HasDefaultValueSql("CURRENT_TIMESTAMP");
-
- b.Property("CreatedBy")
- .HasColumnType("uniqueidentifier");
-
- b.Property("ParentId")
- .HasColumnType("uniqueidentifier");
-
- b.Property("Value")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Messages");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/Web/Messages/Migrations/20240707023204_UseSubjectId_InsteadOfContentId.Designer.cs b/src/Web/Messages/Migrations/20240707023204_UseSubjectId_InsteadOfContentId.Designer.cs
deleted file mode 100644
index 86ed4f1..0000000
--- a/src/Web/Messages/Migrations/20240707023204_UseSubjectId_InsteadOfContentId.Designer.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-using System;
-using Hutopy.Web.Contents.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace Hutopy.Web.Messages.Migrations
-{
- [DbContext(typeof(ContentDbContext))]
- [Migration("20240707023204_UseSubjectId_InsteadOfContentId")]
- partial class UseSubjectId_InsteadOfContentId
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("Hutopy.Web.Contents.Data.Content", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uniqueidentifier");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("datetime2")
- .HasDefaultValueSql("CURRENT_TIMESTAMP");
-
- b.Property("CreatedBy")
- .HasColumnType("uniqueidentifier");
-
- b.Property("Description")
- .HasColumnType("nvarchar(max)");
-
- b.Property("Title")
- .HasColumnType("nvarchar(max)");
-
- b.Property("Uri")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Contents");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/Web/Messages/Migrations/20240707023204_UseSubjectId_InsteadOfContentId.cs b/src/Web/Messages/Migrations/20240707023204_UseSubjectId_InsteadOfContentId.cs
deleted file mode 100644
index 760efd1..0000000
--- a/src/Web/Messages/Migrations/20240707023204_UseSubjectId_InsteadOfContentId.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace Hutopy.Web.Messages.Migrations
-{
- ///
- public partial class UseSubjectId_InsteadOfContentId : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
-
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
-
- }
- }
-}
diff --git a/src/Web/Messages/Migrations/20240707030834_ChangingMessagingDefaultSchema.cs b/src/Web/Messages/Migrations/20240707030834_ChangingMessagingDefaultSchema.cs
deleted file mode 100644
index c788df7..0000000
--- a/src/Web/Messages/Migrations/20240707030834_ChangingMessagingDefaultSchema.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace Hutopy.Web.Messages.Migrations
-{
- ///
- public partial class ChangingMessagingDefaultSchema : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.EnsureSchema(
- name: "Messaging");
-
- migrationBuilder.RenameTable(
- name: "Messages",
- newName: "Messages",
- newSchema: "Messaging");
-
- migrationBuilder.RenameColumn(
- name: "ContentId",
- schema: "Messaging",
- table: "Messages",
- newName: "SubjectId");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.RenameTable(
- name: "Messages",
- schema: "Messaging",
- newName: "Messages");
-
- migrationBuilder.RenameColumn(
- name: "SubjectId",
- table: "Messages",
- newName: "ContentId");
- }
- }
-}
diff --git a/src/Web/Messages/Migrations/20240707030834_ChangingMessagingDefaultSchema.Designer.cs b/src/Web/Messages/Migrations/20240718041130_Initial.Designer.cs
similarity index 65%
rename from src/Web/Messages/Migrations/20240707030834_ChangingMessagingDefaultSchema.Designer.cs
rename to src/Web/Messages/Migrations/20240718041130_Initial.Designer.cs
index dacf0b2..c375b1b 100644
--- a/src/Web/Messages/Migrations/20240707030834_ChangingMessagingDefaultSchema.Designer.cs
+++ b/src/Web/Messages/Migrations/20240718041130_Initial.Designer.cs
@@ -3,17 +3,17 @@ using System;
using Hutopy.Web.Messages.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Hutopy.Web.Messages.Migrations
{
[DbContext(typeof(MessagingDbContext))]
- [Migration("20240707030834_ChangingMessagingDefaultSchema")]
- partial class ChangingMessagingDefaultSchema
+ [Migration("20240718041130_Initial")]
+ partial class Initial
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -21,34 +21,34 @@ namespace Hutopy.Web.Messages.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Messaging")
- .HasAnnotation("ProductVersion", "8.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
+ .HasAnnotation("ProductVersion", "8.0.4")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Hutopy.Web.Messages.Data.Message", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
- b.Property("CreatedAt")
+ b.Property("CreatedAt")
.ValueGeneratedOnAdd()
- .HasColumnType("datetime2")
+ .HasColumnType("timestamp with time zone")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
b.Property("CreatedBy")
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
b.Property("ParentId")
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
b.Property("SubjectId")
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
b.Property("Value")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.HasKey("Id");
diff --git a/src/Web/Messages/Migrations/20240627081653_Initial.cs b/src/Web/Messages/Migrations/20240718041130_Initial.cs
similarity index 51%
rename from src/Web/Messages/Migrations/20240627081653_Initial.cs
rename to src/Web/Messages/Migrations/20240718041130_Initial.cs
index bd5664e..fbb3817 100644
--- a/src/Web/Messages/Migrations/20240627081653_Initial.cs
+++ b/src/Web/Messages/Migrations/20240718041130_Initial.cs
@@ -11,16 +11,20 @@ namespace Hutopy.Web.Messages.Migrations
///
protected override void Up(MigrationBuilder migrationBuilder)
{
+ migrationBuilder.EnsureSchema(
+ name: "Messaging");
+
migrationBuilder.CreateTable(
name: "Messages",
+ schema: "Messaging",
columns: table => new
{
- Id = table.Column(type: "uniqueidentifier", nullable: false),
- ContentId = table.Column(type: "uniqueidentifier", nullable: false),
- CreatedBy = table.Column(type: "uniqueidentifier", nullable: false),
- CreatedAt = table.Column(type: "datetime2", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
- ParentId = table.Column(type: "uniqueidentifier", nullable: false),
- Value = table.Column(type: "nvarchar(max)", nullable: false)
+ Id = table.Column(type: "uuid", nullable: false),
+ SubjectId = table.Column(type: "uuid", nullable: false),
+ CreatedBy = table.Column(type: "uuid", nullable: false),
+ CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
+ ParentId = table.Column(type: "uuid", nullable: false),
+ Value = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
@@ -32,7 +36,8 @@ namespace Hutopy.Web.Messages.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
- name: "Messages");
+ name: "Messages",
+ schema: "Messaging");
}
}
}
diff --git a/src/Web/Messages/Migrations/MessagingDbContextModelSnapshot.cs b/src/Web/Messages/Migrations/MessagingDbContextModelSnapshot.cs
index dcaa429..64c03fb 100644
--- a/src/Web/Messages/Migrations/MessagingDbContextModelSnapshot.cs
+++ b/src/Web/Messages/Migrations/MessagingDbContextModelSnapshot.cs
@@ -3,8 +3,8 @@ using System;
using Hutopy.Web.Messages.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
@@ -18,34 +18,34 @@ namespace Hutopy.Web.Messages.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Messaging")
- .HasAnnotation("ProductVersion", "8.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
+ .HasAnnotation("ProductVersion", "8.0.4")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Hutopy.Web.Messages.Data.Message", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
- b.Property("CreatedAt")
+ b.Property("CreatedAt")
.ValueGeneratedOnAdd()
- .HasColumnType("datetime2")
+ .HasColumnType("timestamp with time zone")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
b.Property("CreatedBy")
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
b.Property("ParentId")
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
b.Property("SubjectId")
- .HasColumnType("uniqueidentifier");
+ .HasColumnType("uuid");
b.Property("Value")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.HasKey("Id");
diff --git a/src/Web/Program.cs b/src/Web/Program.cs
index fec1d10..3698029 100644
--- a/src/Web/Program.cs
+++ b/src/Web/Program.cs
@@ -79,12 +79,12 @@ builder.Services.AddOpenApiDocument((configure, sp) =>
configure.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT"));
});
-var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
- ?? throw new InvalidOperationException("Missing ConnectionStrings:DefaultConnection");
+var postgresConnectionString = builder.Configuration.GetConnectionString("PostgresConnection")
+ ?? throw new InvalidOperationException("Missing ConnectionStrings:PostgresConnection");
builder.Services.AddFastEndpoints();
-builder.Services.AddContentModule(options => options.UseSqlServer(connectionString));
-builder.Services.AddMessagingModule(options => options.UseSqlServer(connectionString));
+builder.Services.AddContentModule(options => options.UseNpgsql(postgresConnectionString));
+builder.Services.AddMessagingModule(options => options.UseNpgsql(postgresConnectionString));
builder.Services.Configure(builder.Configuration.GetRequiredSection(JwtOptions.SectionName));
diff --git a/src/Web/Web.csproj b/src/Web/Web.csproj
index 817e221..761a54d 100644
--- a/src/Web/Web.csproj
+++ b/src/Web/Web.csproj
@@ -22,6 +22,7 @@
+
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -30,4 +31,9 @@
+
+
+
+
+
diff --git a/src/Web/appsettings.Development.json b/src/Web/appsettings.Development.json
index d249e8e..f7ec248 100644
--- a/src/Web/appsettings.Development.json
+++ b/src/Web/appsettings.Development.json
@@ -8,7 +8,8 @@
}
},
"ConnectionStrings": {
- "DefaultConnection": "Server=localhost,1433;Initial Catalog=Hutopy;User Id=sa;Password=P@ssword123!;MultipleActiveResultSets=true;TrustServerCertificate=True;MultiSubnetFailover=True"
+ "MssqlConnection": "Server=localhost,1433;Initial Catalog=Hutopy;User Id=sa;Password=P@ssword123!;MultipleActiveResultSets=true;TrustServerCertificate=True;MultiSubnetFailover=True",
+ "PostgresConnection": "Server=localhost,5432;Database=Hutopy;Uid=sa;Pwd=P@ssword123!;"
},
"Authentication": {
"Jwt": {
diff --git a/tests/Application.FunctionalTests/SqlServerTestDatabase.cs b/tests/Application.FunctionalTests/SqlServerTestDatabase.cs
index 57e7acc..bd88b6d 100644
--- a/tests/Application.FunctionalTests/SqlServerTestDatabase.cs
+++ b/tests/Application.FunctionalTests/SqlServerTestDatabase.cs
@@ -20,7 +20,7 @@ public class SqlServerTestDatabase : ITestDatabase
.AddEnvironmentVariables()
.Build();
- var connectionString = configuration.GetConnectionString("DefaultConnection");
+ var connectionString = configuration.GetConnectionString("MssqlConnection");
Guard.Against.Null(connectionString);
diff --git a/tests/Application.FunctionalTests/appsettings.json b/tests/Application.FunctionalTests/appsettings.json
index ea0855a..31e3e45 100644
--- a/tests/Application.FunctionalTests/appsettings.json
+++ b/tests/Application.FunctionalTests/appsettings.json
@@ -1,5 +1,5 @@
{
"ConnectionStrings": {
- "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=HutopyTestDb;Trusted_Connection=True;MultipleActiveResultSets=true"
+ "MssqlConnection": "Server=(localdb)\\mssqllocaldb;Database=HutopyTestDb;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}