From 36c66c75fb6fd72dfb36e4e9b9b8c332737aeb1d Mon Sep 17 00:00:00 2001 From: Frankie B Date: Wed, 31 Jan 2024 21:17:56 +0000 Subject: [PATCH] Add database migrations --- ...730_create_bookmark__categories_table.php} | 11 +++--- ...31_204742_create_bookmark__sites_table.php | 33 ++++++++++++++++++ ...1_204815_create_guestbook__bans_table.php} | 11 +++--- ...204820_create_guestbook__entries_table.php | 33 ++++++++++++++++++ ...27_populate_bookmark__categories_table.php | 34 +++++++++++++++++++ 5 files changed, 110 insertions(+), 12 deletions(-) rename database/migrations/{2014_10_12_000000_create_users_table.php => 2024_01_31_204730_create_bookmark__categories_table.php} (58%) create mode 100644 database/migrations/2024_01_31_204742_create_bookmark__sites_table.php rename database/migrations/{2014_10_12_100000_create_password_reset_tokens_table.php => 2024_01_31_204815_create_guestbook__bans_table.php} (56%) create mode 100644 database/migrations/2024_01_31_204820_create_guestbook__entries_table.php create mode 100644 database/migrations/2024_01_31_210227_populate_bookmark__categories_table.php diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2024_01_31_204730_create_bookmark__categories_table.php similarity index 58% rename from database/migrations/2014_10_12_000000_create_users_table.php rename to database/migrations/2024_01_31_204730_create_bookmark__categories_table.php index 444fafb..68bf949 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2024_01_31_204730_create_bookmark__categories_table.php @@ -11,13 +11,10 @@ */ public function up(): void { - Schema::create('users', function (Blueprint $table) { - $table->id(); + Schema::create('bookmark__categories', function (Blueprint $table) { + $table->increments('id'); $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); + $table->float('priority'); $table->timestamps(); }); } @@ -27,6 +24,6 @@ public function up(): void */ public function down(): void { - Schema::dropIfExists('users'); + Schema::dropIfExists('bookmark__categories'); } }; diff --git a/database/migrations/2024_01_31_204742_create_bookmark__sites_table.php b/database/migrations/2024_01_31_204742_create_bookmark__sites_table.php new file mode 100644 index 0000000..775c6bb --- /dev/null +++ b/database/migrations/2024_01_31_204742_create_bookmark__sites_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->string('name', 50); + $table->string('description', 150); + $table->string('url', 100); + $table->float('priority'); + $table->integer('category_id')->unsigned(); + $table->foreign('category_id')->references('id')->on('bookmark__categories'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('bookmark__sites'); + } +}; diff --git a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php b/database/migrations/2024_01_31_204815_create_guestbook__bans_table.php similarity index 56% rename from database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php rename to database/migrations/2024_01_31_204815_create_guestbook__bans_table.php index 81a7229..6f0a959 100644 --- a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php +++ b/database/migrations/2024_01_31_204815_create_guestbook__bans_table.php @@ -11,10 +11,11 @@ */ public function up(): void { - Schema::create('password_reset_tokens', function (Blueprint $table) { - $table->string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); + Schema::create('guestbook__bans', function (Blueprint $table) { + $table->increments('id'); + $table->string('ip_address', 40); + $table->string('reason', 50); + $table->timestamps(); }); } @@ -23,6 +24,6 @@ public function up(): void */ public function down(): void { - Schema::dropIfExists('password_reset_tokens'); + Schema::dropIfExists('guestbook__bans'); } }; diff --git a/database/migrations/2024_01_31_204820_create_guestbook__entries_table.php b/database/migrations/2024_01_31_204820_create_guestbook__entries_table.php new file mode 100644 index 0000000..baaf862 --- /dev/null +++ b/database/migrations/2024_01_31_204820_create_guestbook__entries_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->string('name', 255); + $table->bigInteger('timestamp'); + $table->string('ip_address', 40); + $table->string('agent', 2048)->default('Agent unavailable'); + $table->boolean('site_owner')->default(0); + $table->string('message', 512); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('guestbook__entries'); + } +}; diff --git a/database/migrations/2024_01_31_210227_populate_bookmark__categories_table.php b/database/migrations/2024_01_31_210227_populate_bookmark__categories_table.php new file mode 100644 index 0000000..fb81e1f --- /dev/null +++ b/database/migrations/2024_01_31_210227_populate_bookmark__categories_table.php @@ -0,0 +1,34 @@ +count() == 0) { + // Insert placeholder categories + DB::table('bookmark__categories')->insert([ + ['name' => 'Friends\' Websites', 'priority' => 1], + ['name' => 'Cool Projects', 'priority' => 2], + ['name' => 'Other Cool Sites', 'priority' => 3], + ['name' => 'Miscellaneous Resources', 'priority' => 4] + ]); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +};