diff --git a/phinx/src/Phinx/Db/Table.php b/phinx/src/Phinx/Db/Table.php index eafc2ac..d400fc0 100644 --- a/phinx/src/Phinx/Db/Table.php +++ b/phinx/src/Phinx/Db/Table.php @@ -560,19 +560,23 @@ class Table /** * Add timestamp columns created_at and updated_at to the table. * + * @param string $createdAtColumnName + * @param string $updatedAtColumnName + * * @return Table */ - public function addTimestamps() + public function addTimestamps($createdAtColumnName = 'created_at', $updatedAtColumnName = 'updated_at') { - $this->addColumn('create_time', 'timestamp', [ - 'default' => 'CURRENT_TIMESTAMP', - 'update' => '' - ]) - ->addColumn('update_time', 'timestamp', [ + $createdAtColumnName = is_null($createdAtColumnName) ? 'created_at' : $createdAtColumnName; + $updatedAtColumnName = is_null($updatedAtColumnName) ? 'updated_at' : $updatedAtColumnName; + $this->addColumn($createdAtColumnName, 'timestamp', array( + 'default' => 'CURRENT_TIMESTAMP', + 'update' => '' + )) + ->addColumn($updatedAtColumnName, 'timestamp', array( 'null' => true, 'default' => null - ]); - + )); return $this; }