using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace MessageService.Infrastructure.Migrations { /// public partial class InitMessageDb : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "conversations", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TargetId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TargetAvatar = table.Column(type: "longtext", nullable: false) .Annotation("MySql:Charset", "utf8mb4"), TargetName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:Charset", "utf8mb4"), LastReadSequenceId = table.Column(type: "bigint", nullable: true), UnreadCount = table.Column(type: "int", nullable: false), ChatType = table.Column(type: "int", nullable: false), StreamKey = table.Column(type: "longtext", nullable: false) .Annotation("MySql:Charset", "utf8mb4"), LastMessage = table.Column(type: "longtext", nullable: false) .Annotation("MySql:Charset", "utf8mb4"), IsDeleted = table.Column(type: "tinyint(1)", nullable: false), CreationTime = table.Column(type: "datetime(6)", nullable: false), Deletion = table.Column(type: "datetime(6)", nullable: true), ModificationTime = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ChatType = table.Column(type: "int", nullable: false), MsgType = table.Column(type: "int", nullable: false), ClientMsgId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), SenderId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TargetId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), State = table.Column(type: "int", nullable: false), StreamKey = table.Column(type: "varchar(255)", nullable: false) .Annotation("MySql:Charset", "utf8mb4"), SequenceId = table.Column(type: "bigint", nullable: false), Content_Fallback = table.Column(type: "varchar(255)", maxLength: 255, nullable: false), Content_Body = table.Column(type: "longtext", nullable: false), Content_Ext = table.Column(type: "longtext", nullable: false), Quote_MsgId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Quote_MsgType = table.Column(type: "int", nullable: false), Quote_Preview = table.Column(type: "varchar(100)", maxLength: 100, nullable: false), Quote_SenderId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Quote_SenderName = table.Column(type: "varchar(50)", maxLength: 50, nullable: false), IsDeleted = table.Column(type: "tinyint(1)", nullable: false), CreationTime = table.Column(type: "datetime(6)", nullable: false), Deletion = table.Column(type: "datetime(6)", nullable: true), ModificationTime = table.Column(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" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "conversations"); migrationBuilder.DropTable( name: "messages"); } } }