-
Notifications
You must be signed in to change notification settings - Fork 260
Remove soft-deletion pattern #2327
Remove soft-deletion pattern #2327
Conversation
Addresses #2146 |
@zwass I took a stab at solving #2146 here. It's still a bit of a work in progress, but I could use some help with the migrations since I haven't worked with that before. I'm following the instructions in When I run Could you take a look and see if I'm doing something wrong? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tackling this!
server/datastore/mysql/migrations/data/20171212182459_DeleteSoftDeletedPacks.go
Show resolved
Hide resolved
server/datastore/mysql/migrations/data/20181119180000_DeleteSoftDeletedEntities.go
Show resolved
Hide resolved
) | ||
|
||
func init() { | ||
goose.AddMigration(Up20201011162341, Down20201011162341) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be MigrationClient.AddMigration
. That will solve your issue with the migration not running. Do we need to update the docs about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs say to run goose create AddColumnFooToUsers
, then 'edit it', but is less clear on what needs to be done.
I see two things that must be edited (as far as I can tell) each time you run the goose create
command:
- delete the import line for goose:
github.com/pressly/goose
- change
goose.AddMigration(...)
to `MigrationClient.AddMigration(...)
I can add a note to the docs to fix both of these if you'd like.
It would also be good to have the goose create
command generate this file as close to 'correctly' as possible, so it might be worth updating the goose library to do this.
Also while I was looking into this, I was a bit confused on what the kolide goose fork did, but it seemed like the fork hasn't been updated since 2018, while the pressly source is still actively maintained. Long-term - should we consider moving back to pressly upstream?
server/datastore/mysql/migrations/tables/20201011162341_CleanupSoftDeletedColumns.go
Show resolved
Hide resolved
server/datastore/mysql/migrations/tables/20201011162341_CleanupSoftDeletedColumns.go
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there are a couple of test failures that need to be updated.
In regards to your comment about Goose (Github no longer seems to allow me to reply to that comment), please do update the documentation with what you found.
We had initially forked Goose for at least one reason: We needed to be able to make the separate migration "clients" for tables and data, and needed to refactor Goose from using a single, global, migration client. I cannot remember if there were other motivations for the fork.
I did look recently at the activity on Goose and did not get the impression that the core had changed in a way that would allow us to achieve the goal of separate clients. That said, I do think it could be worthwhile to try to rebase the fork onto the new changes.
In regards to making the command generate a migration closer to what we need, that definitely seems worthwhile.
server/datastore/mysql/migrations/tables/20201011162341_CleanupSoftDeletedColumns.go
Show resolved
Hide resolved
server/datastore/mysql/migrations/tables/20201011162341_CleanupSoftDeletedColumns.go
Show resolved
Hide resolved
server/datastore/mysql/migrations/data/20171212182459_DeleteSoftDeletedPacks.go
Show resolved
Hide resolved
* Perform migration to delete any entries with `deleted` set, and subsequently drop columns `deleted` and `deleted_at`. * Remove `deleted` and `deleted_at` references.
* Change `goose.AddMigration` to `MigrationClient.AddMigration` * If columns don't exist, skip instead of failing the migration. This might happen in the case of a partial or broken migration.
* Specify changes that need to be made after running the goose create command.
One of the test failures is when deleting hosts. There is an existing test for I'm not sure what the reasoning is behind that, but I'm going to put up a commit that removes this test, as deleting is not actually idempotent any more. Give me a shout if this doesn't work. |
* Without soft-delete, host deleting is no longer idempotent. Removing the test for this.
* Replace definitions with the mysqlerr package constants instead of defining them here.
* Return appropriate error message when attempting to insert a query by ID that already exists in the DB.
5e13345
to
102ea1b
Compare
I am totally on board with removing tests that no longer make sense. Thank you. I will give this some more review and testing when I have a chance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed a commit to remove the debug prints. Thank you for sorting this out!
Changes in kolide/fleet#2327 broke the MySQL syntax for listing hosts with online status. This was not caught due to the lack of a unit test for the functionality. This PR adds a unit test and fixes the regression.
Changes in kolide/fleet#2327 broke the MySQL syntax for listing hosts with online status. This was not caught due to the lack of a unit test for the functionality. This PR adds a unit test and fixes the regression.
This is another error introduced in kolide/fleet#2327 we did not catch previously due to insufficient unit test coverage. Test is now added
This is another error introduced in kolide/fleet#2327 we did not catch previously due to insufficient unit test coverage. Test is now added.
deleted
set, andsubsequently drop columns
deleted
anddeleted_at
.deleted
anddeleted_at
references.