Flyway baselines new schemas, since they always have a schema_version table. #898
Comments
Could you contribute a small test case that reproduces the bug? |
Okay, I created a really small test here: import org.flywaydb.core.Flyway; import java.io.*; public class BaselineTest {
} The testExistingSchema() passes and testNewSchema() fails. It fails with: org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException: Migration V2__AddColumn.sql failedSQL State : 42P01
|
Thanks! I'll have a look at this in time for 3.2 |
Thanks for confirming this is an actual bug and not just an issue with my understanding. For now I'll just make two separate codepaths for updating existing tenants and provisioning new tenants, so that only the old tenants are baselined. |
oops, I thought "close" was for closing browser, not bug, sorry, re-opening |
It turns out we even had a testcase for this actually validating the wrong behavior! Thanks for reporting. Fixed. Cheers |
… a schema_version table
I have a tenant-per-schema system, where each schema has it's own schema_version table.
So I already have some existing schemas, but new schemas will be added as well. My integration tests to create new schemas are failing. I see it is because of this code in Flyway.java starting at line 929:
Line 929, the call to create(), ends up creating the table SCHEMA_VERSION with the schema_marker.
Specifically, the call MetaDataTableImpl.addSchemasMarker() creates this table just after the schema is created.
Line 934, the call to empty(), returns false, because the schema does have this one single table SCHEMA_VERSION.
So now we think this brand new schema is non-empty, and we end up baselining the schema. Then the brand new migration script fails because it is trying to add a column to a table which should have been created in the baselined scripts.
Is this a bug, or am I mis-using baseline somehow? I want my existing schemas to be baselined up to a certain point without my future schemas failing to create.
The text was updated successfully, but these errors were encountered: