Files
laraundfelix/database/migrations/2026_11_15_120000_create_commerce_tables.php
LarsandCursor fd6860efda
Deploy Test / test (push) Successful in 12s
Deploy Test / deploy (push) Successful in 21s
Öffne Katalog, Bibliothek und Testkauf für den MVP.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-15 09:04:08 +01:00

72 lines
2.7 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('manual_grants', function (Blueprint $table) {
$table->id();
$table->foreignId('actor_id')->constrained('users')->restrictOnDelete();
$table->foreignId('party_id')->constrained()->restrictOnDelete();
$table->foreignId('offer_id')->constrained()->restrictOnDelete();
$table->text('reason');
$table->timestamps();
});
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->restrictOnDelete();
$table->foreignId('party_id')->constrained()->restrictOnDelete();
$table->string('status');
$table->string('holder_kind');
$table->timestamps();
});
Schema::create('order_lines', function (Blueprint $table) {
$table->id();
$table->foreignId('order_id')->constrained()->cascadeOnDelete();
$table->foreignId('offer_version_id')->constrained()->restrictOnDelete();
$table->unsignedInteger('price_cents');
$table->string('term_rule');
$table->string('update_promise');
$table->string('holder_kind');
$table->timestamps();
$table->unique(['order_id', 'offer_version_id']);
});
Schema::create('order_scope_items', function (Blueprint $table) {
$table->id();
$table->foreignId('order_line_id')->constrained()->cascadeOnDelete();
$table->foreignId('license_article_id')->constrained()->restrictOnDelete();
$table->foreignId('rights_profile_version_id')->constrained()->restrictOnDelete();
$table->json('rights_snapshot');
$table->timestamps();
$table->unique(['order_line_id', 'license_article_id', 'rights_profile_version_id'], 'order_scope_unique');
});
Schema::create('payments', function (Blueprint $table) {
$table->id();
$table->foreignId('order_id')->constrained()->cascadeOnDelete();
$table->string('provider');
$table->string('status');
$table->string('provider_reference')->unique();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('payments');
Schema::dropIfExists('order_scope_items');
Schema::dropIfExists('order_lines');
Schema::dropIfExists('orders');
Schema::dropIfExists('manual_grants');
}
};