denny / ShinyCMS

ShinyCMS is an open source CMS. This is the Perl version, built with Catalyst and DBIC. (There is also a Ruby on Rails version: www.github.com/denny/ShinyCMS-ruby)
56 stars 24 forks source link

Fix for MySQL default timestamp fields. #13

Closed dteklavya closed 10 years ago

dteklavya commented 10 years ago

Default time stamp will not work on MySQL version earlier than 5.6.5.

A workaround could be to use DBIx::Class::TimeStamp and leave the DB fields null-able or without defaults.

denny commented 10 years ago

Hi, thanks for the patch! Unfortunately you're not supposed to edit the DBIC files above the line that says "DO NOT MODIFY THIS OR ANYTHING ABOVE!", or DBIC::Schema::Loader stops working. You need to change the default in the database using an ALTER TABLE statement (or in the sample SQL file in /docs/database before importing that into the database), and then regenerate the modules from the modified database using the script provided in /bin/dev-tools - this will update the checksum in the files and keep everything happy for future auto-generation of DBIC modules.

denny commented 10 years ago

I can't actually remember why there are default dates on these columns. It might be worth digging through the code to see where they're used, if anywhere. You're right that having no default would seem to make more sense.

dteklavya commented 10 years ago

Denny,

Regenerating DBIC schema results in lot of noisy changes. It also removes the POD sections. This is probably due to different version of DBIC than one that was originally used. There was few changes to code as well to models which are unrelated.

Perhaps we can regenerate models for only two tables in question but even that is not a good idea and will be noisy.

Thanks.

denny commented 10 years ago

Hrm, that's annoying. I guess I'll make the change and regenerate the model here.

I do wish DBIC::S::L would stop changing the way it lays the model out so frequently, it's quite irritating. Thanks for trying, anyway!

denny commented 10 years ago

Okay, fixed/kludged: https://github.com/denny/ShinyCMS/commit/9c7191b7f2e6f2fbc8ee434e5ac06b561c3820d6