Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
<?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
|
||||
{
|
||||
// Compte connecté d'un utilisateur chez un fournisseur externe (Garmin/Strava/...).
|
||||
// Couche générique : le nom du fournisseur n'est qu'une string, jamais une référence en dur.
|
||||
Schema::create('integrations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained();
|
||||
$table->string('provider'); // clé du fournisseur, ex "strava" (cf ActivityProvider::key())
|
||||
$table->string('external_user_id')->nullable(); // identifiant du compte côté fournisseur
|
||||
$table->text('access_token')->nullable(); // cast "encrypted"
|
||||
$table->text('refresh_token')->nullable(); // cast "encrypted"
|
||||
$table->timestamp('token_expires_at')->nullable();
|
||||
$table->json('scopes')->nullable(); // permissions OAuth accordées
|
||||
$table->string('status')->default('connected'); // cast PHP IntegrationStatus, pas d'enum SQL
|
||||
$table->timestamp('connected_at');
|
||||
$table->timestamp('last_synced_at')->nullable();
|
||||
$table->json('meta')->nullable(); // données libres propres au fournisseur
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'provider']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('integrations');
|
||||
}
|
||||
};
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?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
|
||||
{
|
||||
// Activité importée depuis un fournisseur externe (course, sortie vélo, etc.), rattachée à l'intégration qui l'a récupérée.
|
||||
Schema::create('external_activities', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('integration_id')->constrained();
|
||||
$table->foreignId('user_id')->constrained();
|
||||
$table->string('provider'); // dupliqué depuis l'intégration pour requêter sans jointure
|
||||
$table->string('external_id'); // identifiant de l'activité côté fournisseur
|
||||
$table->string('type'); // ex "run", "ride", vocabulaire propre au fournisseur
|
||||
$table->timestamp('started_at');
|
||||
$table->unsignedInteger('duration_seconds')->nullable();
|
||||
$table->decimal('distance_meters', 10, 2)->nullable();
|
||||
$table->unsignedInteger('calories')->nullable();
|
||||
$table->json('raw')->nullable(); // payload brut du fournisseur, pour ré-exploitation future
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['provider', 'external_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('external_activities');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user