I have just upgraded an existing application from ABP 3.3.1 to 7.0.1
I have resolved all dependency issues, build errors and updates in the code.
Now I am trying to run the DB migrator after creating a new migration as advised in the documentation:
Use Add-Migration "Upgraded_To_Abp_4_1" or a similar command in the Package Manager Console (PMC) to create a new migration (Set the EntityFrameworkCore as the Default project in the PMC and .DbMigrator as the Startup Project in the Solution Explorer, in the Visual Studio).
The issue I am having is that it wants to create new tables that already exist.
So I am getting an exception An unhandled exception of type 'Microsoft.Data.SqlClient.SqlException' occurred in System.Private.CoreLib.dll There is already an object named 'AbpAuditLogs' in the database.
If I look at the migration code I do see that it CREATES a new table. It doesn't ALTER
What is the ABP approach to solve this?
migrationBuilder.CreateTable(
name: "AbpAuditLogs",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ApplicationName = table.Column<string>(type: "nvarchar(96)", maxLength: 96, nullable: true),
BrowserInfo = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
ClientId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
ClientIpAddress = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
ClientName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
Comments = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CorrelationId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
Exceptions = table.Column<string>(type: "nvarchar(max)", nullable: true),
ExecutionDuration = table.Column<int>(type: "int", nullable: false),
ExecutionTime = table.Column<DateTime>(type: "datetime2", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
HttpMethod = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: true),
HttpStatusCode = table.Column<int>(type: "int", nullable: true),
ImpersonatorTenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ImpersonatorTenantName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
ImpersonatorUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ImpersonatorUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
TenantName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
Url = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpAuditLogs", x => x.Id);
});
Because of time constraints and this being a once-off exercise, I ended up using Redgate Compare (Free trial - feature complete)
AbpUsers
table (has breaking schema changes)AbpUsers
tableAll this in under 2 hours.
Still open to hear of a better, faster and data-safe way