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
Drush command for deleting orphaned legacy datastore tables #2839
Conversation
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 tested this by creating an empty table called "feeds_datastore_dkan_file_130" and the command did remove it. So let's make these small wording changes and I'll merge it.
// Delete ghost datastore tables. | ||
$items['dkan-datastore-delete-ghost-tables'] = array( | ||
'aliases' => array('dkan-datastore-dgt'), | ||
'description' => 'Delete ghost datastore tables if they exist.', |
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.
We've been using the term "ghost" casually for this but I don't think it's very clear to others. Let's switch "ghost" for "orphan," and "deleted" for "dropped" while we're at it. So let's call it dkan-datastore-drop-orphan-tables
) And while we're at it let's make that alias a little shorter and consistent with our conventions: dkan-dot
.
} | ||
} | ||
if (!empty($nids)) { | ||
drush_print("Looking through " . implode(', ', $nids)); |
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.
Let's say for this "Checking for the following nodes: "
drush_print("Deleted ghost table $table"); | ||
} | ||
} else { | ||
drush_print("There is currently no datastore tables."); |
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.
"There are currently no datastore tables on this site."
drush_print("Ghost tables found: $ghosts"); | ||
foreach ($to_truncate as $table) { | ||
$query = db_drop_table($table); | ||
drush_print("Deleted ghost table $table"); |
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.
"Deleted orphan table $table"
@dafeder fixed. |
Drush command for deleting orphaned legacy datastore tables
Drush command for deleting orphaned legacy datastore tables
User story
The ghost datastore tables are those for which there doesn't exist a related node, for example there exist a table
feeds_datastore_dkan_file_10000
but there isn't a node with id10000
. Here we're adding a new drush commanddrush dkan-datastore-delete-ghost-tables
with aliasdrush dkan-datastore-dgt
to find ghost datastore tables and delete them.QA Steps
drush dkan-datastore-drop-orphan-tables
ordrush dkan-datastore-dot
you'll get the following behaviour:Connects NuCivic/dkan_management#171