0

How to write the below using Install Scheme script .

I want initially the updated_at to be 0000-00-00 00:00:00

 CREATE TABLE IF NOT EXISTS `tgs_queue` (
`id` int(10) unsigned NOT NULL COMMENT 'ID',
`entity_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Product ID',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
 ) 

Is the below rite?

->addColumn(
            'created_at',
            \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
            null,
            [ 'nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT, ],
            'Created At'
        )
        ->addColumn(
            'updated_at',
            \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
            null,
            [ 'nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE, ],
            'Updated At'
0
->addColumn(
        'updated_at',
        \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
        null,
        ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE],
        'Updated At'

updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE

CURRENT_TIMESTAMP COMMENT 'Updated At'

  • I want updated_at columns default value to be 'as defined' by 00 :00 as shown – Sushivam Aug 23 '16 at 7:03
  • Make changes as per you need ALTER TABLE customer_entity CHANGE created_at created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Created At'; ALTER TABLE customer_entity CHANGE updated_at updated_at TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Updated At'; for ref maximehuran.fr/en/… – Arjun Aug 23 '16 at 7:15

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.