New Initial Commit

This commit is contained in:
twotalesanimation
2025-12-09 12:04:54 +02:00
commit 6de01c13c5
350 changed files with 42032 additions and 0 deletions
@@ -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');
}
};
@@ -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');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -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');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->string('image')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('categories');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('category_id')->nullable();
$table->string('name');
$table->string('slug')->unique();
$table->text('description');
$table->decimal('price', 10, 2);
$table->string('image')->nullable();
$table->integer('stock')->default(0);
$table->boolean('featured')->default(false);
$table->timestamps();
$table->foreign('category_id')->references('id')->on('categories')->nullOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('products');
}
};
@@ -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('orders', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id')->nullable();
$table->string('order_number')->unique();
$table->decimal('total', 12, 2);
$table->string('status')->default('pending');
$table->string('payment_method')->nullable();
$table->string('payment_status')->default('unpaid');
$table->text('shipping_address')->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('orders');
}
};
@@ -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('order_items', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('order_id');
$table->unsignedBigInteger('product_id');
$table->integer('quantity');
$table->decimal('price', 10, 2);
$table->timestamps();
$table->foreign('order_id')->references('id')->on('orders')->cascadeOnDelete();
$table->foreign('product_id')->references('id')->on('products')->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('order_items');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('order_items', function (Blueprint $table) {
$table->string('type')->default('wallpaper')->after('price');
$table->decimal('length', 8, 2)->nullable()->after('type');
$table->decimal('width', 8, 2)->nullable()->after('length');
$table->decimal('height', 8, 2)->nullable()->after('width');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('order_items', function (Blueprint $table) {
$table->dropColumn(['type', 'length', 'width', 'height']);
});
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('orders', function (Blueprint $table) {
$table->string('customer_name')->after('user_id');
$table->string('customer_email')->after('customer_name');
$table->string('customer_phone')->after('customer_email');
$table->text('notes')->nullable()->after('shipping_address');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('orders', function (Blueprint $table) {
$table->dropColumn(['customer_name', 'customer_email', 'customer_phone', 'notes']);
});
}
};
@@ -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('print_stocks', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->decimal('cost_per_meter', 10, 2)->nullable();
$table->decimal('cost_per_m2', 10, 2)->nullable();
$table->enum('type', ['wallpaper', 'mural', 'both'])->default('both');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('print_stocks');
}
};
@@ -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('product_print_stocks', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('product_id');
$table->unsignedBigInteger('print_stock_id');
$table->timestamps();
$table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
$table->foreign('print_stock_id')->references('id')->on('print_stocks')->onDelete('cascade');
$table->unique(['product_id', 'print_stock_id']);
});
}
public function down(): void
{
Schema::dropIfExists('product_print_stocks');
}
};
@@ -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('order_items', function (Blueprint $table) {
$table->unsignedBigInteger('print_stock_id')->nullable()->after('product_id');
$table->foreign('print_stock_id')->references('id')->on('print_stocks')->onDelete('set null');
});
}
public function down(): void
{
Schema::table('order_items', function (Blueprint $table) {
$table->dropForeign(['print_stock_id']);
$table->dropColumn('print_stock_id');
});
}
};
@@ -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('users', function (Blueprint $table) {
$table->boolean('is_admin')->default(false)->after('email');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('is_admin');
});
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->enum('type', ['wallpaper', 'mural'])->default('wallpaper')->after('stock');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('type');
});
}
};
@@ -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('product_images', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id')->constrained()->onDelete('cascade');
$table->string('image_path');
$table->integer('sort_order')->default(0);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('product_images');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('print_stocks', function (Blueprint $table) {
$table->decimal('width', 8, 2)->default(1)->after('type');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('print_stocks', function (Blueprint $table) {
$table->dropColumn('width');
});
}
};
@@ -0,0 +1,96 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
// Check if uuid column already exists from previous failed migration
if (!Schema::hasColumn('orders', 'uuid')) {
Schema::table('orders', function (Blueprint $table) {
// Add UUID column
$table->uuid('uuid')->nullable()->unique()->after('id');
});
}
// Populate existing orders with UUIDs
DB::table('orders')->whereNull('uuid')->update([
'uuid' => DB::raw('UUID()')
]);
// Make UUID non-nullable
Schema::table('orders', function (Blueprint $table) {
$table->uuid('uuid')->nullable(false)->change();
});
// Temporarily disable foreign key checks
DB::statement('SET FOREIGN_KEY_CHECKS=0');
// Drop the foreign key constraint on order_items
DB::statement('ALTER TABLE `order_items` DROP FOREIGN KEY `order_items_order_id_foreign`');
// Change order_id column in order_items to uuid type first
// Get the UUID values from orders and map them to order_items
DB::statement('ALTER TABLE `order_items` MODIFY `order_id` CHAR(36) NULL');
// Update order_items with uuid values from orders
DB::statement('UPDATE `order_items` oi INNER JOIN `orders` o ON oi.order_id = o.id SET oi.order_id = o.uuid');
// Make order_id non-nullable
DB::statement('ALTER TABLE `order_items` MODIFY `order_id` CHAR(36) NOT NULL');
// Remove auto_increment from id column, then drop it and make uuid the primary key
DB::statement('ALTER TABLE `orders` MODIFY `id` INT NOT NULL');
DB::statement('ALTER TABLE `orders` DROP PRIMARY KEY, ADD PRIMARY KEY (`uuid`)');
DB::statement('ALTER TABLE `orders` DROP COLUMN `id`');
// Recreate the foreign key constraint on order_items pointing to uuid
DB::statement('ALTER TABLE `order_items` ADD CONSTRAINT `order_items_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders`(`uuid`) ON DELETE CASCADE');
// Re-enable foreign key checks
DB::statement('SET FOREIGN_KEY_CHECKS=1');
}
public function down(): void
{
// Disable foreign key checks
DB::statement('SET FOREIGN_KEY_CHECKS=0');
// Drop the uuid-based foreign key
DB::statement('ALTER TABLE `order_items` DROP FOREIGN KEY `order_items_order_id_foreign`');
// Check if id column still exists, if not we need to restore it
if (!Schema::hasColumn('orders', 'id')) {
Schema::table('orders', function (Blueprint $table) {
$table->id()->first();
});
}
// Convert order_id back to integer and update references
DB::statement('ALTER TABLE `order_items` MODIFY `order_id` BIGINT UNSIGNED NULL');
// Update order_items with id values from orders
DB::statement('UPDATE `order_items` oi INNER JOIN `orders` o ON oi.order_id = o.uuid SET oi.order_id = o.id');
// Make order_id non-nullable
DB::statement('ALTER TABLE `order_items` MODIFY `order_id` BIGINT UNSIGNED NOT NULL');
// Recreate the original foreign key pointing to id
DB::statement('ALTER TABLE `order_items` ADD CONSTRAINT `order_items_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders`(`id`) ON DELETE CASCADE');
// Drop uuid column if it exists
if (Schema::hasColumn('orders', 'uuid')) {
Schema::table('orders', function (Blueprint $table) {
$table->dropUnique(['uuid']);
$table->dropColumn('uuid');
});
}
// Re-enable foreign key checks
DB::statement('SET FOREIGN_KEY_CHECKS=1');
}
};
@@ -0,0 +1,32 @@
<?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('hero_images', function (Blueprint $table) {
$table->id();
$table->enum('page', ['home', 'wallpaper', 'mural']);
$table->string('image_path');
$table->string('title');
$table->text('description')->nullable();
$table->string('button_text')->nullable();
$table->string('button_link')->nullable();
$table->integer('sort_order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->index('page');
$table->index('is_active');
});
}
public function down(): void
{
Schema::dropIfExists('hero_images');
}
};