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 [
'up' => function (Builder $schema) {
$schema->table('registration_tokens', function (Blueprint $table) {
$table->dateTime('created_at')->change();
});
// do this manually because dbal doesn't recognize timestamp columns
$connection = $schema->getConnection();
$prefix = $connection->getTablePrefix();
$connection->statement("ALTER TABLE {$prefix}registration_tokens MODIFY created_at DATETIME");
},
'down' => function (Builder $schema) {
$schema->table('registration_tokens', function (Blueprint $table) {
$table->timestamp('created_at')->change();
});
$connection = $schema->getConnection();
$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 [
'up' => function (Builder $schema) {
$schema->table('email_tokens', function (Blueprint $table) {
$table->dateTime('created_at')->change();
});
// do this manually because dbal doesn't recognize timestamp columns
$connection = $schema->getConnection();
$prefix = $connection->getTablePrefix();
$connection->statement("ALTER TABLE {$prefix}email_tokens MODIFY created_at DATETIME");
},
'down' => function (Builder $schema) {
$schema->table('email_tokens', function (Blueprint $table) {
$table->timestamp('created_at')->change();
});
$connection = $schema->getConnection();
$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 [
'up' => function (Builder $schema) {
$schema->table('password_tokens', function (Blueprint $table) {
$table->dateTime('created_at')->change();
});
// do this manually because dbal doesn't recognize timestamp columns
$connection = $schema->getConnection();
$prefix = $connection->getTablePrefix();
$connection->statement("ALTER TABLE {$prefix}password_tokens MODIFY created_at DATETIME");
},
'down' => function (Builder $schema) {
$schema->table('password_tokens', function (Blueprint $table) {
$table->timestamp('created_at')->change();
});
$connection = $schema->getConnection();
$prefix = $connection->getTablePrefix();
$connection->statement("ALTER TABLE {$prefix}password_tokens MODIFY created_at TIMESTAMP");
}
];