Active
Project:
Drupal core
Version:
main
Component:
database system
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
20 Oct 2016 at 09:35 UTC
Updated:
26 Jun 2021 at 19:26 UTC
Jump to comment: Most recent
Comments
Comment #6
andypostComment #8
andypostComment #13
tr commenteddrupal_get_module_schema()was removed in core 9.2 by #2908886: Split off schema management out of schema.incThere is now currently no API to get a table schema for any table. I consider this a regression, and this issue should probably now be a bug report rather than a feature request.
Use case:
There is nothing unusual or edge about this use case - just because not many modules do this does not mean it is wrong in any way. Drupal should and must have methods for dealing with non-Entity, non-Field data.
But for this use case to work, I MUST be able to create a new table with the same structure as the existing table. And for that I need the schema of the existing table. While I have
\Database::getConnection()->startTransaction(),\Database::getConnection()->schema()->dropTable()andDatabase::getConnection()->schema()->renameTable()available for this purpose, creating the temporary table requires\Database::getConnection()->schema()->createTable()which requires a schema for the created table. There is no way to obtain that schema anymore now thatdrupal_get_module_schema()has been removed.The solution suggested in #2908886: Split off schema management out of schema.inc is to use
\Drupal\TestTools\Extension\SchemaInspector, which is intended only for Tests. This is not a substitute for having schema introspection in core. The only other alternative is to call<modulename>_schema()directly, which again is not a good solution.This issue proposes a solution that would work for my use case. It requires maintainer feedback. Part of this solution is to deprecated
drupal_get_module_schema(), but that has already been done, and without a replacement, so IMO the priority of this issue should now be higher because functionality has disappeared.@claudiu.cristea, this is still assigned to you - are you intending to work on it?