Problem/Motivation
#2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data added an API for converting an entity type's schema between various translatable/revisionable states, and this can be seen as a major update API that hasn't been attempted before in core.
The schema conversion process creates backup tables at the begging of the migration, and it deletes them at the end if no errors were encountered/thrown during the data copying process.
Proposed resolution
It was argued by @plach that we should keep those backup tables around, possibly indefinitely, in order to provide a way for users to recover their data if something goes terribly wrong.
Remaining tasks
Discuss whether we want to keep the backup tables around, for how long, and maybe provide a mechanism to delete them from the UI.
User interface changes
TBD.
API changes
Nope.
Data model changes
Having a lot of backup tables in the database could be seen as a data model change?
Release notes snippet
Entity schema operations will now leave backup tables in place for inspection. See the <a href="https://www.drupal.org/node/3046576">change record</a> for more details including how to disable this functionality.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | interdiff-9.txt | 7.98 KB | amateescu |
| #9 | 3024728-9.patch | 11.16 KB | amateescu |
| #6 | interdiff-6.txt | 3.39 KB | amateescu |
| #6 | 3024728-6.patch | 8.87 KB | amateescu |
| #5 | 3024728-5.patch | 5.49 KB | amateescu |
Comments
Comment #2
plachAs mentioned in #2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data, I'd be fine with a PHP setting that lets people enable the automatic deletion behavior. Sites with big databases would just need to enable it, but those are likely to have more tech-savy people behind them. OTOH non-technical site owners relying on dangerous YOLO update workflows directly on prod would have a safety net by default.
Comment #3
hchonovWhat about something like a Dashboard for the admin where pending actions must be approved? We could then add a notification there and when the admin approves it, then we could flag those tables for deletion. I think that we could use such a dashboard for a lot of different things instead of introducing more and more settings :).
Comment #5
amateescu commentedThis should do it.
Comment #6
amateescu commentedAdded test coverage.
Comment #7
dixon_I like the idea of using a PHP setting for this. It's very simple and definitely sufficient.
We just need to make a point of creating a change record for this to bring this new setting to people's attention.
Comment #8
plachThis is exactly what I had in mind, thanks! Storing backup metadata in the key-value store opens up the door for all sort of fancy solutions on top of this, like the one that @hchonov was mentioning in #3. At the same we have a change that is small enough to still have a chance to go into 8.7.0.
The patch looks very good to me, however it seems that we have no test coverage for the case where the setting is FALSE. It would be good to add that as well, since that's a critical piece of this solution. I think we should really add that.
Quick code review:
The
::getTemporaryTableMappingPrefix()method was added in 8.7.x and is internal, however, since it was in -beta1, I think it would be better to add a new (protected) method to compute just the hash and invoke that from::getTemporaryTableMappingPrefix(), so we do not need to change its behavior. This would have the additional (admittedly minor) benefit of keeping thetmp_prefix encapsulated.I was wondering whether it would make sense to append the timestamp to the prefix key, just to be super safe :)
Comment #9
amateescu commentedThank you both for the reviews! Added a change record here: https://www.drupal.org/node/3046576
Re #8:
Added test coverage for the case when the setting is
FALSE.1. Let's add an optional argument to that method instead :) FWIW, it's kinda sad that
@internalis meaningless and it doesn't really help with anything..2. I would prefer not to do that, this hash should be useful for quick visual inspection and comparison between entries in the state storage and the database table names, and obfuscating it with additional characters would make it harder.
Comment #10
plachLooks good, thanks!
Comment #11
catchAdded a release notes snippet.
Committed/pushed to 8.8.x and cherry-picked to 8.7.x.