Add database migrations
This commit is contained in:
parent
278abdbcfa
commit
36c66c75fb
5 changed files with 110 additions and 12 deletions
|
@ -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');
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -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');
|
||||||
|
}
|
||||||
|
};
|
|
@ -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');
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -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');
|
||||||
|
}
|
||||||
|
};
|
|
@ -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
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue