update lisensi prosess
tests / ci (push) Has been cancelled

This commit is contained in:
Wian Drs
2026-08-25 13:43:55 +07:00
parent 1e80be180e
commit 60946ddf37
58 changed files with 2903 additions and 165 deletions
@@ -0,0 +1,37 @@
<?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('billing_orders', function (Blueprint $table): void {
$table->id();
$table->uuid('uuid')->unique();
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
$table->foreignId('license_id')->nullable()->constrained()->nullOnDelete();
$table->string('plan_code', 50);
$table->string('gateway', 50);
$table->string('external_id')->nullable()->index();
$table->string('status', 30)->default('pending')->index();
$table->unsignedBigInteger('subtotal');
$table->unsignedBigInteger('tax')->default(0);
$table->unsignedBigInteger('total');
$table->char('currency', 3)->default('IDR');
$table->text('checkout_url')->nullable();
$table->jsonb('metadata')->nullable();
$table->timestampTz('expires_at')->nullable();
$table->timestampTz('paid_at')->nullable();
$table->timestampsTz();
$table->index(['tenant_id', 'created_at']);
});
}
public function down(): void
{
Schema::dropIfExists('billing_orders');
}
};
@@ -0,0 +1,23 @@
<?php
use App\Models\DeploymentInstallation;
use App\Models\Tenant;
use App\Services\LicenseEntitlementService;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
public function up(): void
{
Tenant::query()->whereDoesntHave('licenses')->each(function (Tenant $tenant): void {
$installation = DeploymentInstallation::withoutGlobalScope('tenant')->where('tenant_id', $tenant->id)->first();
if (! $installation) {
return;
}
$plan = $installation->deployment_type->value === 'managed_cloud' ? 'cloud_free' : 'local_micro';
app(LicenseEntitlementService::class)->provisionInitial($tenant, $installation, $plan, true);
});
}
public function down(): void {}
};
@@ -0,0 +1,28 @@
<?php
use App\Models\DeploymentInstallation;
use App\Models\Tenant;
use App\Services\LicenseEntitlementService;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
public function up(): void
{
Tenant::query()->each(function (Tenant $tenant): void {
$installation = DeploymentInstallation::withoutGlobalScope('tenant')->where('tenant_id', $tenant->id)->first();
if (! $installation) {
$installation = DeploymentInstallation::withoutGlobalScope('tenant')->create([
'tenant_id' => $tenant->id, 'name' => 'RADIQ Managed Cloud', 'deployment_type' => 'managed_cloud',
'instance_key_hash' => hash('sha256', random_bytes(32)), 'status' => 'active', 'activated_at' => now(),
]);
}
if (! $tenant->licenses()->exists()) {
$plan = $installation->deployment_type->value === 'managed_cloud' ? 'cloud_free' : 'local_micro';
app(LicenseEntitlementService::class)->provisionInitial($tenant, $installation, $plan, true);
}
});
}
public function down(): void {}
};
@@ -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('billing_orders', function (Blueprint $table): void {
$table->string('payment_method', 20)->nullable()->after('gateway');
});
}
public function down(): void
{
Schema::table('billing_orders', function (Blueprint $table): void {
$table->dropColumn('payment_method');
});
}
};