diff options
| author | grothedev <grothedev@gmail.com> | 2025-02-09 16:43:16 -0600 |
|---|---|---|
| committer | grothedev <grothedev@gmail.com> | 2025-02-09 16:43:16 -0600 |
| commit | 0cf66873255ecc1c7738c92525a632ff6e58d376 (patch) | |
| tree | 559dbeba4cf17a551208cee3816815936a10c84b /database | |
| parent | 8b45b1fb9532643effc796acb5ed5bfb6431bfb7 (diff) | |
working on a little writing thing
Diffstat (limited to 'database')
| -rw-r--r-- | database/migrations/2024_12_21_032114_pivots.php | 6 | ||||
| -rw-r--r-- | database/migrations/2025_02_05_004055_create_roles_table.php | 29 | ||||
| -rw-r--r-- | database/migrations/2025_02_09_040949_writings.php | 31 |
3 files changed, 66 insertions, 0 deletions
diff --git a/database/migrations/2024_12_21_032114_pivots.php b/database/migrations/2024_12_21_032114_pivots.php index df65191..f4916f6 100644 --- a/database/migrations/2024_12_21_032114_pivots.php +++ b/database/migrations/2024_12_21_032114_pivots.php @@ -30,6 +30,12 @@ return new class extends Migration $table->integer('tag_id')->unsigned()->index(); $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); }); + Schema::create('user_role', function (Blueprint $table) { + $table->integer('user_id')->unsigned()->index(); + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $table->integer('role_id')->unsigned()->index(); + $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); + }); } /** diff --git a/database/migrations/2025_02_05_004055_create_roles_table.php b/database/migrations/2025_02_05_004055_create_roles_table.php new file mode 100644 index 0000000..9e33dc2 --- /dev/null +++ b/database/migrations/2025_02_05_004055_create_roles_table.php @@ -0,0 +1,29 @@ +<?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('roles', function (Blueprint $table) { + $table->id(); + $table->timestamps(); + $table->string('name')->unique(); + $table->string('description')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('roles'); + } +}; diff --git a/database/migrations/2025_02_09_040949_writings.php b/database/migrations/2025_02_09_040949_writings.php new file mode 100644 index 0000000..bc5de2a --- /dev/null +++ b/database/migrations/2025_02_09_040949_writings.php @@ -0,0 +1,31 @@ +<?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('writings', function (Blueprint $table) { + $table->id(); + $table->timestamps(); + $table->string('title'); + $table->string('content')->required(); + $table->integer('user_id')->unsigned()->index(); + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('writings'); + } +}; |
