This is my first post to the forum, and I’ll point out right away that
I’m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that I’m
wrong here, but is the ‘year’ datatype missing from ActiveRecord in
2.0.2? According to my MySQL 5.0 reference manual, ‘year’ is a datatype,
but when I try to run a migration that has a t.year column, I get this:
I opened up the mysql_adapter.rb file in my frozen 2.0.2 ActiveRecord,
and sure enough, ‘year’ was missing from the native_database_types hash,
so I added it. rake db:migrate still doesn’t work (continues to give the
same error, and I can’t find the TableDefinition), however. Any
suggestions? I can of course use a ‘date’ as a workaround, but I’m
building a discography, and ‘year’ is all I need.
I opened up the mysql_adapter.rb file in my frozen 2.0.2 ActiveRecord,
and sure enough, ‘year’ was missing from the native_database_types hash,
so I added it. rake db:migrate still doesn’t work (continues to give the
same error, and I can’t find the TableDefinition), however. Any
suggestions? I can of course use a ‘date’ as a workaround, but I’m
building a discography, and ‘year’ is all I need.
I don’t believe that ‘year’ is a standard sql type so I suspect that
Rails
is intentionally not putting it in there as what you’ve just done won’t
work with other databases…
If all you need is the number, just make it an :integer.
Thanks, this makes sense. I agree that an integer is the way to go,
but I figured that if it existed in MySQL I might as well use it. But
if it’s specific only to MySQL, then I understand why it’s not there.
Is there a place in the API/docs where this kind of stuff is listed/
explained?
Thanks, this makes sense. I agree that an integer is the way to go,
but I figured that if it existed in MySQL I might as well use it. But
if it’s specific only to MySQL, then I understand why it’s not there.
Is there a place in the API/docs where this kind of stuff is listed/
explained?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.