🔥 Add initial database migrations, seeders, and factories

🎨 Refactor `Lecturer` model to include new fields and factory usage
🔧 Update `DatabaseSeeder` to handle default seeds
🛠️ Enhance `einundzwanzig` database configuration for SQLite compatibility
This commit is contained in:
BT
2026-05-02 17:17:13 +01:00
parent 04abf231bd
commit cb61d9d543
54 changed files with 1975 additions and 417 deletions
@@ -0,0 +1,24 @@
<?php
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('countries', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code', 8)->unique();
$table->json('language_codes')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('countries');
}
};
@@ -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
{
public function up(): void
{
Schema::create('cities', function (Blueprint $table) {
$table->id();
$table->foreignId('country_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('slug')->nullable()->index();
$table->decimal('latitude', 10, 7)->nullable();
$table->decimal('longitude', 10, 7)->nullable();
$table->json('osm_relation')->nullable();
$table->json('simplified_geojson')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('cities');
}
};
@@ -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
{
public function up(): void
{
Schema::create('lecturers', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->nullable()->index();
$table->text('bio')->nullable();
$table->string('npub', 63)->nullable()->index();
$table->string('pubkey', 64)->nullable()->index();
$table->string('website')->nullable();
$table->boolean('active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('lecturers');
}
};
@@ -0,0 +1,22 @@
<?php
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('categories', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('categories');
}
};
@@ -0,0 +1,30 @@
<?php
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('meetups', function (Blueprint $table) {
$table->id();
$table->foreignId('city_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('slug')->nullable()->index();
$table->text('description')->nullable();
$table->string('website')->nullable();
$table->string('nostr_pubkey', 64)->nullable();
$table->json('github_data')->nullable();
$table->json('simplified_geojson')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('meetups');
}
};
@@ -0,0 +1,30 @@
<?php
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('meetup_events', function (Blueprint $table) {
$table->id();
$table->foreignId('meetup_id')->constrained()->cascadeOnDelete();
$table->timestamp('start');
$table->string('location')->nullable();
$table->text('description')->nullable();
$table->string('link')->nullable();
$table->json('attendees')->nullable();
$table->json('might_attendees')->nullable();
$table->string('nostr_status')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('meetup_events');
}
};
@@ -0,0 +1,28 @@
<?php
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('venues', function (Blueprint $table) {
$table->id();
$table->foreignId('city_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('slug')->nullable()->index();
$table->text('description')->nullable();
$table->string('address')->nullable();
$table->string('website')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('venues');
}
};
@@ -0,0 +1,27 @@
<?php
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('courses', function (Blueprint $table) {
$table->id();
$table->foreignId('lecturer_id')->nullable()->constrained()->nullOnDelete();
$table->string('name');
$table->string('slug')->nullable()->index();
$table->text('description')->nullable();
$table->unsignedInteger('duration_minutes')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('courses');
}
};
@@ -0,0 +1,26 @@
<?php
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('course_events', function (Blueprint $table) {
$table->id();
$table->foreignId('course_id')->constrained()->cascadeOnDelete();
$table->foreignId('venue_id')->nullable()->constrained()->nullOnDelete();
$table->timestamp('from');
$table->timestamp('to')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('course_events');
}
};
@@ -0,0 +1,22 @@
<?php
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('category_course', function (Blueprint $table) {
$table->foreignId('category_id')->constrained()->cascadeOnDelete();
$table->foreignId('course_id')->constrained()->cascadeOnDelete();
$table->primary(['category_id', 'course_id']);
});
}
public function down(): void
{
Schema::dropIfExists('category_course');
}
};
@@ -0,0 +1,22 @@
<?php
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('meetup_user', function (Blueprint $table) {
$table->foreignId('meetup_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->primary(['meetup_id', 'user_id']);
});
}
public function down(): void
{
Schema::dropIfExists('meetup_user');
}
};