using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace IoTGateway.DataAccess.Migrations { public partial class Init : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "ActionLogs", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ModuleName = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ActionName = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ITCode = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ActionUrl = table.Column(type: "varchar(250)", maxLength: 250, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ActionTime = table.Column(type: "datetime(6)", nullable: false), Duration = table.Column(type: "double", nullable: false), Remark = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), IP = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), LogType = table.Column(type: "int", nullable: false), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_ActionLogs", x => x.ID); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "DataPrivileges", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), GroupCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), TableName = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), RelateId = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Domain = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_DataPrivileges", x => x.ID); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "FileAttachments", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), FileName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), FileExt = table.Column(type: "varchar(10)", maxLength: 10, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Path = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Length = table.Column(type: "bigint", nullable: false), UploadTime = table.Column(type: "datetime(6)", nullable: false), SaveMode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), FileData = table.Column(type: "longblob", nullable: true), ExtraInfo = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), HandlerInfo = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_FileAttachments", x => x.ID); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "FrameworkGroups", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), GroupCode = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), GroupName = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), GroupRemark = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), TenantCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_FrameworkGroups", x => x.ID); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "FrameworkMenus", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), PageName = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ActionName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ModuleName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), FolderOnly = table.Column(type: "tinyint(1)", nullable: false), IsInherit = table.Column(type: "tinyint(1)", nullable: false), ClassName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), MethodName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Domain = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ShowOnMenu = table.Column(type: "tinyint(1)", nullable: false), IsPublic = table.Column(type: "tinyint(1)", nullable: false), DisplayOrder = table.Column(type: "int", nullable: false), IsInside = table.Column(type: "tinyint(1)", nullable: false), Url = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Icon = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ParentId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_FrameworkMenus", x => x.ID); table.ForeignKey( name: "FK_FrameworkMenus_FrameworkMenus_ParentId", column: x => x.ParentId, principalTable: "FrameworkMenus", principalColumn: "ID"); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "FrameworkRoles", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), RoleCode = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), RoleName = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), RoleRemark = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), TenantCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_FrameworkRoles", x => x.ID); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "FrameworkUserGroups", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserCode = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), GroupCode = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_FrameworkUserGroups", x => x.ID); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "FrameworkUserRoles", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserCode = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), RoleCode = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_FrameworkUserRoles", x => x.ID); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "PersistedGrants", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Type = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UserCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationTime = table.Column(type: "datetime(6)", nullable: false), Expiration = table.Column(type: "datetime(6)", nullable: false), RefreshToken = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_PersistedGrants", x => x.ID); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "FrameworkUsers", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Email = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Gender = table.Column(type: "int", nullable: true), CellPhone = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), HomePhone = table.Column(type: "varchar(30)", maxLength: 30, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Address = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ZipCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ITCode = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Password = table.Column(type: "varchar(32)", maxLength: 32, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), IsValid = table.Column(type: "tinyint(1)", nullable: false), PhotoId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), TenantCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_FrameworkUsers", x => x.ID); table.ForeignKey( name: "FK_FrameworkUsers_FileAttachments_PhotoId", column: x => x.PhotoId, principalTable: "FileAttachments", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "FunctionPrivileges", columns: table => new { ID = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), RoleCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), MenuItemId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Allowed = table.Column(type: "tinyint(1)", nullable: false), CreateTime = table.Column(type: "datetime(6)", nullable: true), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true), UpdateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_FunctionPrivileges", x => x.ID); table.ForeignKey( name: "FK_FunctionPrivileges_FrameworkMenus_MenuItemId", column: x => x.MenuItemId, principalTable: "FrameworkMenus", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_FrameworkMenus_ParentId", table: "FrameworkMenus", column: "ParentId"); migrationBuilder.CreateIndex( name: "IX_FrameworkUsers_PhotoId", table: "FrameworkUsers", column: "PhotoId"); migrationBuilder.CreateIndex( name: "IX_FunctionPrivileges_MenuItemId", table: "FunctionPrivileges", column: "MenuItemId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ActionLogs"); migrationBuilder.DropTable( name: "DataPrivileges"); migrationBuilder.DropTable( name: "FrameworkGroups"); migrationBuilder.DropTable( name: "FrameworkRoles"); migrationBuilder.DropTable( name: "FrameworkUserGroups"); migrationBuilder.DropTable( name: "FrameworkUserRoles"); migrationBuilder.DropTable( name: "FrameworkUsers"); migrationBuilder.DropTable( name: "FunctionPrivileges"); migrationBuilder.DropTable( name: "PersistedGrants"); migrationBuilder.DropTable( name: "FileAttachments"); migrationBuilder.DropTable( name: "FrameworkMenus"); } } }