feat: Board, BoardColumn, Card, User tables
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('users', function (Blueprint $table): void {
|
||||
$table->increments('user_id');
|
||||
$table->string('email', 255);
|
||||
$table->string('password_hash', 255);
|
||||
$table->string('name', 255);
|
||||
$table->timestamp('created_datetime')->useCurrent();
|
||||
$table->timestamp('updated_datetime')->nullable();
|
||||
|
||||
$table->unique('email', 'idx_email');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('boards', function (Blueprint $table): void {
|
||||
$table->increments('board_id');
|
||||
$table->string('title', 255);
|
||||
$table->integer('owner_user_id');
|
||||
$table->boolean('is_public')->default(false);
|
||||
$table->timestamp('created_datetime')->useCurrent();
|
||||
$table->timestamp('updated_datetime')->nullable();
|
||||
|
||||
$table->foreign('owner_user_id')
|
||||
->references('user_id')
|
||||
->on('users')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('boards');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('board_columns', function (Blueprint $table): void {
|
||||
$table->increments('column_id');
|
||||
$table->integer('board_id');
|
||||
$table->smallInteger('ordinal_position');
|
||||
$table->string('title', 255);
|
||||
$table->string('color', 6)->nullable();
|
||||
|
||||
$table->index('board_id', 'idx_board_id');
|
||||
|
||||
$table->foreign('board_id')
|
||||
->references('board_id')
|
||||
->on('boards')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('board_columns');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
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 {
|
||||
public function up(): void {
|
||||
Schema::create('cards', function (Blueprint $table): void {
|
||||
$table->increments('card_id');
|
||||
$table->integer('board_id');
|
||||
$table->integer('column_id');
|
||||
$table->smallInteger('sort_index');
|
||||
$table->string('title', 255);
|
||||
$table->text('content')->nullable();
|
||||
$table->string('color', 6)->nullable();
|
||||
$table->boolean('is_archived')->default(false);
|
||||
$table->timestamp('created_datetime')->useCurrent();
|
||||
$table->timestamp('updated_datetime')->nullable();
|
||||
|
||||
$table->foreign('board_id')
|
||||
->references('board_id')
|
||||
->on('boards')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('column_id')
|
||||
->references('column_id')
|
||||
->on('board_columns')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
|
||||
DB::statement('create index "idx_active_board_id" on "cards" ("board_id") where "is_archived" = false');
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('cards');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user