function hierarchical_taxonomy_importer_install in Hierarchical Taxonomy Import 8
{@inherit_doc}
As Foreign keys are not directly supported with Database API, hence adding Foreign key constraint manually.
File
- ./
hierarchical_taxonomy_importer.install, line 58 - This file will contain install and uninstall hooks for hierarchical_taxonomy_importer module.
Code
function hierarchical_taxonomy_importer_install() {
// Query to alter mapping table and add a constraint.
$query = "ALTER TABLE {hti_term_levels} ADD CONSTRAINT " . " FOREIGN KEY(tid)" . " REFERENCES " . " {taxonomy_term_data}(tid)" . " ON DELETE CASCADE";
try {
\Drupal\Core\Database\Database::getConnection()
->query($query);
} catch (\Exception $ex) {
print $ex
->getMessage();
exit;
}
}