fix: align backend APIs and upload flow
This commit is contained in:
+48
@@ -0,0 +1,48 @@
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace MessageService.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(MessageDbContext))]
|
||||
[Migration("20260913000100_ConversationActivityAndMessageSearch")]
|
||||
public partial class ConversationActivityAndMessageSearch : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTimeOffset>(
|
||||
name: "LastMessageTime",
|
||||
table: "conversations",
|
||||
type: "datetime(6)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.Sql("""
|
||||
UPDATE `conversations` AS `conversation`
|
||||
SET `conversation`.`LastMessageTime` = COALESCE(
|
||||
(
|
||||
SELECT MAX(`message`.`CreationTime`)
|
||||
FROM `messages` AS `message`
|
||||
WHERE `message`.`StreamKey` = `conversation`.`StreamKey`
|
||||
AND `message`.`IsDeleted` = 0
|
||||
),
|
||||
`conversation`.`CreationTime`
|
||||
);
|
||||
""");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_messages_StreamKey_MsgType_State_SequenceId",
|
||||
table: "messages",
|
||||
columns: new[] { "StreamKey", "MsgType", "State", "SequenceId" });
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_messages_StreamKey_MsgType_State_SequenceId",
|
||||
table: "messages");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastMessageTime",
|
||||
table: "conversations");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user