using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace LY.MicroService.RealtimeMessage.Migrations { public partial class ReInitlizeDbMigration : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppChatGroups", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), AdminUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), GroupId = table.Column(type: "bigint", nullable: false), Name = table.Column(type: "varchar(20)", maxLength: 20, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Tag = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Address = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Notice = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), MaxUserCount = table.Column(type: "int", nullable: false), AllowAnonymous = table.Column(type: "tinyint(1)", nullable: false), AllowSendMessage = table.Column(type: "tinyint(1)", nullable: false), Description = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationTime = table.Column(type: "datetime(6)", nullable: false), CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), LastModificationTime = table.Column(type: "datetime(6)", nullable: true), LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_AppChatGroups", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppGroupChatBlacks", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), GroupId = table.Column(type: "bigint", nullable: false), ShieldUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), CreationTime = table.Column(type: "datetime(6)", nullable: false), CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_AppGroupChatBlacks", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppGroupMessages", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), GroupId = table.Column(type: "bigint", nullable: false), ExtraProperties = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationTime = table.Column(type: "datetime(6)", nullable: false), CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), MessageId = table.Column(type: "bigint", nullable: false), SendUserName = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Content = table.Column(type: "longtext", maxLength: 1048576, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Type = table.Column(type: "int", nullable: false), SendState = table.Column(type: "tinyint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AppGroupMessages", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppNotifications", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), Severity = table.Column(type: "tinyint", nullable: false), Type = table.Column(type: "int", nullable: false), NotificationId = table.Column(type: "bigint", nullable: false), NotificationName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), NotificationData = table.Column(type: "longtext", maxLength: 1048576, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), NotificationTypeName = table.Column(type: "varchar(512)", maxLength: 512, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ExpirationTime = table.Column(type: "datetime(6)", nullable: true), CreationTime = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AppNotifications", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppUserChatCards", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Sex = table.Column(type: "int", nullable: false), Sign = table.Column(type: "varchar(30)", maxLength: 30, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), NickName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), AvatarUrl = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Birthday = table.Column(type: "datetime(6)", nullable: true), Age = table.Column(type: "int", nullable: false), ExtraProperties = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationTime = table.Column(type: "datetime(6)", nullable: false), CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), LastModificationTime = table.Column(type: "datetime(6)", nullable: true), LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_AppUserChatCards", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppUserChatFriends", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), FrientId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Black = table.Column(type: "tinyint(1)", nullable: false), DontDisturb = table.Column(type: "tinyint(1)", nullable: false), SpecialFocus = table.Column(type: "tinyint(1)", nullable: false), RemarkName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Status = table.Column(type: "tinyint unsigned", nullable: false), ExtraProperties = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationTime = table.Column(type: "datetime(6)", nullable: false), CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_AppUserChatFriends", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppUserChatGroups", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), GroupId = table.Column(type: "bigint", nullable: false), CreationTime = table.Column(type: "datetime(6)", nullable: false), CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_AppUserChatGroups", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppUserChatSettings", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), AllowAnonymous = table.Column(type: "tinyint(1)", nullable: false), AllowAddFriend = table.Column(type: "tinyint(1)", nullable: false), RequireAddFriendValition = table.Column(type: "tinyint(1)", nullable: false), AllowReceiveMessage = table.Column(type: "tinyint(1)", nullable: false), AllowSendMessage = table.Column(type: "tinyint(1)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AppUserChatSettings", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppUserGroupCards", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), NickName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), IsAdmin = table.Column(type: "tinyint(1)", nullable: false), SilenceEnd = table.Column(type: "datetime(6)", nullable: true), ExtraProperties = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationTime = table.Column(type: "datetime(6)", nullable: false), CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), LastModificationTime = table.Column(type: "datetime(6)", nullable: true), LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_AppUserGroupCards", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppUserMessages", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ReceiveUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ExtraProperties = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationTime = table.Column(type: "datetime(6)", nullable: false), CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), MessageId = table.Column(type: "bigint", nullable: false), SendUserName = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Content = table.Column(type: "longtext", maxLength: 1048576, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Type = table.Column(type: "int", nullable: false), SendState = table.Column(type: "tinyint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AppUserMessages", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppUserNotifications", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), NotificationId = table.Column(type: "bigint", nullable: false), ReadStatus = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AppUserNotifications", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AppUserSubscribes", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false, defaultValue: "/") .Annotation("MySql:CharSet", "utf8mb4"), TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), CreationTime = table.Column(type: "datetime(6)", nullable: false), NotificationName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AppUserSubscribes", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_AppChatGroups_TenantId_Name", table: "AppChatGroups", columns: new[] { "TenantId", "Name" }); migrationBuilder.CreateIndex( name: "IX_AppGroupChatBlacks_TenantId_GroupId", table: "AppGroupChatBlacks", columns: new[] { "TenantId", "GroupId" }); migrationBuilder.CreateIndex( name: "IX_AppGroupMessages_TenantId_GroupId", table: "AppGroupMessages", columns: new[] { "TenantId", "GroupId" }); migrationBuilder.CreateIndex( name: "IX_AppNotifications_TenantId_NotificationName", table: "AppNotifications", columns: new[] { "TenantId", "NotificationName" }); migrationBuilder.CreateIndex( name: "IX_AppUserChatCards_TenantId_UserId", table: "AppUserChatCards", columns: new[] { "TenantId", "UserId" }); migrationBuilder.CreateIndex( name: "IX_AppUserChatFriends_TenantId_UserId_FrientId", table: "AppUserChatFriends", columns: new[] { "TenantId", "UserId", "FrientId" }); migrationBuilder.CreateIndex( name: "IX_AppUserChatGroups_TenantId_GroupId_UserId", table: "AppUserChatGroups", columns: new[] { "TenantId", "GroupId", "UserId" }); migrationBuilder.CreateIndex( name: "IX_AppUserChatSettings_TenantId_UserId", table: "AppUserChatSettings", columns: new[] { "TenantId", "UserId" }); migrationBuilder.CreateIndex( name: "IX_AppUserGroupCards_TenantId_UserId", table: "AppUserGroupCards", columns: new[] { "TenantId", "UserId" }); migrationBuilder.CreateIndex( name: "IX_AppUserMessages_TenantId_ReceiveUserId", table: "AppUserMessages", columns: new[] { "TenantId", "ReceiveUserId" }); migrationBuilder.CreateIndex( name: "IX_Tenant_User_Notification_Id", table: "AppUserNotifications", columns: new[] { "TenantId", "UserId", "NotificationId" }); migrationBuilder.CreateIndex( name: "IX_Tenant_User_Notification_Name", table: "AppUserSubscribes", columns: new[] { "TenantId", "UserId", "NotificationName" }, unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AppChatGroups"); migrationBuilder.DropTable( name: "AppGroupChatBlacks"); migrationBuilder.DropTable( name: "AppGroupMessages"); migrationBuilder.DropTable( name: "AppNotifications"); migrationBuilder.DropTable( name: "AppUserChatCards"); migrationBuilder.DropTable( name: "AppUserChatFriends"); migrationBuilder.DropTable( name: "AppUserChatGroups"); migrationBuilder.DropTable( name: "AppUserChatSettings"); migrationBuilder.DropTable( name: "AppUserGroupCards"); migrationBuilder.DropTable( name: "AppUserMessages"); migrationBuilder.DropTable( name: "AppUserNotifications"); migrationBuilder.DropTable( name: "AppUserSubscribes"); } } }