添加项目文件。
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MessageService.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitMessageDb : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("MySql:Charset", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "conversations",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
TargetId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
TargetAvatar = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:Charset", "utf8mb4"),
|
||||
TargetName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:Charset", "utf8mb4"),
|
||||
LastReadSequenceId = table.Column<long>(type: "bigint", nullable: true),
|
||||
UnreadCount = table.Column<int>(type: "int", nullable: false),
|
||||
ChatType = table.Column<int>(type: "int", nullable: false),
|
||||
StreamKey = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:Charset", "utf8mb4"),
|
||||
LastMessage = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:Charset", "utf8mb4"),
|
||||
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
CreationTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
|
||||
Deletion = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
|
||||
ModificationTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_conversations", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:Charset", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "messages",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ChatType = table.Column<int>(type: "int", nullable: false),
|
||||
MsgType = table.Column<int>(type: "int", nullable: false),
|
||||
ClientMsgId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
SenderId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
TargetId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
State = table.Column<int>(type: "int", nullable: false),
|
||||
StreamKey = table.Column<string>(type: "varchar(255)", nullable: false)
|
||||
.Annotation("MySql:Charset", "utf8mb4"),
|
||||
SequenceId = table.Column<long>(type: "bigint", nullable: false),
|
||||
Content_Fallback = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false),
|
||||
Content_Body = table.Column<string>(type: "longtext", nullable: false),
|
||||
Content_Ext = table.Column<string>(type: "longtext", nullable: false),
|
||||
Quote_MsgId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Quote_MsgType = table.Column<int>(type: "int", nullable: false),
|
||||
Quote_Preview = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
Quote_SenderId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Quote_SenderName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false),
|
||||
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
CreationTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
|
||||
Deletion = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
|
||||
ModificationTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_messages", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:Charset", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_conversations_UserId",
|
||||
table: "conversations",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_messages_StreamKey_SequenceId",
|
||||
table: "messages",
|
||||
columns: new[] { "StreamKey", "SequenceId" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "conversations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "messages");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user