Also updated code to properly import used facades.
For #4903
<?php
+use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
'name' => 'Admin',
'password' => bcrypt('password'),
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
}
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('users');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('password_resets');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('books', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('books');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('pages', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('pages');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('images', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('images');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('chapters', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('chapters');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->integer('created_by');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->dropColumn('created_by');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('page_revisions', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('page_revisions');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('activities', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('activities');
}
* @url https://github.com/Zizaco/entrust
*/
+use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Create table for storing roles
Schema::create('roles', function (Blueprint $table) {
'name' => 'admin',
'display_name' => 'Admin',
'description' => 'Administrator of the whole application',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
$editorId = DB::table('roles')->insertGetId([
'name' => 'editor',
'display_name' => 'Editor',
'description' => 'User can edit Books, Chapters & Pages',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
$viewerId = DB::table('roles')->insertGetId([
'name' => 'viewer',
'display_name' => 'Viewer',
'description' => 'User can view books & their content behind authentication',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
// Create default CRUD permissions and allocate to admins and editors
$newPermId = DB::table('permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower($op),
'display_name' => $op . ' ' . $entity . 's',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
DB::table('permission_role')->insert([
['permission_id' => $newPermId, 'role_id' => $adminId],
$newPermId = DB::table('permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower($op),
'display_name' => $op . ' ' . $entity,
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
DB::table('permission_role')->insert([
'permission_id' => $newPermId,
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('permission_role');
Schema::drop('permissions');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('settings', function (Blueprint $table) {
$table->string('setting_key')->primary()->indexed();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('settings');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
$sm = Schema::getConnection()->getDoctrineSchemaManager();
$pages = $sm->listTableDetails('pages');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('social_accounts', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('social_accounts');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('email_confirmed')->default(true);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('email_confirmed');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('views', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('views');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('books', function (Blueprint $table) {
$table->index('slug');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('books', function (Blueprint $table) {
$table->dropIndex('books_slug_index');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
$sm = Schema::getConnection()->getDoctrineSchemaManager();
$pages = $sm->listTableDetails('pages');
use BookStack\Uploads\Image;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('images', function (Blueprint $table) {
$table->string('path', 400);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('images', function (Blueprint $table) {
$table->dropColumn('type');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->integer('image_id')->default(0);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('image_id');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('external_auth_id')->index();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('external_auth_id');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('page_revisions', function (Blueprint $table) {
$table->string('slug');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('page_revisions', function (Blueprint $table) {
$table->dropColumn('slug');
<?php
+use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Get roles with permissions we need to change
$adminRoleId = DB::table('roles')->where('name', '=', 'admin')->first()->id;
$permissionId = DB::table('permissions')->insertGetId([
'name' => $name,
'display_name' => $displayName,
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
DB::table('permission_role')->insert([
'role_id' => $adminRoleId,
$permissionId = DB::table('permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
'display_name' => $op . ' ' . $entity . 's',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
DB::table('permission_role')->insert([
'role_id' => $adminRoleId,
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
// Get roles with permissions we need to change
$adminRoleId = DB::table('roles')->where('name', '=', 'admin')->first()->id;
$permissionId = DB::table('permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower($op),
'display_name' => $op . ' ' . $entity . 's',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
DB::table('permission_role')->insert([
'role_id' => $adminRoleId,
$permissionId = DB::table('permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower($op),
'display_name' => $op . ' ' . $entity,
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
DB::table('permission_role')->insert([
'role_id' => $adminRoleId,
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('images', function (Blueprint $table) {
$table->integer('uploaded_to')->default(0);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('images', function (Blueprint $table) {
$table->dropColumn('uploaded_to');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('page_revisions', function (Blueprint $table) {
$table->string('type')->default('version');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('page_revisions', function (Blueprint $table) {
$table->dropColumn('type');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->boolean('draft')->default(false);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->dropColumn('draft');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->longText('markdown')->default('');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->dropColumn('markdown');
<?php
+use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
$currentRoles = DB::table('roles')->get();
$permId = DB::table('permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
'display_name' => $op . ' ' . $entity . 's',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
// Assign view permission to all current roles
foreach ($currentRoles as $role) {
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
// Delete the new view permission
$entities = ['Book', 'Page', 'Chapter'];
<?php
+use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('joint_permissions', function (Blueprint $table) {
$table->increments('id');
'description' => 'The role given to public visitors if allowed',
'system_name' => 'public',
'hidden' => true,
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
];
// Ensure unique name
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('joint_permissions');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('tags', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::drop('tags');
}
<?php
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('page_revisions', function ($table) {
$table->string('summary')->nullable();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('page_revisions', function ($table) {
$table->dropColumn('summary');
<?php
+use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Remove the hidden property from roles
Schema::table('roles', function (Blueprint $table) {
'name' => 'Guest',
'system_name' => 'public',
'email_confirmed' => true,
- 'created_at' => \Carbon\Carbon::now(),
- 'updated_at' => \Carbon\Carbon::now(),
+ 'created_at' => Carbon::now(),
+ 'updated_at' => Carbon::now(),
]);
// Get the public role
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('roles', function (Blueprint $table) {
$table->boolean('hidden')->default(false);
<?php
+use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('attachments', function (Blueprint $table) {
$table->increments('id');
$permissionId = DB::table('role_permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
'display_name' => $op . ' ' . $entity . 's',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
DB::table('permission_role')->insert([
'role_id' => $adminRoleId,
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('attachments');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->unique();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('cache');
}
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->unique();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('sessions');
}
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('search_terms', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
// This was removed for v0.24 since these indexes are removed anyway
// and will cause issues for db engines that don't support such indexes.
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->integer('revision_count');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->dropColumn('revision_count');
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
<?php
+use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('comments', function (Blueprint $table) {
$table->increments('id')->unsigned();
$permissionId = DB::table('role_permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
'display_name' => $op . ' ' . $entity . 's',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
DB::table('permission_role')->insert([
'role_id' => $adminRoleId,
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('comments');
// Delete comment role permissions
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('books', function (Blueprint $table) {
$table->integer('image_id')->nullable()->default(null);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('books', function (Blueprint $table) {
$table->dropColumn('image_id');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('roles', function (Blueprint $table) {
$table->string('external_auth_id', 180)->default('');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('roles', function (Blueprint $table) {
$table->dropColumn('external_auth_id');
<?php
+use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Convert the existing entity tables to InnoDB.
$permId = DB::table('role_permissions')->insertGetId([
'name' => 'bookshelf-' . $dbOpName,
'display_name' => $op . ' ' . 'BookShelves',
- 'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
- 'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
+ 'created_at' => Carbon::now()->toDateTimeString(),
+ 'updated_at' => Carbon::now()->toDateTimeString(),
]);
$rowsToInsert = $roleIdsWithBookPermission->filter(function ($roleId) {
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
// Drop created permissions
$ops = ['bookshelf-create-all', 'bookshelf-create-own', 'bookshelf-delete-all', 'bookshelf-delete-own', 'bookshelf-update-all', 'bookshelf-update-own', 'bookshelf-view-all', 'bookshelf-view-own'];
use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->boolean('template')->default(false);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->dropColumn('template');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('user_invites', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('user_invites');
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Add API tokens table
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
// Remove API tokens table
Schema::dropIfExists('api_tokens');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('joint_permissions', function (Blueprint $table) {
$table->dropColumn('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('joint_permissions', function (Blueprint $table) {
$table->dropPrimary(['role_id', 'entity_type', 'entity_id', 'action']);
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('roles', function (Blueprint $table) {
$table->dropColumn('name');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('roles', function (Blueprint $table) {
$table->string('name')->index();
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('activities', function (Blueprint $table) {
$table->index('key');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('activities', function (Blueprint $table) {
$table->dropIndex('activities_key_index');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('bookshelves', function (Blueprint $table) {
$table->softDeletes();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('bookshelves', function (Blueprint $table) {
$table->dropSoftDeletes();
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('deletions', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('deletions');
}
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('activities', function (Blueprint $table) {
$table->renameColumn('key', 'type');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
DB::table('activities')
->whereNull('entity_id')
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
$tables = ['pages', 'books', 'chapters', 'bookshelves'];
foreach ($tables as $table) {
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
$tables = ['pages', 'books', 'chapters', 'bookshelves'];
foreach ($tables as $table) {
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('settings', function (Blueprint $table) {
$table->string('type', 50)->default('string');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('type');
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('slug', 180);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('slug');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('favourites', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('favourites');
}
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('mfa_values', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('mfa_values');
}
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('roles', function (Blueprint $table) {
$table->boolean('mfa_enforced');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('roles', function (Blueprint $table) {
$table->dropColumn('mfa_enforced');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Create new templates-manage permission and assign to admin role
$roles = DB::table('roles')->get('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
// Remove content-export permission
$contentExportPermission = DB::table('role_permissions')
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('activities', function (Blueprint $table) {
$table->string('ip', 45)->after('user_id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('activities', function (Blueprint $table) {
$table->dropColumn('ip');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('activities', function (Blueprint $table) {
$table->index('ip', 'activities_ip_index');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('activities', function (Blueprint $table) {
$table->dropIndex('activities_ip_index');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('webhooks', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('webhooks');
Schema::dropIfExists('webhook_tracked_events');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('jobs');
}
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('webhooks', function (Blueprint $table) {
$table->unsignedInteger('timeout')->default(3);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('webhooks', function (Blueprint $table) {
$table->dropColumn('timeout');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Add the new 'editor' column to the pages table
Schema::table('pages', function (Blueprint $table) {
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
// Drop the new column from the pages table
Schema::table('pages', function (Blueprint $table) {
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
foreach ($this->columnsByTable as $table => $column) {
foreach ($this->changeMap as $oldVal => $newVal) {
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
foreach ($this->columnsByTable as $table => $column) {
foreach ($this->changeMap as $oldVal => $newVal) {
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
DB::table('joint_permissions')
->where('action', '!=', 'view')
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('joint_permissions', function (Blueprint $table) {
$table->string('action');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('references', function (Blueprint $table) {
$table->id();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('references');
}
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// This updates the 'type' field for images, uploaded as shelf cover images,
// to be cover_bookshelf instead of cover_book.
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
DB::table('images')
->where('type', '=', 'cover_bookshelf')
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Remove entries for non-existing roles (Caused by previous lack of deletion handling)
$roleIds = DB::table('roles')->pluck('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
// Create old table structure for entity_permissions
Schema::create('old_entity_permissions', function (Blueprint $table) {
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Remove entity-permissions on non-restricted entities
$deleteInactiveEntityPermissions = function (string $table, string $morphClass) {
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
// Create restricted columns
$createRestrictedColumn = fn(Blueprint $table) => $table->boolean('restricted')->index()->default(0);
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Truncate before schema changes to avoid performance issues
// since we'll need to rebuild anyway.
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
DB::table('joint_permissions')->truncate();
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
$colorSettings = [
'app-color',
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
$colorSettings = [
'app-color-dark',
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('attachments', function (Blueprint $table) {
$table->text('path')->change();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('attachments', function (Blueprint $table) {
$table->string('path')->change();
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->index('updated_at', 'pages_updated_at_index');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->dropIndex('pages_updated_at_index');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
$guestUserId = DB::table('users')
->where('system_name', '=', 'public')
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
// Create new receive-notifications permission and assign to admin role
$permissionId = DB::table('role_permissions')->insertGetId([
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
$permission = DB::table('role_permissions')
->where('name', '=', 'receive-notifications')
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::create('watches', function (Blueprint $table) {
$table->increments('id');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists('watches');
}
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('cache', function (Blueprint $table) {
$table->mediumText('value')->change();
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('cache', function (Blueprint $table) {
$table->text('value')->change();
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('books', function (Blueprint $table) {
$table->integer('default_template_id')->nullable()->default(null);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('books', function (Blueprint $table) {
$table->dropColumn('default_template_id');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
$addColumn = fn(Blueprint $table) => $table->text('description_html');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
$removeColumn = fn(Blueprint $table) => $table->removeColumn('description_html');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('chapters', function (Blueprint $table) {
$table->integer('default_template_id')->nullable()->default(null);
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('chapters', function (Blueprint $table) {
$table->dropColumn('default_template_id');
{
/**
* Run the migrations.
- *
- * @return void
*/
- public function up()
+ public function up(): void
{
Schema::table('views', function (Blueprint $table) {
$table->index(['updated_at'], 'views_updated_at_index');
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
+ public function down(): void
{
Schema::table('views', function (Blueprint $table) {
$table->dropIndex('views_updated_at_index');