1
0
mirror of https://github.com/flarum/core.git synced 2025-02-24 11:13:40 +01:00
php-flarum/migrations/2018_01_18_133000_change_notifications_columns.php
Toby Zerner aa4c4b07bd Revert notifications_from table
I didn't think this change through and it's going to be too difficult
to implement right now. It can wait until we do the notifications
revamp. For now reverting back to the old structure, with the
`sender_id` column renamed to `from_user_id`.
2018-07-21 18:35:50 +09:30

55 lines
1.5 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Carbon\Carbon;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
return [
'up' => function (Builder $schema) {
$schema->table('notifications', function (Blueprint $table) {
$table->dropColumn('subject_type');
$table->renameColumn('time', 'created_at');
$table->renameColumn('sender_id', 'from_user_id');
$table->dateTime('read_at')->nullable();
});
$schema->getConnection()->table('notifications')
->where('is_read', 1)
->update(['read_at' => Carbon::now()]);
$schema->table('notifications', function (Blueprint $table) {
$table->dropColumn('is_read');
});
},
'down' => function (Builder $schema) {
$schema->table('notifications', function (Blueprint $table) {
$table->string('subject_type', 200)->nullable();
$table->renameColumn('created_at', 'time');
$table->renameColumn('from_user_id', 'sender_id');
$table->boolean('is_read');
});
$schema->getConnection()->table('notifications')
->whereNotNull('read_at')
->update(['is_read' => 1]);
$schema->table('notifications', function (Blueprint $table) {
$table->dropColumn('read_at');
});
}
];