mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-10-26 11:11:56 +00:00
DB: Planned out new entity table format via migrations
This commit is contained in:
parent
08dfff05f4
commit
50b147c632
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('entities', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('type', 10);
|
||||
$table->string('slug', 191);
|
||||
|
||||
$table->unsignedBigInteger('book_id')->nullable()->index();
|
||||
$table->unsignedInteger('priority')->nullable();
|
||||
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable()->index();
|
||||
$table->timestamp('deleted_at')->nullable()->index();
|
||||
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->unsignedInteger('updated_by')->nullable();
|
||||
$table->unsignedInteger('owned_by')->nullable()->index();
|
||||
|
||||
$table->primary(['id', 'type'], 'entities_pk');
|
||||
});
|
||||
|
||||
Schema::create('entity_container_data', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('entity_id');
|
||||
$table->string('type', 10);
|
||||
$table->text('description');
|
||||
$table->text('description_html');
|
||||
|
||||
$table->unsignedBigInteger('default_template_id')->nullable();
|
||||
$table->unsignedInteger('image_id')->nullable();
|
||||
$table->unsignedInteger('sort_rule_id')->nullable();
|
||||
|
||||
$table->primary(['entity_id', 'type'], 'entity_container_data_pk');
|
||||
});
|
||||
|
||||
Schema::table('entity_page_data', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('page_id')->primary();
|
||||
$table->unsignedBigInteger('chapter_id')->index();
|
||||
|
||||
$table->boolean('draft')->index();
|
||||
$table->boolean('template')->index();
|
||||
$table->unsignedInteger('revision_count');
|
||||
$table->string('editor', 50);
|
||||
|
||||
$table->longText('html');
|
||||
$table->longText('text');
|
||||
$table->longText('markdown');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('entities');
|
||||
Schema::dropIfExists('entity_container_data');
|
||||
Schema::dropIfExists('entity_page_data');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Migrate main data
|
||||
|
||||
// Fix up data (zeros to nulls, missing relations to nulls, etc)
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
107
database/migrations/2025_09_15_134813_drop_old_entity_tables.php
Normal file
107
database/migrations/2025_09_15_134813_drop_old_entity_tables.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::dropIfExists('pages');
|
||||
Schema::dropIfExists('chapters');
|
||||
Schema::dropIfExists('books');
|
||||
Schema::dropIfExists('bookshelves');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::create('pages', function (Blueprint $table) {
|
||||
$table->unsignedInteger('id', true)->primary();
|
||||
$table->integer('book_id')->index();
|
||||
$table->integer('chapter_id')->index();
|
||||
$table->string('name');
|
||||
$table->string('slug')->index();
|
||||
$table->longText('html');
|
||||
$table->longText('text');
|
||||
$table->integer('priority')->index();
|
||||
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable()->index();
|
||||
$table->integer('created_by')->index();
|
||||
$table->integer('updated_by')->index();
|
||||
|
||||
$table->boolean('draft')->default(0)->index();
|
||||
$table->longText('markdown');
|
||||
$table->integer('revision_count');
|
||||
$table->boolean('template')->default(0)->index();
|
||||
$table->timestamp('deleted_at')->nullable();
|
||||
|
||||
$table->unsignedInteger('owned_by')->index();
|
||||
$table->string('editor', 50)->default('');
|
||||
});
|
||||
|
||||
Schema::table('chapters', function (Blueprint $table) {
|
||||
$table->unsignedInteger('id', true)->primary();
|
||||
$table->integer('book_id')->index();
|
||||
$table->string('slug')->index();
|
||||
$table->text('name');
|
||||
$table->text('description');
|
||||
$table->integer('priority')->index();
|
||||
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
$table->integer('created_by')->index();
|
||||
$table->integer('updated_by')->index();
|
||||
|
||||
$table->timestamp('deleted_at')->nullable();
|
||||
$table->unsignedInteger('owned_by')->index();
|
||||
$table->text('description_html');
|
||||
$table->integer('default_template_id')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('books', function (Blueprint $table) {
|
||||
$table->unsignedInteger('id', true)->primary();
|
||||
$table->string('name');
|
||||
$table->string('slug')->index();
|
||||
$table->text('description');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
|
||||
$table->integer('created_by')->index();
|
||||
$table->integer('updated_by')->index();
|
||||
|
||||
$table->integer('image_id')->nullable();
|
||||
$table->timestamp('deleted_at')->nullable();
|
||||
$table->unsignedInteger('owned_by')->index();
|
||||
|
||||
$table->integer('default_template_id')->nullable();
|
||||
$table->text('description_html');
|
||||
$table->unsignedInteger('sort_rule_id')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('bookshelves', function (Blueprint $table) {
|
||||
$table->unsignedInteger('id', true)->primary();
|
||||
$table->string('name', 180);
|
||||
$table->string('slug', 180)->index();
|
||||
$table->text('description');
|
||||
|
||||
$table->integer('created_by')->index();
|
||||
$table->integer('updated_by')->index();
|
||||
$table->integer('image_id')->nullable();
|
||||
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
$table->timestamp('deleted_at')->nullable();
|
||||
|
||||
$table->unsignedInteger('owned_by')->index();
|
||||
$table->text('description_html');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user