Current state

This commit is contained in:
2026-02-07 08:23:18 +01:00
commit 0a4372c40d
22479 changed files with 1553543 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@@ -0,0 +1,35 @@
<?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('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@@ -0,0 +1,57 @@
<?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('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@@ -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('content_types', function (Blueprint $table) {
$table->id();
$table->string('name', 64);
$table->string('slug', 64)->unique();
$table->text('description')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('content_types');
}
};

View File

@@ -0,0 +1,42 @@
<?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->foreignId('content_type_id')
->constrained('content_types')
->cascadeOnDelete();
$table->foreignId('parent_id')
->nullable()
->constrained('categories')
->cascadeOnDelete();
$table->string('name', 128);
$table->string('slug', 128);
$table->text('description')->nullable();
$table->string('image', 255)->nullable();
$table->boolean('is_active')->default(true);
$table->integer('sort_order')->default(0);
$table->timestamps();
$table->unique(['content_type_id', 'slug']);
$table->index(['parent_id']);
});
}
public function down(): void
{
Schema::dropIfExists('categories');
}
};

View File

@@ -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('artwork_category', function (Blueprint $table) {
$table->unsignedBigInteger('artwork_id');
$table->unsignedBigInteger('category_id');
$table->primary(['artwork_id', 'category_id']);
$table->foreign('category_id')
->references('id')
->on('categories')
->cascadeOnDelete();
});
}
public function down(): void
{
Schema::dropIfExists('artwork_category');
}
};

View File

@@ -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('category_seo', function (Blueprint $table) {
$table->foreignId('category_id')
->primary()
->constrained('categories')
->cascadeOnDelete();
$table->string('meta_title')->nullable();
$table->string('meta_description')->nullable();
$table->string('meta_keywords')->nullable();
$table->string('canonical_url')->nullable();
});
}
public function down(): void
{
Schema::dropIfExists('category_seo');
}
};

View File

@@ -0,0 +1,31 @@
<?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_translations', function (Blueprint $table) {
$table->id();
$table->foreignId('category_id')
->constrained('categories')
->cascadeOnDelete();
$table->char('locale', 2);
$table->string('name', 128);
$table->text('description')->nullable();
$table->unique(['category_id', 'locale']);
});
}
public function down(): void
{
Schema::dropIfExists('category_translations');
}
};

View File

@@ -0,0 +1,41 @@
<?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('artworks', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->index();
$table->string('title', 150);
$table->string('slug', 160)->unique();
$table->text('description')->nullable();
$table->string('file_name');
$table->string('file_path');
$table->unsignedBigInteger('file_size');
$table->string('mime_type', 64);
$table->unsignedInteger('width');
$table->unsignedInteger('height');
$table->boolean('is_public')->default(true)->index();
$table->boolean('is_approved')->default(false)->index();
$table->timestamp('published_at')->nullable()->index();
$table->timestamps();
$table->softDeletes();
$table->index(['is_public', 'is_approved', 'published_at'], 'idx_artworks_browse');
});
}
public function down(): void
{
Schema::dropIfExists('artworks');
}
};

View File

@@ -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('artwork_translations', function (Blueprint $table) {
$table->id();
$table->foreignId('artwork_id')->constrained()->cascadeOnDelete();
$table->char('locale', 2);
$table->string('title', 150);
$table->text('description')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unique(['artwork_id', 'locale']);
$table->index(['locale', 'artwork_id']);
});
}
public function down(): void
{
Schema::dropIfExists('artwork_translations');
}
};

View File

@@ -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('artwork_stats', function (Blueprint $table) {
$table->foreignId('artwork_id')->primary()->constrained()->cascadeOnDelete();
$table->unsignedBigInteger('views')->default(0);
$table->unsignedBigInteger('downloads')->default(0);
$table->unsignedBigInteger('favorites')->default(0);
$table->float('rating_avg', 4, 2)->default(0);
$table->unsignedInteger('rating_count')->default(0);
});
}
public function down(): void
{
Schema::dropIfExists('artwork_stats');
}
};

View File

@@ -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('artwork_comments', function (Blueprint $table) {
$table->id();
$table->foreignId('artwork_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->index();
$table->text('content');
$table->boolean('is_approved')->default(true)->index();
$table->timestamps();
$table->softDeletes();
$table->index(['artwork_id', 'created_at'], 'idx_comments_artwork');
});
}
public function down(): void
{
Schema::dropIfExists('artwork_comments');
}
};

View File

@@ -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('artwork_downloads', function (Blueprint $table) {
$table->id();
$table->foreignId('artwork_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->nullable()->index();
$table->binary('ip', 16);
$table->string('user_agent')->nullable();
$table->timestamp('created_at')->useCurrent();
$table->index(['artwork_id', 'created_at'], 'idx_downloads_artwork');
});
}
public function down(): void
{
Schema::dropIfExists('artwork_downloads');
}
};

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
{
public function up(): void
{
if (Schema::hasTable('artworks') && Schema::hasTable('artwork_category')) {
Schema::table('artwork_category', function (Blueprint $table) {
$table->foreign('artwork_id')
->references('id')
->on('artworks')
->cascadeOnDelete();
});
}
}
public function down(): void
{
if (Schema::hasTable('artwork_category')) {
try {
Schema::table('artwork_category', function (Blueprint $table) {
$table->dropForeign(['artwork_id']);
});
} catch (\Exception $e) {
// Foreign key does not exist or cannot be dropped; ignore.
}
}
}
};

View File

@@ -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::table('categories', function (Blueprint $table) {
$table->softDeletes();
});
}
public function down(): void
{
Schema::table('categories', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
};

View File

@@ -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::table('category_translations', function (Blueprint $table) {
$table->softDeletes();
});
}
public function down(): void
{
Schema::table('category_translations', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
};

View File

@@ -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::table('categories', function (Blueprint $table) {
$table->index('slug');
});
}
public function down(): void
{
Schema::table('categories', function (Blueprint $table) {
$table->dropIndex(['slug']);
});
}
};

View File

@@ -0,0 +1,67 @@
<?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::table('users', function (Blueprint $table) {
// Add username (nullable for legacy), unique
if (!Schema::hasColumn('users', 'username')) {
$table->string('username', 80)->nullable()->unique()->after('id');
}
// Ensure name exists and is nullable
if (!Schema::hasColumn('users', 'name')) {
$table->string('name')->nullable();
} else {
$table->string('name')->nullable()->change();
}
// Email nullable to allow legacy nulls/dupes handling in import
if (Schema::hasColumn('users', 'email')) {
$table->string('email')->nullable()->change();
}
if (!Schema::hasColumn('users', 'is_active')) {
$table->boolean('is_active')->default(true)->after('remember_token');
}
if (!Schema::hasColumn('users', 'needs_password_reset')) {
$table->boolean('needs_password_reset')->default(true)->after('is_active');
}
if (!Schema::hasColumn('users', 'role')) {
$table->string('role', 32)->default('user')->after('needs_password_reset');
}
if (!Schema::hasColumn('users', 'legacy_password_algo')) {
$table->string('legacy_password_algo', 32)->nullable()->after('role');
}
if (!Schema::hasColumn('users', 'last_visit_at')) {
$table->timestamp('last_visit_at')->nullable()->after('legacy_password_algo');
}
// Soft deletes for user accounts
if (!Schema::hasColumn('users', 'deleted_at')) {
$table->softDeletes()->after('last_visit_at');
}
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'username')) $table->dropColumn('username');
if (Schema::hasColumn('users', 'is_active')) $table->dropColumn('is_active');
if (Schema::hasColumn('users', 'needs_password_reset')) $table->dropColumn('needs_password_reset');
if (Schema::hasColumn('users', 'role')) $table->dropColumn('role');
if (Schema::hasColumn('users', 'legacy_password_algo')) $table->dropColumn('legacy_password_algo');
if (Schema::hasColumn('users', 'last_visit_at')) $table->dropColumn('last_visit_at');
if (Schema::hasColumn('users', 'deleted_at')) $table->dropColumn('deleted_at');
});
}
};

View File

