130 lines
5.2 KiB
PHP
130 lines
5.2 KiB
PHP
<?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('businesses', function (Blueprint $t) {
|
|
$t->ulid('id')->primary();
|
|
$t->string('name');
|
|
$t->string('slug')->unique();
|
|
$t->text('description')->nullable();
|
|
$t->string('email')->nullable();
|
|
$t->string('phone')->nullable();
|
|
$t->string('website')->nullable();
|
|
$t->string('status')->default('active');
|
|
$t->timestamp('verified_at')->nullable();
|
|
$t->timestamps();
|
|
});
|
|
Schema::create('business_user', function (Blueprint $t) {
|
|
$t->id();
|
|
$t->ulid('business_id');
|
|
$t->foreignId('user_id')->constrained()->cascadeOnDelete();
|
|
$t->string('role')->default('member');
|
|
$t->timestamps();
|
|
$t->unique(['business_id', 'user_id']);
|
|
});
|
|
Schema::create('dj_profiles', function (Blueprint $t) {
|
|
$t->ulid('id')->primary();
|
|
$t->foreignId('user_id')->constrained()->cascadeOnDelete();
|
|
$t->ulid('business_id')->nullable();
|
|
$t->string('stage_name');
|
|
$t->string('slug')->unique();
|
|
$t->string('headline')->nullable();
|
|
$t->text('bio')->nullable();
|
|
$t->string('city')->index();
|
|
$t->unsignedSmallInteger('service_radius_miles')->default(30);
|
|
$t->decimal('price_from', 10, 2)->nullable();
|
|
$t->string('profile_photo')->nullable();
|
|
$t->string('cover_photo')->nullable();
|
|
$t->timestamp('verified_at')->nullable();
|
|
$t->boolean('is_featured')->default(false);
|
|
$t->boolean('is_published')->default(false);
|
|
$t->decimal('average_rating', 3, 2)->default(0);
|
|
$t->unsignedInteger('review_count')->default(0);
|
|
$t->timestamps();
|
|
});
|
|
Schema::create('genres', function (Blueprint $t) {
|
|
$t->id();
|
|
$t->string('name');
|
|
$t->string('slug')->unique();
|
|
$t->timestamps();
|
|
});
|
|
Schema::create('dj_profile_genre', function (Blueprint $t) {
|
|
$t->ulid('dj_profile_id');
|
|
$t->foreignId('genre_id')->constrained()->cascadeOnDelete();
|
|
$t->primary(['dj_profile_id', 'genre_id']);
|
|
});
|
|
Schema::create('enquiries', function (Blueprint $t) {
|
|
$t->ulid('id')->primary();
|
|
$t->foreignId('user_id')->constrained();
|
|
$t->ulid('dj_profile_id');
|
|
$t->string('event_type');
|
|
$t->date('event_date');
|
|
$t->time('start_time')->nullable();
|
|
$t->time('end_time')->nullable();
|
|
$t->string('venue');
|
|
$t->string('postcode')->nullable();
|
|
$t->unsignedInteger('guest_count')->nullable();
|
|
$t->decimal('budget', 10, 2)->nullable();
|
|
$t->text('message');
|
|
$t->string('status')->default('new')->index();
|
|
$t->timestamps();
|
|
});
|
|
Schema::create('bookings', function (Blueprint $t) {
|
|
$t->ulid('id')->primary();
|
|
$t->ulid('enquiry_id')->nullable();
|
|
$t->foreignId('client_id')->constrained('users');
|
|
$t->ulid('dj_profile_id');
|
|
$t->date('event_date');
|
|
$t->decimal('total', 10, 2);
|
|
$t->decimal('deposit', 10, 2)->default(0);
|
|
$t->string('status')->default('pending')->index();
|
|
$t->timestamp('paid_at')->nullable();
|
|
$t->timestamps();
|
|
});
|
|
Schema::create('reviews', function (Blueprint $t) {
|
|
$t->ulid('id')->primary();
|
|
$t->ulid('booking_id');
|
|
$t->foreignId('user_id')->constrained();
|
|
$t->ulid('dj_profile_id');
|
|
$t->unsignedTinyInteger('rating');
|
|
$t->string('title')->nullable();
|
|
$t->text('body');
|
|
$t->string('status')->default('pending')->index();
|
|
$t->text('dj_reply')->nullable();
|
|
$t->timestamps();
|
|
});
|
|
Schema::create('cookie_consents', function (Blueprint $t) {
|
|
$t->id();
|
|
$t->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
|
|
$t->string('anonymous_id')->nullable()->index();
|
|
$t->boolean('analytics')->default(false);
|
|
$t->boolean('marketing')->default(false);
|
|
$t->string('policy_version');
|
|
$t->timestamp('consented_at');
|
|
$t->timestamps();
|
|
});
|
|
Schema::create('audit_logs', function (Blueprint $t) {
|
|
$t->id();
|
|
$t->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
|
|
$t->string('action')->index();
|
|
$t->nullableMorphs('subject');
|
|
$t->json('meta')->nullable();
|
|
$t->string('ip_hash', 64)->nullable();
|
|
$t->timestamps();
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
foreach (['audit_logs', 'cookie_consents', 'reviews', 'bookings', 'enquiries', 'dj_profile_genre', 'genres', 'dj_profiles', 'business_user', 'businesses'] as $x) {
|
|
Schema::dropIfExists($x);
|
|
}
|
|
}
|
|
};
|