@@ -0,0 +1,68 @@
|
||||
<?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('deployment_installations', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('deployment_type', 30)->index();
|
||||
$table->string('domain')->nullable();
|
||||
$table->string('instance_key_hash', 64)->unique();
|
||||
$table->string('fingerprint_hash', 64)->nullable()->index();
|
||||
$table->string('status', 30)->default('pending')->index();
|
||||
$table->timestampTz('activated_at')->nullable();
|
||||
$table->timestampTz('last_seen_at')->nullable()->index();
|
||||
$table->timestampsTz();
|
||||
$table->index(['tenant_id', 'status']);
|
||||
});
|
||||
|
||||
Schema::create('licenses', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('deployment_installation_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('license_key_hash', 64)->unique();
|
||||
$table->string('plan', 50);
|
||||
$table->string('status', 30)->default('pending')->index();
|
||||
$table->unsignedInteger('max_devices')->nullable();
|
||||
$table->unsignedInteger('max_users')->nullable();
|
||||
$table->jsonb('features')->nullable();
|
||||
$table->text('signed_payload')->nullable();
|
||||
$table->timestampTz('starts_at');
|
||||
$table->timestampTz('expires_at')->index();
|
||||
$table->timestampTz('grace_until')->nullable();
|
||||
$table->foreignId('issued_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestampsTz();
|
||||
$table->index(['tenant_id', 'status', 'expires_at']);
|
||||
});
|
||||
|
||||
Schema::create('license_events', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('license_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('deployment_installation_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('actor_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('event_type', 50)->index();
|
||||
$table->jsonb('metadata')->nullable();
|
||||
$table->timestampTz('occurred_at')->index();
|
||||
$table->timestampsTz();
|
||||
$table->index(['tenant_id', 'occurred_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('license_events');
|
||||
Schema::dropIfExists('licenses');
|
||||
Schema::dropIfExists('deployment_installations');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user