@@ -0,0 +1,36 @@
<?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('user_profiles', function (Blueprint $table) {
$table->unsignedBigInteger('user_id')->primary();
$table->text('bio')->nullable();
$table->string('avatar', 255)->nullable();
$table->string('cover_image', 255)->nullable();
$table->string('country', 80)->nullable();
$table->char('country_code', 2)->nullable();
$table->string('language', 10)->nullable();
$table->date('birthdate')->nullable();
$table->enum('gender', ['M','F','X'])->default('X');
$table->string('website', 255)->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
});
}
public function down(): void
{
Schema::dropIfExists('user_profiles');
}
};

View File

@@ -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('user_social_links', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->string('platform', 32);
$table->string('url', 255);
$table->timestamps();
$table->unique(['user_id', 'platform']);
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
});
}
public function down(): void
{
Schema::dropIfExists('user_social_links');
}
};

View File

@@ -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('user_statistics', function (Blueprint $table) {
$table->unsignedBigInteger('user_id')->primary();
$table->unsignedInteger('uploads')->default(0);
$table->unsignedInteger('downloads')->default(0);
$table->unsignedInteger('pageviews')->default(0);
$table->unsignedInteger('awards')->default(0);
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
});
}
public function down(): void
{
Schema::dropIfExists('user_statistics');
}
};

View File

@@ -0,0 +1,25 @@
<?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::table('users', function (Blueprint $table) {
if (! Schema::hasColumn('users', 'deleted_at')) {
$table->softDeletes()->after('last_visit_at');
}
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'deleted_at')) {
$table->dropColumn('deleted_at');
}
});
}
};

View File

@@ -0,0 +1,72 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateArtworkFeaturesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('artwork_features', function (Blueprint $table) {
// Production-ready settings
$table->engine = 'InnoDB';
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
$table->bigIncrements('id');
$table->unsignedBigInteger('artwork_id');
$table->dateTime('featured_at')->nullable(false);
$table->dateTime('expires_at')->nullable();
$table->unsignedSmallInteger('priority')->default(100);
$table->string('label', 100)->nullable();
$table->text('note')->nullable();
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
$table->softDeletes();
// Indexes
$table->index(['is_active', 'featured_at', 'expires_at'], 'idx_features_active');
$table->index(['is_active', 'priority', 'featured_at'], 'idx_features_priority');
$table->index('artwork_id', 'idx_features_artwork');
$table->unique(['artwork_id', 'is_active'], 'uq_features_artwork_active');
// Foreign keys
$table->foreign('artwork_id', 'fk_features_artwork')
->references('id')->on('artworks')
->onDelete('cascade');
$table->foreign('created_by', 'fk_features_user')
->references('id')->on('users')
->onDelete('set null');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('artwork_features', function (Blueprint $table) {
$table->dropForeign('fk_features_artwork');
$table->dropForeign('fk_features_user');
});
Schema::dropIfExists('artwork_features');
}
}

View File

@@ -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::table('artworks', function (Blueprint $table) {
$table->string('hash', 128)->nullable()->unique()->after('mime_type');
$table->string('file_ext', 16)->nullable()->after('hash');
$table->string('thumb_ext', 16)->nullable()->after('file_ext');
});
}
public function down(): void
{
Schema::table('artworks', function (Blueprint $table) {
$table->dropUnique(['hash']);
$table->dropColumn(['hash', 'file_ext', 'thumb_ext']);
});
}
};

View File

@@ -0,0 +1,45 @@
<?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::table('artworks', function (Blueprint $table) {
// Remove unique constraint on hash and add a non-unique index
try {
$table->dropUnique(['hash']);
} catch (\Throwable $e) {
// Ignore if it doesn't exist
}
// Add regular index for faster lookups. Wrap in try/catch since
// checking existing indexes requires DBAL which may not be installed.
try {
if (Schema::hasColumn('artworks', 'hash')) {
$table->index('hash', 'artworks_hash_index');
}
} catch (\Throwable $e) {
// Ignore index creation errors (likely already exists)
}
});
}
public function down(): void
{
Schema::table('artworks', function (Blueprint $table) {
// Restore unique constraint (if desired)
try {
$table->dropIndex('artworks_hash_index');
} catch (\Throwable $e) {
}
try {
$table->unique('hash', 'artworks_hash_unique');
} catch (\Throwable $e) {
}
});
}
};