Change TIMESTAMP columns to DATETIME manually

This commit is contained in:
Toby Zerner 2018-08-01 13:24:55 +09:30
parent a13175600f
commit fdcb78a48c
3 changed files with 21 additions and 18 deletions

View File

@ -14,14 +14,15 @@ use Illuminate\Database\Schema\Builder;
return [ return [
'up' => function (Builder $schema) { 'up' => function (Builder $schema) {
$schema->table('registration_tokens', function (Blueprint $table) { // do this manually because dbal doesn't recognize timestamp columns
$table->dateTime('created_at')->change(); $connection = $schema->getConnection();
}); $prefix = $connection->getTablePrefix();
$connection->statement("ALTER TABLE {$prefix}registration_tokens MODIFY created_at DATETIME");
}, },
'down' => function (Builder $schema) { 'down' => function (Builder $schema) {
$schema->table('registration_tokens', function (Blueprint $table) { $connection = $schema->getConnection();
$table->timestamp('created_at')->change(); $prefix = $connection->getTablePrefix();
}); $connection->statement("ALTER TABLE {$prefix}registration_tokens MODIFY created_at TIMESTAMP");
} }
]; ];

View File

@ -14,14 +14,15 @@ use Illuminate\Database\Schema\Builder;
return [ return [
'up' => function (Builder $schema) { 'up' => function (Builder $schema) {
$schema->table('email_tokens', function (Blueprint $table) { // do this manually because dbal doesn't recognize timestamp columns
$table->dateTime('created_at')->change(); $connection = $schema->getConnection();
}); $prefix = $connection->getTablePrefix();
$connection->statement("ALTER TABLE {$prefix}email_tokens MODIFY created_at DATETIME");
}, },
'down' => function (Builder $schema) { 'down' => function (Builder $schema) {
$schema->table('email_tokens', function (Blueprint $table) { $connection = $schema->getConnection();
$table->timestamp('created_at')->change(); $prefix = $connection->getTablePrefix();
}); $connection->statement("ALTER TABLE {$prefix}email_tokens MODIFY created_at TIMESTAMP");
} }
]; ];

View File

@ -14,14 +14,15 @@ use Illuminate\Database\Schema\Builder;
return [ return [
'up' => function (Builder $schema) { 'up' => function (Builder $schema) {
$schema->table('password_tokens', function (Blueprint $table) { // do this manually because dbal doesn't recognize timestamp columns
$table->dateTime('created_at')->change(); $connection = $schema->getConnection();
}); $prefix = $connection->getTablePrefix();
$connection->statement("ALTER TABLE {$prefix}password_tokens MODIFY created_at DATETIME");
}, },
'down' => function (Builder $schema) { 'down' => function (Builder $schema) {
$schema->table('password_tokens', function (Blueprint $table) { $connection = $schema->getConnection();
$table->timestamp('created_at')->change(); $prefix = $connection->getTablePrefix();
}); $connection->statement("ALTER TABLE {$prefix}password_tokens MODIFY created_at TIMESTAMP");
} }
]; ];