2

I used Drupal 7 and the Data module to import a table into Drupal. I could import the orphaned table, but my table has a column of type "timestamp" which does not show up when I try to edit the schema of the data table. I get the following error:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'published': ALTER TABLE {resource_profiles} CHANGE published published INT NOT NULL DEFAULT 'CURRENT_TIMESTAMP'; Array ( ) in db_change_field() (line 2988 of C:\xampp\htdocs\drupal\includes\database\database.inc).

I followed http://drupal.org/node/1466122, and added the timestamp datatype to /includes/database/mysql/schema.inc.

Where can I edit the schema information for my data table?

  • Where do you retrieve this error? I guess that the issue is into type you are trying to use (INT) and defining as a default value the current timestamp... – Gian Mar 29 '12 at 7:54
  • Yes.. the type is INT and I am trying to store a timestamp into it. But I added a new type called timestamp in the mysql database schema in drupal but "timestamp " does not show up when I try to edit the schema later within ui. – Aditya Kalluri Mar 29 '12 at 21:09
  • Also, if it's not a duplicate, and you want it to be possible in Drupal 7, then it would be a feature / backport request for Drupal 7 rather than a real question, and as such should be posted in issue queue on Drupal.org, not here. – Mołot May 4 '14 at 11:07
0

Like Gian says, you can't have a default value of CURRENT_TIMESTAMP for an int field.

Due to Drupal's database abstraction layer timestamp is not a supported field type.

This is due to not all databases supporting timestamp or now() as a field default value as apposed to mySQL where it is supported. The solution / work around if you're using mySQL is to add a query to your .install that modifies the field default to now() where the field type is int. See the Data Type doc page for further discussion: http://drupal.org/node/159605 or see here for more info on Drupals DB Schema: https://api.drupal.org/comment/48593

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.