3

I am upgrading my table with new version and changed config version too,

getting error :PDOException Object ( [message:protected] => SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 [string:Exception:private] => [code:protected] => 42000

here is my query :

<?php
$installer = $this;
$installer->startSetup();

$installer->run("ALTER TABLE `asm_tracker` CHANGE COLUMN  `create_at` TIMESTAMP;");
$installer->run("ALTER TABLE `asm_tracker` CHANGE COLUMN  `punch_in_time` TIMESTAMP;");
$installer->run("ALTER TABLE `asm_tracker` CHANGE COLUMN  `punch_out_time` TIMESTAMP;");
$installer->run("ALTER TABLE `asm_tracker` ADD `manager_name` varchar(30) NOT NULL ;");

$installer->endSetup();

?>

want to change DATATYPE and add one column in existing table.

3

Try this :

$installer = $this;
$installer->startSetup();
$installer->run("ALTER TABLE `asm_tracker` CHANGE `create_at` `create_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;");
$installer->run("ALTER TABLE `asm_tracker` CHANGE `punch_in_time` `punch_in_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;");
$installer->run("ALTER TABLE `asm_tracker` CHANGE `punch_out_time` `punch_out_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;");
$installer->run("ALTER TABLE `asm_tracker` ADD `manager_name` varchar(30) NOT NULL;");
$installer->endSetup();
3

Try below code:

$installer = $this;
$installer->startSetup();

$installer->run("ALTER TABLE `asm_tracker` CHANGE `create_at` `create_at` TIMESTAMP;");
$installer->run("ALTER TABLE `asm_tracker` CHANGE `punch_in_time` `punch_in_time` TIMESTAMP;");
$installer->run("ALTER TABLE `asm_tracker` CHANGE `punch_out_time` `punch_out_time` TIMESTAMP;");
$installer->run("ALTER TABLE `asm_tracker` ADD `manager_name` varchar(30) NOT NULL;");
$installer->endSetup();

Note: Please add "NOT NULL DEFAULT CURRENT_TIMESTAMP"

1

You have to use below code after TIMESTAMP:

NOT NULL DEFAULT CURRENT_TIMESTAMP

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.