From 10003cec3deadb99463160d59b97b0b0e25e44cb Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Wed, 10 Dec 2025 08:59:13 +0100 Subject: [PATCH] fix: add UUID support to CloudProviderToken model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add uuid column to cloud_provider_tokens table via migration - Update CloudProviderToken to extend BaseModel for auto UUID generation - Generate UUIDs for existing records in migration - Fixes null uuid issue in API responses 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/Models/CloudProviderToken.php | 4 +- ...0001_add_uuid_to_cloud_provider_tokens.php | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2024_11_19_000001_add_uuid_to_cloud_provider_tokens.php diff --git a/app/Models/CloudProviderToken.php b/app/Models/CloudProviderToken.php index 607040269..700ab0992 100644 --- a/app/Models/CloudProviderToken.php +++ b/app/Models/CloudProviderToken.php @@ -2,9 +2,7 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Model; - -class CloudProviderToken extends Model +class CloudProviderToken extends BaseModel { protected $guarded = []; diff --git a/database/migrations/2024_11_19_000001_add_uuid_to_cloud_provider_tokens.php b/database/migrations/2024_11_19_000001_add_uuid_to_cloud_provider_tokens.php new file mode 100644 index 000000000..c1d19d3bc --- /dev/null +++ b/database/migrations/2024_11_19_000001_add_uuid_to_cloud_provider_tokens.php @@ -0,0 +1,42 @@ +string('uuid')->nullable()->unique()->after('id'); + }); + + // Generate UUIDs for existing records + $tokens = DB::table('cloud_provider_tokens')->whereNull('uuid')->get(); + foreach ($tokens as $token) { + DB::table('cloud_provider_tokens') + ->where('id', $token->id) + ->update(['uuid' => (string) new Cuid2]); + } + + // Make uuid non-nullable after filling in values + Schema::table('cloud_provider_tokens', function (Blueprint $table) { + $table->string('uuid')->nullable(false)->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('cloud_provider_tokens', function (Blueprint $table) { + $table->dropColumn('uuid'); + }); + } +};