Add database migrations

This commit is contained in:
floppydiskette 2024-01-31 21:17:56 +00:00
parent 278abdbcfa
commit 36c66c75fb
Signed by: fwoppydwisk
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
5 changed files with 110 additions and 12 deletions

View file

@ -11,13 +11,10 @@
*/ */
public function up(): void public function up(): void
{ {
Schema::create('users', function (Blueprint $table) { Schema::create('bookmark__categories', function (Blueprint $table) {
$table->id(); $table->increments('id');
$table->string('name'); $table->string('name');
$table->string('email')->unique(); $table->float('priority');
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps(); $table->timestamps();
}); });
} }
@ -27,6 +24,6 @@ public function up(): void
*/ */
public function down(): void public function down(): void
{ {
Schema::dropIfExists('users'); Schema::dropIfExists('bookmark__categories');
} }
}; };

View file

@ -0,0 +1,33 @@
<?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('bookmark__sites', function (Blueprint $table) {
$table->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');
}
};

View file

@ -11,10 +11,11 @@
*/ */
public function up(): void public function up(): void
{ {
Schema::create('password_reset_tokens', function (Blueprint $table) { Schema::create('guestbook__bans', function (Blueprint $table) {
$table->string('email')->primary(); $table->increments('id');
$table->string('token'); $table->string('ip_address', 40);
$table->timestamp('created_at')->nullable(); $table->string('reason', 50);
$table->timestamps();
}); });
} }
@ -23,6 +24,6 @@ public function up(): void
*/ */
public function down(): void public function down(): void
{ {
Schema::dropIfExists('password_reset_tokens'); Schema::dropIfExists('guestbook__bans');
} }
}; };

View file

@ -0,0 +1,33 @@
<?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('guestbook__entries', function (Blueprint $table) {
$table->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');
}
};

View file

@ -0,0 +1,34 @@
<?php
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.
*/
public function up(): void
{
// Check if table exists and is empty
if (Schema::hasTable('bookmark__categories') && DB::table('bookmark__categories')->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
{
//
}
};