budu / lobos

A library to create and manipulate SQL database schemas with migrations support.
http://budu.github.com/lobos/
267 stars 56 forks source link

No support for datetime type #41

Open techwhizbang opened 12 years ago

techwhizbang commented 12 years ago

MySQL and H2 support the datetime column type which we prefer over timestamps seeing that MySQL's version of timestamp is limited to the years (1970 to 2038). Can you introduce support for the datetime column type with the H2 and MySQL backends? Thank you!

budu commented 12 years ago

I'll have a look at it later today.

On Thu, Apr 26, 2012 at 4:13 PM, Nick Zalabak < reply@reply.github.com

wrote:

MySQL and H2 support the datetime column type which we prefer over timestamps seeing that MySQL's version of timestamp is limited to the years (1970 to 2038). Can you introduce support for the datetime column type with the H2 and MySQL backends? Thank you!


Reply to this email directly or view it on GitHub: https://github.com/budu/lobos/issues/41

budu commented 12 years ago

After a quick look, I'm not sure Lobos should support the datetime data type by default as it's not standard. You should be able to use custom data types easily though using the column and data-type functions. Here's an example of how you would define your own datetime function:

(defn datetime [table name & options]
  (apply column table name (data-type :datetime) options))

Basically, data types in Lobos are represented as keywords and those are simply made into string then upper cased by the compiler. Some backends defines data type aliases (for example the SQL Server backend substitute :timestamp by :datetime2), but I've not sure if datetime would be a better fit for H2 and MySQL, I'll need to revise those. I'll leave that issue open until I've figured it out.