fix: Error if after the migration there are not null columns that are not part of the new schema#6282
Conversation
8fd313d to
c6196fe
Compare
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
127f755 to
1948bbc
Compare
2b46e23 to
d112538
Compare
d112538 to
91bd761
Compare
|
I would be cautions in dropping things as a data-integration tool. users can (and do) create their own constraints, views and so on. |
That's my concern too. We're dropping the constraint on columns that were primary keys before the migration, and are not after the migration. The main issue is that the migration succeeds, but puts the DB in a state that any following sync fails. Exiting with an error should also work. |
Yes error would be a better/safer solution. |
not null when a column is no longer a PK in the new schemanot null columns that are not part of the new schema
not null columns that are not part of the new schemanot null columns that are not part of the new schema
91bd761 to
b80ab93
Compare
b80ab93 to
14790b6
Compare
Done in 14790b6 |
|
Could also generate |
Ah, I tried that at first. But the problem they only work after we drop the primary keys. And if we drop the primary keys we won't be able to detect the error the next time the migration runs 🙃 |
Need an For the user message you could also suggest the drop pk commands as well as drop not nulls. |
I felt that would be too verbose, but let me try that |
But then again, it brings the question - do we tell the user to drop the column? Drop only the constraint? Rename it? |
In the olden times we did: I remember writing some code to compare a Here we'll just suggest the user to drop any unused column, including renames. We'll take care of the rest in the next migration (by adding what's missing). We could also tell the user what the next steps are (from our migrations POV, ie. what we're going to do on the next run if the columns are dropped), so they can decide for themselves if it's a rename and take necessary action? Too much? Maybe. |
I could go either way. I'd rather give a generic error that's 100% correct, than have something wrong in our heuristics and provide the wrong recommendation. Maybe dropping the primary key and the |
|
OK, so I think 371be8e should work (see image) |
🤖 I have created a release *beep* *boop* --- ## [2.0.2](plugins-destination-postgresql-v2.0.1...plugins-destination-postgresql-v2.0.2) (2023-01-06) ### Bug Fixes * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.18.0 ([#6339](#6339)) ([158365a](158365a)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.20.0 ([#6376](#6376)) ([d6187ec](d6187ec)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.21.0 ([#6382](#6382)) ([5baea40](5baea40)) * **deps:** Update plugin-sdk to v1.21.0 for destinations ([#6419](#6419)) ([f3b989f](f3b989f)) * Error if after the migration there are `not null` columns that are not part of the new schema ([#6282](#6282)) ([c5a4bf5](c5a4bf5)) * **pg:** Return more detailed pg errors ([#6421](#6421)) ([acb3e21](acb3e21)) * **postgresql:** Revert [#6282](#6282) ([#6434](#6434)) ([2cecacd](2cecacd)) * **tests:** Postgresql: Read only columns defined in the schema ([#6371](#6371)) ([491941a](491941a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This reverts commit 2cecacd.
…re not part of the new schema (#6519) #### Summary Bring back #6282 as the revert was not needed (see the fix #6466). Also I fixed the issue with the tests, they were flaky not failing. The reason is that the separator length is based on the `alter table` statement. Since I use a random table name, I need to pad the table index to make it consistent. **Please note that without this fix, if we rename a primary key column the migration will succeed but the first sync will fail without a clear message on the reason of the failure**. Original issue #6248 <!--

Summary
Fixes #6248 (implements
firstsecond solution from the issue)