I have managed to get working a solution for the timestamp datatype for MySQL. I don't yet know how to create patches etc. so I put describe here my work and I hope that if you are looking for a way to make this work you can use my work to help you, or even better, if you are able to make this fix get into core, all the better.

In your database schema use as shown in the example below:

  $schema['vchess_moves'] = array(
      'description' => 'Contains the list of moves for each game',
      'fields' => array(
          'timestamp' => array(
              'description' => 'Exact date and time of the move',
              'type' => 'timestamp',
              'not null' => TRUE,

In the MySQL version of schema.inc in /includes/database/mysql/schema.inc file add code for the timestamp datatype in the getFieldTypeMap() function:

  public function getFieldTypeMap() {
    // Put :normal last so it gets preserved by array_flip. This makes
    // it much easier for modules (such as schema.module) to map
    // database types back into schema types.
    // $map does not use drupal_static as its value never changes.
    static $map = array(
      'varchar:normal'  => 'VARCHAR',
      'char:normal'     => 'CHAR',

      'text:tiny'       => 'TINYTEXT',
      'text:small'      => 'TINYTEXT',
      'text:medium'     => 'MEDIUMTEXT',
      'text:big'        => 'LONGTEXT',
      'text:normal'     => 'TEXT',

      'serial:tiny'     => 'TINYINT',
      'serial:small'    => 'SMALLINT',
      'serial:medium'   => 'MEDIUMINT',
      'serial:big'      => 'BIGINT',
      'serial:normal'   => 'INT',

      'int:tiny'        => 'TINYINT',
      'int:small'       => 'SMALLINT',
      'int:medium'      => 'MEDIUMINT',
      'int:big'         => 'BIGINT',
      'int:normal'      => 'INT',

      'float:tiny'      => 'FLOAT',
      'float:small'     => 'FLOAT',
      'float:medium'    => 'FLOAT',
      'float:big'       => 'DOUBLE',
      'float:normal'    => 'FLOAT',

      'numeric:normal'  => 'DECIMAL',
 
      'timestamp:normal'=> 'TIMESTAMP', // This is a line you need to add for timestamp    
   
      'enum:normal'     => 'ENUM',      // See drupal.org/node/1464354 if you want ENUM as well

      'blob:big'        => 'LONGBLOB',
      'blob:normal'     => 'BLOB',
     );
    return $map;
  }

That's it!

I've tested it on Drupal 7.10, and for me it works great. As I said, if someone can help get this into core, that would be brilliant. I understand that a similar thing should also be added for the other database schema files, but I don't see that this should stop this MySQL fix going in already.

You might also like to read:

Comments

Eric_A’s picture

ziobudda’s picture

Why is this not in the core ? 2 years old...

drupalshrek’s picture

I think from the Eric_A links, it is a conscious decision to not do so.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kenorb’s picture

daffie’s picture

Version: 8.1.x-dev » 7.x-dev

This belongs with Drupal 7. The related issue is also Drupal 7.