-
-
Notifications
You must be signed in to change notification settings - Fork 784
[14.0][IMP] openupgrade_framework: remove FKs of obsolete tables/columns #2989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 14.0
Are you sure you want to change the base?
[14.0][IMP] openupgrade_framework: remove FKs of obsolete tables/columns #2989
Conversation
|
I will backport it to some previous versions. |
|
Isn't this more appropriate in https://github.com/OCA/server-tools/tree/13.0/database_cleanup? (or well, its later ports that are still pending) |
|
I see database_cleanup more to delete columns/tables instead of FKs. And not everybody uses that module. I mean, OU should not depend of the existence of database_cleanup. |
|
Indeed, But if you don't want to perform such cleaning yet, or you are doing data manipulation in the progress of the migration, there's a chance that these columns/tables interfere with it. Lifting these constraints allows to keep data, but not requiring extra controls/actions on your migration scripts or on normal activity after migration. My only doubt right now is if the field is re-added by a third-party module, if the constraints are restored by the ORM. As a related note, Odoo enterprise migration deletes directly the columns/tables (like performing |
| table = current_model._table | ||
| if tools.table_kind(self._cr, table) == "r": | ||
| openupgrade.remove_tables_fks(self.env.cr, [table]) | ||
| openupgrade.message( |
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.
Maybe you can mention on the message that only removing FKs, but it's optional.
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.
@MiquelRForgeFlow let's finish this putting that message.
|
No, I first created that module in order to clean up after migration, to prevent having do that in OpenUpgrade, especially because it would have to be an unsupervised process in OpenUpgrade whereas it is supervised in database_cleanup. |
|
Why is harmful? Please expose your use case to say that is harmful. I will prepare cases where you find the problem. I have right now in mind when trying to remove in v9 accounts of type view (it was work-arounded other way). |
|
@sbidoul could you exclude this repo from the runboat? thanks |
|
I'm most concerned about the loss of information and losing referential integrity. We keep these tables and columns for a reason. |
|
Hi, At first sight, I don't see why remove the foreign keys, so I agree with stefan to keep as much obsolete data / FK / etc. as possible, while waiting for the use of |
done |
|
/ocabot rebase Moreover, I'm in favor to close this PR. |
|
@legalsylvain The rebase process failed, because command |
|
One example of a problem due to old foreign keys is:
Although this one wouldn't be bypassed with this extra code, as the cleanup is done at the end. But I would say that the main reason is the performance: having FK with ondelete=cascade or ondelete=restrict for tables that are no longer used is draining the performance on each delete operation, but also the referential integrity is draining it on each update. You may want to keep the tables during some time after the migration, but you don't want them to affect your performance. |
3b9fe45 to
53a7d14
Compare
|
TLDR :
That's the main point. In my opinion : Here is the perimeter of openupgrade as I understand it :
this is what is outside the scope of openupgrade :
i don't think it's optional. When I explain how openugprade works, I always mention the fact of executing this module.
I see it less modular. @pedrobaeza : what's wrong with doing openupgrade + database_cleanup ? |
|
You can't move this outside of OpenUpgrade because you don't know which are the FKs that can be really deleted. It's a post-mortem analysis where not everything can be deduced. And I don't agree on your assessment about not having to care about performance after running OpenUpgrade. One of the main goals of OpenUpgrade is to adapt database schema and information to the state expected by the new version. If we don't remove extra DB schema things, like obsolete FK constraints (the same we have done manually in some occasions), we are not getting the same DB schema as if we create the DB from scratch in this new version. Preserving old data is not the same as preserving old DB scheme. |
I have to think about that point. I thought that it was possible, to deduce valid and invalid foreign keys, based on the code. if it's not the case, I'll have to reconsider my PoV on that topic.
Well, it's not "my" assessment. it's just how openupgrade and database_cleanup are designed. For the time being,
If you want to promote an "all-in-one" openupgrade tools so that the database is optimized to work in production and make the DB scheme after upgrade the same as a fresh DB, we have a lot of things to do, not only that point. Is it what you want ? If yes, we can open a distinct issue to talk about that point. |
This depends on the way you perform the migration. A dump + restore already VACUUM the DB. And you need to do the same VACUUM on the same Odoo version regularly. It's a DB maintenance operation, not OpenUpgrade nor
About schema I refer the rest of the things. It's clear that if we want to preserve old data, we have to preserve the part of the schema that supports this old data, which are tables/columns, but not the rest of the artifacts around them.
No and yes. I want to do in OpenUpgrade what is the most suitable to be done and to not force to install and run a foreigner thing for finishing what I consider part of a good migration: old things not affecting the behavior of the new version. And this includes both constraints that blocks proper operations (we remove these constraints manually in migration scripts when detected), and the rest of the deprecated constraints that don't block the operation, but impact them on the speed to perform them. |
It was time.