kohana-pack / timestamped-migrations

Rails Like migrations for Kohana 3
MIT License
6 stars 0 forks source link

DEFAULT CURRENT_TIMESTAMP doesn't work #14

Closed seyfer closed 10 years ago

seyfer commented 10 years ago

Try this

'created_at' => array('timestamp', 'default' => DB::expr('CURRENT_TIMESTAMP')) or 'created_at' => array('timestamp', 'default' => 'CURRENT_TIMESTAMP')

and have error

1396501173_create_table_pref_pay_tpl Create_Table_Pref_Pay_Tpl : migrating up -- create_table( pref_pay_tpl, array(id, name, updated_at, created_at) ) error: Migration_Exception [ 0 ]: CREATE TABLEpref_pay_tpl(idINT,nameVARCHAR (255),updated_atDATETIME NOT NULL,created_atTIMESTAMP DEFAULT 'CURRENT_TIMESTAMP') Exception: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at' ~ MODPATH/timestamped-migrations/classes/migration/driver/mysql.php [ 85 ]

here is my code

class Create_Table_Pref_Pay_Tpl extends Migration { public function up() { $this->create_table('pref_pay_tpl', array( 'id' => array('integer'), "name" => array("string"), 'updated_at' => array('datetime', "null" => FALSE), // 'created_at' => array('timestamp', 'default' => DB::expr('CURRENT_TIMESTAMP')), 'created_at' => array('timestamp', 'default' => 'CURRENT_TIMESTAMP'), )); } public function down() { $this->drop_table('pref_pay_tpl'); } }

This works in this module https://github.com/ferpetrelli/kohana-flexible-migrations

maybe you can fix?

dmitrymomot commented 10 years ago

try it:

'created_at' => 'timestamp',
seyfer commented 10 years ago

Fix for 3.2 branch too, please.