Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Jobs/CreateAnystackLicenseJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function handle(): void
$licenseData = $this->createLicense($this->user->anystack_contact_id);

$license = License::create([
'anystack_id' => $licenseData['id'],
'user_id' => $this->user->id,
'subscription_item_id' => $this->subscriptionItemId,
'policy_name' => $this->subscription->value,
Expand Down
1 change: 1 addition & 0 deletions database/factories/LicenseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class LicenseFactory extends Factory
public function definition(): array
{
return [
'anystack_id' => fake()->uuid(),
'user_id' => User::factory(),
'subscription_item_id' => SubscriptionItem::factory(),
'policy_name' => fake()->randomElement(Subscription::cases())->value,
Expand Down
36 changes: 36 additions & 0 deletions database/migrations/2025_05_15_190315_alter_licenses_table.php
Original file line number Diff line number Diff line change
@@ -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::table('licenses', function (Blueprint $table) {
$table->uuid('anystack_id')->nullable()->after('id');
$table->uuid('key')->change();

$table->unique('anystack_id');
$table->unique('key');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('licenses', function (Blueprint $table) {
$table->dropUnique(['anystack_id']);
$table->dropUnique(['key']);

$table->dropColumn(['anystack_id']);
$table->string('key')->change();
});
}
};
1 change: 1 addition & 0 deletions tests/Feature/Jobs/CreateAnystackLicenseJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public function it_stores_the_license_key_in_database()
$job->handle();

$this->assertDatabaseHas('licenses', [
'anystack_id' => 'license-123',
'user_id' => $user->id,
'subscription_item_id' => null,
'policy_name' => 'max',
Expand Down