1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Merge pull request #10 from BookStackApp/master

Latest changes
This commit is contained in:
Abijeet Patro
2017-05-03 01:41:08 +05:30
committed by GitHub
38 changed files with 680 additions and 432 deletions

View File

@ -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
];
});

View File

@ -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');
});
}
}

View File

@ -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();
}