Open martijnboland opened 2 years ago
Hi, would you be able to provide a sample snapshot? and perhaps try this again with the latest 9.14.1
version?
I'm seeing re-applying stating that the collections are marked to be deleted, which feels like it's an entirely different issue now.
That said, I do also think the particular error reported here specifically pertains to MSSQL (based on the identity(1,1)
in the error). Other similar errors (like SQLite char primary key to Postgres UUID) are tracked separately, so we'll need a reproduction specifically from Postgres to MSSQL to confirm this issue 🤔
Just tried with 9.14, but re-applying indeed states that all collections are going to be deleted (both pg->mssql and mssql->pg).
Added snapshots: snapshots.zip
Just tried with 9.14, but re-applying indeed states that all collections are going to be deleted (both pg->mssql and mssql->pg).
Added snapshots: snapshots.zip
Thanks for sharing the snapshots and also confirming the current state of re-applying is different now! Seems like we'll have to take another detour to resolve this new issue first 😄
The re-applying snapshot turns out to not be MSSQL specific, but it's more so between any different db vendors since their collection -> schema
are indeed vendor-specific 🤔
(snapshots below are simplified to focus the main differences)
When applying snapshot from PostgreSQL onto MSSQL:
collections:
- collection: a
meta:
# meta properties here
schema:
comment: null
name: a
schema: public
It's diff-ing against:
collections:
- collection: a
meta:
# meta properties here
schema:
catalog: directus_db
name: a
schema: dbo
but schema.catalog
is unique to mssql and shouldn't be attempted to be removed, and schema.schema
for mssql is by default dbo
, which is different to the PostgreSQL's default public
.
When applying snapshot from SQLite onto Postgres:
collections:
- collection: a
meta:
# meta properties here
schema:
name: a
sql: >-
CREATE TABLE `a` (`id` char(36) not null, `name` varchar(255) null,
primary key (`id`))
It's diff-ing against:
collections:
- collection: a
meta:
# meta properties here
schema:
comment: null
name: a
schema: public
but sql
is SQLite specific and shouldn't be applied, nor should it attempt to remove schema.schema
on Postgres side.
That said, we can't flat out ignore the schema
property as schema: null
denotes an folder collection.
Tracking the re-apply issue in #14687, but leaving this open until we can circle back to this MSSQL specific error once #14687 gets resolved.
Linear: ENG-254
Describe the Bug
When you create a snapshot for a specific database type (e.g. postgres) and apply that to another database type (e.g. mssql), the initial apply on an empty db succeeds, but the next time, applying fails because for some reason, differences in id fields are detected and the schema applier tries to update the id fields with invalid SQL.
schema created with postgres and applied on mssql (2nd time):
The other way around (schema created with mssql and applied on postgres) also fails, but with a different error:
To Reproduce
Create a snapshot on a specific database type (e.g. postgres) and apply that to a different database type (e.g. mssql). Applying the snapshot on an empty database the first time works, but succeeding applies on this database fail.
Errors Shown
No response
What version of Directus are you using?
9.10.0
What version of Node.js are you using?
16.13.1
What database are you using?
Postgres 13, MS SQL Server 2019
What browser are you using?
Chrome
How are you deploying Directus?
locally