mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-01 06:59:52 +00:00
Updated activities table format
Renamed some columns to be more generic and applicable. Removed now redundant book_id column. Allowed nullable entity morph columns for non-entity activity. Ran tests and made required changes.
This commit is contained in:
parent
ee7e1122d3
commit
712ccd23c4
12 changed files with 106 additions and 50 deletions
database/migrations
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SimplifyActivitiesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('activities', function (Blueprint $table) {
|
||||
$table->renameColumn('key', 'type');
|
||||
$table->renameColumn('extra', 'detail');
|
||||
$table->dropColumn('book_id');
|
||||
$table->integer('entity_id')->nullable()->change();
|
||||
$table->string('entity_type', 191)->nullable()->change();
|
||||
});
|
||||
|
||||
DB::table('activities')
|
||||
->where('entity_id', '=', 0)
|
||||
->update([
|
||||
'entity_id' => null,
|
||||
'entity_type' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
DB::table('activities')
|
||||
->whereNull('entity_id')
|
||||
->update([
|
||||
'entity_id' => 0,
|
||||
'entity_type' => '',
|
||||
]);
|
||||
|
||||
Schema::table('activities', function (Blueprint $table) {
|
||||
$table->renameColumn('type', 'key');
|
||||
$table->renameColumn('detail', 'extra');
|
||||
$table->integer('book_id');
|
||||
|
||||
$table->integer('entity_id')->change();
|
||||
$table->string('entity_type', 191)->change();
|
||||
|
||||
$table->index('book_id');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue