2

I am getting this error with my existing database:

no Schema type for mysql type date.

I did some research and it seems like schema does not support date type in MySQL. What would you guys suggest I replace it with? I'm presenting income statements and balance sheets on my site and I need to have some sort of date reference of each row(otherwise I wouldn't be able to figure out 2009 earnings versus 1999).

What other options are available?

  • Perfect answer by Berdir, i want only to add that if you ever choose to use mysql_data in Drupal 7 probably the core or some module could always give the "no schema for that type field" message, but you can ignore it, as I learned on my question here: drupal.stackexchange.com/a/69741/16340?stw=2 – Marco Apr 13 '13 at 18:31
2

You could define it yourself, have a look at http://drupal.org/node/159605#comment-1674678.

You should however only do this if you are sure that you will only ever use/support MySQL.

Portability with date data types among different databases is almost impossible. Drupal 7 initially had date types defined but they were removed again because there is simply no way to make them work consistently across multiple database types.

You might want to look at http://drupal.org/project/date, I'm pretty sure that allows to use dates that can not be mapped to a UNIX timestamp.

  • awesome. I'll give it a shot. Date wasn't working for me, but I'll work on defining it myself. I am going to stick with mysql for sure for a while. I am making the site in drupal6, but want to make it in drupal7..so as new modules get released I'll look at rebuilding and will study if I want to stick to mysql. Other then bigtables(google), I don't see myself using any other database in the near future. Thank you so much for all your help with my project Berdir. You have answered many of my questions and I'm very grateful. – Lostsoul May 19 '11 at 0:16
0

I found a better solution than ignoring the message. I was able to stop getting it by making Schema happy.

When I imported a table from Access to MySQL and then adopted it for the Data module ("Structure > Data tables > Adopt tables") I got the same message for two table fields, one that was a "Yes/No" in Access and the other that was a "Date/Time". The importation from Access had converted those fields to types "bit(1)" and "datetime", respectively, in MySQL. Drupal's data schema does not have bit types or temporal (date/time) types, so the Schema module issued those messages.

My solution was to convert those table fields to types that are consistent both with Drupal's schema and with the data in my table. I converted the "bit(1)" field to type "tinyint(1)" and the "datetime" field to type "double". (The "datetime" data type is the same as the "double" type except that it's designated to represent a date and time.)

I checked that the conversion had not changed the values of the data in the table. For the datetime field, this was done using the SQL function "convert(<field name>, datetime)". The check was successful; the before and after values were the same.

Then I went back to "Data tables" and adopted the table with the converted data types. No more complaints from Schema!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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