Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arguments for timestamps columns names. #707

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Phinx/Db/Table.php
Expand Up @@ -550,17 +550,20 @@ public function hasForeignKey($columns, $constraint = null)
}

/**
* Add timestamp columns created_at and updated_at to the table.
* Add timestamp columns to the table.
* `created_at` and `updated_at` named by default.
*
* @param string $createdAtColumnName
* @param string $updatedAtColumnName
* @return Table
*/
public function addTimestamps()
public function addTimestamps($createdAtColumnName = 'created_at', $updatedAtColumnName = 'updated_at')
{
$this->addColumn('created_at', 'timestamp', array(
$this->addColumn($createdAtColumnName, 'timestamp', array(
'default' => 'CURRENT_TIMESTAMP',
'update' => ''
))
->addColumn('updated_at', 'timestamp', array(
->addColumn($updatedAtColumnName, 'timestamp', array(
'null' => true,
'default' => null
));
Expand Down