You are here

function hook_schema_field_type_map_alter in Schema 8

Same name and namespace in other branches
  1. 7 schema.api.php \hook_schema_field_type_map_alter()

Alter the results from the getFieldTypeMap() methods in the schema class.

Parameters

array $map: The array mapping of Drupal schema field names to DB-native field types.

DatabaseSchema $schema: The database schema class.

DatabaseConnection $connection: The database connection class since the $schema object doesn't offer $schema->connection as a public property.

2 invocations of hook_schema_field_type_map_alter()
SchemaDatabaseSchema_mysql::getFieldTypeMap in src/SchemaDatabaseSchema_mysql.php
Overrides DatabaseSchema_mysql::getFieldTypeMap().
SchemaDatabaseSchema_pgsql::getFieldTypeMap in src/SchemaDatabaseSchema_pgsql.php
Overrides DatabaseSchema_pgsql::getFieldTypeMap().

File

./schema.api.php, line 19
API integration for the Schema module.

Code

function hook_schema_field_type_map_alter(array &$map, DatabaseSchema $schema, DatabaseConnection $connection) {
  switch ($connection
    ->getType()) {
    case 'mysql':
      $map['datetime:normal'] = 'DATETIME';
      break;
    case 'pgsql':
      $map['datetime:normal'] = 'timestamp without time zone';
      break;
    case 'sqlite':
      $map['datetime:normal'] = 'VARCHAR';
      break;
  }
}