mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
@ -43,7 +43,8 @@ $factory->define(BookStack\Page::class, function ($faker) {
|
||||
'name' => $faker->sentence,
|
||||
'slug' => str_random(10),
|
||||
'html' => $html,
|
||||
'text' => strip_tags($html)
|
||||
'text' => strip_tags($html),
|
||||
'revision_count' => 1
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddRevisionCounts extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('pages', function (Blueprint $table) {
|
||||
$table->integer('revision_count');
|
||||
});
|
||||
Schema::table('page_revisions', function (Blueprint $table) {
|
||||
$table->integer('revision_number');
|
||||
$table->index('revision_number');
|
||||
});
|
||||
|
||||
// Update revision count
|
||||
$pTable = DB::getTablePrefix() . 'pages';
|
||||
$rTable = DB::getTablePrefix() . 'page_revisions';
|
||||
DB::statement("UPDATE ${pTable} SET ${pTable}.revision_count=(SELECT count(*) FROM ${rTable} WHERE ${rTable}.page_id=${pTable}.id)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('pages', function (Blueprint $table) {
|
||||
$table->dropColumn('revision_count');
|
||||
});
|
||||
Schema::table('page_revisions', function (Blueprint $table) {
|
||||
$table->dropColumn('revision_number');
|
||||
});
|
||||
}
|
||||
}
|
@ -28,6 +28,12 @@ class DummyContentSeeder extends Seeder
|
||||
$book->pages()->saveMany($pages);
|
||||
});
|
||||
|
||||
$largeBook = factory(\BookStack\Book::class)->create(['name' => 'Large book' . str_random(10), 'created_by' => $user->id, 'updated_by' => $user->id]);
|
||||
$pages = factory(\BookStack\Page::class, 200)->make(['created_by' => $user->id, 'updated_by' => $user->id]);
|
||||
$chapters = factory(\BookStack\Chapter::class, 50)->make(['created_by' => $user->id, 'updated_by' => $user->id]);
|
||||
$largeBook->pages()->saveMany($pages);
|
||||
$largeBook->chapters()->saveMany($chapters);
|
||||
|
||||
app(\BookStack\Services\PermissionService::class)->buildJointPermissions();
|
||||
app(\BookStack\Services\SearchService::class)->indexAllEntities();
|
||||
}
|
||||
|
Reference in New Issue
Block a user