using System; using Microsoft.EntityFrameworkCore.Migrations; namespace IoTGateway.DataAccess.Migrations { public partial class ini : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "ActionLogs", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), ModuleName = table.Column(type: "TEXT", maxLength: 255, nullable: true), ActionName = table.Column(type: "TEXT", maxLength: 255, nullable: true), ITCode = table.Column(type: "TEXT", maxLength: 50, nullable: true), ActionUrl = table.Column(type: "TEXT", maxLength: 250, nullable: true), ActionTime = table.Column(type: "TEXT", nullable: false), Duration = table.Column(type: "REAL", nullable: false), Remark = table.Column(type: "TEXT", nullable: true), IP = table.Column(type: "TEXT", maxLength: 50, nullable: true), LogType = table.Column(type: "INTEGER", nullable: false), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_ActionLogs", x => x.ID); }); migrationBuilder.CreateTable( name: "DataPrivileges", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), UserCode = table.Column(type: "TEXT", nullable: true), GroupCode = table.Column(type: "TEXT", nullable: true), TableName = table.Column(type: "TEXT", maxLength: 50, nullable: false), RelateId = table.Column(type: "TEXT", nullable: true), Domain = table.Column(type: "TEXT", nullable: true), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_DataPrivileges", x => x.ID); }); migrationBuilder.CreateTable( name: "Drivers", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), DriverName = table.Column(type: "TEXT", nullable: true), FileName = table.Column(type: "TEXT", nullable: true), AssembleName = table.Column(type: "TEXT", nullable: true), AuthorizesNum = table.Column(type: "INTEGER", nullable: false), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Drivers", x => x.ID); }); migrationBuilder.CreateTable( name: "FileAttachments", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), FileName = table.Column(type: "TEXT", nullable: false), FileExt = table.Column(type: "TEXT", maxLength: 10, nullable: false), Path = table.Column(type: "TEXT", nullable: true), Length = table.Column(type: "INTEGER", nullable: false), UploadTime = table.Column(type: "TEXT", nullable: false), SaveMode = table.Column(type: "TEXT", nullable: true), FileData = table.Column(type: "BLOB", nullable: true), ExtraInfo = table.Column(type: "TEXT", nullable: true), HandlerInfo = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_FileAttachments", x => x.ID); }); migrationBuilder.CreateTable( name: "FrameworkGroups", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), GroupCode = table.Column(type: "TEXT", maxLength: 100, nullable: false), GroupName = table.Column(type: "TEXT", maxLength: 50, nullable: false), GroupRemark = table.Column(type: "TEXT", nullable: true), TenantCode = table.Column(type: "TEXT", nullable: true), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_FrameworkGroups", x => x.ID); }); migrationBuilder.CreateTable( name: "FrameworkMenus", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), PageName = table.Column(type: "TEXT", maxLength: 50, nullable: false), ActionName = table.Column(type: "TEXT", nullable: true), ModuleName = table.Column(type: "TEXT", nullable: true), FolderOnly = table.Column(type: "INTEGER", nullable: false), IsInherit = table.Column(type: "INTEGER", nullable: false), ClassName = table.Column(type: "TEXT", nullable: true), MethodName = table.Column(type: "TEXT", nullable: true), Domain = table.Column(type: "TEXT", nullable: true), ShowOnMenu = table.Column(type: "INTEGER", nullable: false), IsPublic = table.Column(type: "INTEGER", nullable: false), DisplayOrder = table.Column(type: "INTEGER", nullable: false), IsInside = table.Column(type: "INTEGER", nullable: false), Url = table.Column(type: "TEXT", nullable: true), Icon = table.Column(type: "TEXT", maxLength: 50, nullable: true), ParentId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_FrameworkMenus", x => x.ID); table.ForeignKey( name: "FK_FrameworkMenus_FrameworkMenus_ParentId", column: x => x.ParentId, principalTable: "FrameworkMenus", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "FrameworkRoles", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), RoleCode = table.Column(type: "TEXT", maxLength: 100, nullable: false), RoleName = table.Column(type: "TEXT", maxLength: 50, nullable: false), RoleRemark = table.Column(type: "TEXT", nullable: true), TenantCode = table.Column(type: "TEXT", nullable: true), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_FrameworkRoles", x => x.ID); }); migrationBuilder.CreateTable( name: "FrameworkUserGroups", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), UserCode = table.Column(type: "TEXT", nullable: false), GroupCode = table.Column(type: "TEXT", nullable: false), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_FrameworkUserGroups", x => x.ID); }); migrationBuilder.CreateTable( name: "FrameworkUserRoles", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), UserCode = table.Column(type: "TEXT", nullable: false), RoleCode = table.Column(type: "TEXT", nullable: false), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_FrameworkUserRoles", x => x.ID); }); migrationBuilder.CreateTable( name: "PersistedGrants", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), Type = table.Column(type: "TEXT", maxLength: 50, nullable: true), UserCode = table.Column(type: "TEXT", nullable: true), CreationTime = table.Column(type: "TEXT", nullable: false), Expiration = table.Column(type: "TEXT", nullable: false), RefreshToken = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_PersistedGrants", x => x.ID); }); migrationBuilder.CreateTable( name: "SystemConfig", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), GatewayName = table.Column(type: "TEXT", nullable: true), MqttIp = table.Column(type: "TEXT", nullable: true), MqttPort = table.Column(type: "INTEGER", nullable: false), MqttUName = table.Column(type: "TEXT", nullable: true), MqttUPwd = table.Column(type: "TEXT", nullable: true), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_SystemConfig", x => x.ID); }); migrationBuilder.CreateTable( name: "Devices", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), DeviceName = table.Column(type: "TEXT", nullable: true), Index = table.Column(type: "INTEGER", nullable: false), Description = table.Column(type: "TEXT", nullable: true), DriverId = table.Column(type: "TEXT", nullable: true), AutoStart = table.Column(type: "INTEGER", nullable: false), DeviceTypeEnum = table.Column(type: "INTEGER", nullable: false), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", nullable: true), ParentId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Devices", x => x.ID); table.ForeignKey( name: "FK_Devices_Devices_ParentId", column: x => x.ParentId, principalTable: "Devices", principalColumn: "ID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Devices_Drivers_DriverId", column: x => x.DriverId, principalTable: "Drivers", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "FrameworkUsers", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), Email = table.Column(type: "TEXT", maxLength: 50, nullable: true), Gender = table.Column(type: "INTEGER", nullable: true), CellPhone = table.Column(type: "TEXT", nullable: true), HomePhone = table.Column(type: "TEXT", maxLength: 30, nullable: true), Address = table.Column(type: "TEXT", maxLength: 200, nullable: true), ZipCode = table.Column(type: "TEXT", nullable: true), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), ITCode = table.Column(type: "TEXT", maxLength: 50, nullable: false), Password = table.Column(type: "TEXT", maxLength: 32, nullable: false), Name = table.Column(type: "TEXT", maxLength: 50, nullable: false), IsValid = table.Column(type: "INTEGER", nullable: false), PhotoId = table.Column(type: "TEXT", nullable: true), TenantCode = table.Column(type: "TEXT", nullable: true) }, 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); }); migrationBuilder.CreateTable( name: "FunctionPrivileges", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), RoleCode = table.Column(type: "TEXT", nullable: true), MenuItemId = table.Column(type: "TEXT", nullable: false), Allowed = table.Column(type: "INTEGER", nullable: false), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, 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); }); migrationBuilder.CreateTable( name: "DeviceConfigs", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), DeviceConfigName = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true), Value = table.Column(type: "TEXT", nullable: true), EnumInfo = table.Column(type: "TEXT", nullable: true), DeviceId = table.Column(type: "TEXT", nullable: true), CreateTime = table.Column(type: "TEXT", nullable: true), CreateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "TEXT", nullable: true), UpdateBy = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_DeviceConfigs", x => x.ID); table.ForeignKey( name: "FK_DeviceConfigs_Devices_DeviceId", column: x => x.DeviceId, principalTable: "Devices", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "DeviceVariables", columns: table => new { ID = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true), Method = table.Column(type: "TEXT", nullable: true), DeviceAddress = table.Column(type: "TEXT", nullable: true), DataType = table.Column(type: "INTEGER", nullable: false), ValueFactor = table.Column(type: "REAL", nullable: false), ProtectType = table.Column(type: "INTEGER", nullable: false), DeviceId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_DeviceVariables", x => x.ID); table.ForeignKey( name: "FK_DeviceVariables_Devices_DeviceId", column: x => x.DeviceId, principalTable: "Devices", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_DeviceConfigs_DeviceId", table: "DeviceConfigs", column: "DeviceId"); migrationBuilder.CreateIndex( name: "IX_Devices_DriverId", table: "Devices", column: "DriverId"); migrationBuilder.CreateIndex( name: "IX_Devices_ParentId", table: "Devices", column: "ParentId"); migrationBuilder.CreateIndex( name: "IX_DeviceVariables_DeviceId", table: "DeviceVariables", column: "DeviceId"); 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: "DeviceConfigs"); migrationBuilder.DropTable( name: "DeviceVariables"); 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: "SystemConfig"); migrationBuilder.DropTable( name: "Devices"); migrationBuilder.DropTable( name: "FileAttachments"); migrationBuilder.DropTable( name: "FrameworkMenus"); migrationBuilder.DropTable( name: "Drivers"); } } }