This commit is contained in:
2026-05-09 01:18:51 +02:00
parent 7116ee4619
commit 959970c150
132 changed files with 21310 additions and 0 deletions

1
database/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.sqlite*

View File

@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

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,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('products', function (Blueprint $table) {
$table->id();
$table->string('sku')->unique();
$table->string('name');
$table->text('description')->nullable();
$table->decimal('price', 10, 2);
$table->integer('stock_quantity')->default(0);
$table->string('category')->nullable();
$table->string('status')->default('active');
$table->timestamp('imported_at')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('products');
}
};

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('orders', function (Blueprint $table) {
$table->id();
$table->string('order_number')->unique();
$table->string('customer_name');
$table->string('customer_email');
$table->string('status')->default('pending');
$table->decimal('total_amount', 10, 2)->default(0);
$table->string('payment_id')->nullable();
$table->string('tracking_number')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('orders');
}
};

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::create('order_items', function (Blueprint $table) {
$table->id();
$table->foreignId('order_id')->constrained()->cascadeOnDelete();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->integer('quantity');
$table->decimal('unit_price', 10, 2);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('order_items');
}
};

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('import_jobs', function (Blueprint $table) {
$table->id();
$table->string('workflow_id');
$table->string('run_id')->nullable();
$table->string('type');
$table->string('file_path')->nullable();
$table->string('status')->default('pending');
$table->integer('total_records')->default(0);
$table->integer('processed_records')->default(0);
$table->integer('failed_records')->default(0);
$table->json('error_log')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('import_jobs');
}
};

View File

@@ -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('webhook_deliveries', function (Blueprint $table) {
$table->id();
$table->string('workflow_id');
$table->string('endpoint');
$table->json('payload');
$table->string('status')->default('pending');
$table->integer('attempts')->default(0);
$table->text('last_error')->nullable();
$table->timestamp('delivered_at')->nullable();
$table->timestamp('dead_lettered_at')->nullable();
$table->timestamps();
$table->index('workflow_id');
$table->index('status');
});
}
public function down(): void
{
Schema::dropIfExists('webhook_deliveries');
}
};

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('enrichment_results', function (Blueprint $table) {
$table->id();
$table->string('record_type');
$table->unsignedBigInteger('record_id');
$table->json('geocode_result')->nullable();
$table->boolean('email_valid')->nullable();
$table->integer('credit_score')->nullable();
$table->timestamp('enriched_at')->nullable();
$table->timestamps();
$table->unique(['record_type', 'record_id']);
$table->index('record_type');
});
}
public function down(): void
{
Schema::dropIfExists('enrichment_results');
}
};

View File

@@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace Database\Seeders;
use App\Models\Order;
use App\Models\OrderItem;
use App\Models\Product;
use Illuminate\Database\Seeder;
class OrderSeeder extends Seeder
{
public function run(): void
{
// Create some products first
$products = [];
$categories = ['Electronics', 'Clothing', 'Home & Garden'];
for ($i = 1; $i <= 10; $i++) {
$products[] = Product::updateOrCreate(
['sku' => 'DEMO-SKU-' . str_pad((string) $i, 3, '0', STR_PAD_LEFT)],
[
'name' => 'Demo Product ' . $i,
'description' => 'A sample product for order fulfillment demo',
'price' => round(mt_rand(1000, 50000) / 100, 2),
'stock_quantity' => mt_rand(50, 500),
'category' => $categories[array_rand($categories)],
'status' => 'active',
]
);
}
// Create 5 sample orders
$customers = [
['name' => 'Alice Johnson', 'email' => 'alice@example.com'],
['name' => 'Bob Smith', 'email' => 'bob@example.com'],
['name' => 'Carol Williams', 'email' => 'carol@example.com'],
['name' => 'David Brown', 'email' => 'david@example.com'],
['name' => 'Eve Davis', 'email' => 'eve@example.com'],
];
foreach ($customers as $index => $customer) {
$order = Order::updateOrCreate(
['order_number' => 'ORD-' . str_pad((string) ($index + 1), 5, '0', STR_PAD_LEFT)],
[
'customer_name' => $customer['name'],
'customer_email' => $customer['email'],
'status' => 'pending',
'total_amount' => 0,
]
);
$totalAmount = 0;
$itemCount = mt_rand(1, 4);
$selectedProducts = array_rand($products, min($itemCount, count($products)));
if (!is_array($selectedProducts)) {
$selectedProducts = [$selectedProducts];
}
foreach ($selectedProducts as $productIndex) {
$product = $products[$productIndex];
$quantity = mt_rand(1, 5);
$unitPrice = $product->price;
OrderItem::create([
'order_id' => $order->id,
'product_id' => $product->id,
'quantity' => $quantity,
'unit_price' => $unitPrice,
]);
$totalAmount += $quantity * $unitPrice;
}
$order->update(['total_amount' => $totalAmount]);
}
$this->command->info('Created 10 demo products and 5 sample orders');
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
class ProductImportSeeder extends Seeder
{
public function run(): void
{
$categories = ['Electronics', 'Clothing', 'Home & Garden', 'Sports', 'Books', 'Toys', 'Food', 'Health'];
$csv = "sku,name,description,price,stock_quantity,category\n";
for ($i = 1; $i <= 500; $i++) {
$sku = 'SKU-' . str_pad((string) $i, 5, '0', STR_PAD_LEFT);
$name = 'Product ' . $i;
$description = 'Description for product ' . $i . '. This is a sample product for the Temporal import demo.';
$price = round(mt_rand(100, 99999) / 100, 2);
$stock = mt_rand(0, 1000);
$category = $categories[array_rand($categories)];
$csv .= "{$sku},{$name},\"{$description}\",{$price},{$stock},{$category}\n";
}
$dir = storage_path('app/imports');
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
file_put_contents(storage_path('app/imports/products.csv'), $csv);
$this->command->info('Generated 500-row products.csv at storage/app/imports/products.csv');
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class TemporalDemoSeeder extends Seeder
{
public function run(): void
{
$this->call([
ProductImportSeeder::class,
OrderSeeder::class,
]);
}
}