feat: implement AI styling foundation and billing scope rework
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
<?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('ai_styles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->string('name', 120);
|
||||
$table->string('category', 50)->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->text('prompt_template')->nullable();
|
||||
$table->text('negative_prompt_template')->nullable();
|
||||
$table->string('provider', 40)->default('runware');
|
||||
$table->string('provider_model', 120)->nullable();
|
||||
$table->boolean('requires_source_image')->default(true);
|
||||
$table->boolean('is_premium')->default(false);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedSmallInteger('sort')->default(0);
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['is_active', 'sort']);
|
||||
$table->index(['provider', 'is_active']);
|
||||
});
|
||||
|
||||
Schema::create('ai_edit_requests', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('photo_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('style_id')->nullable()->constrained('ai_styles')->nullOnDelete();
|
||||
$table->foreignId('requested_by_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('provider', 40)->default('runware');
|
||||
$table->string('provider_model', 120)->nullable();
|
||||
$table->string('status', 30)->default('queued');
|
||||
$table->string('safety_state', 30)->default('pending');
|
||||
$table->text('prompt')->nullable();
|
||||
$table->text('negative_prompt')->nullable();
|
||||
$table->string('input_image_path')->nullable();
|
||||
$table->string('requested_by_device_id', 191)->nullable();
|
||||
$table->string('requested_by_session_id', 191)->nullable();
|
||||
$table->string('idempotency_key', 120);
|
||||
$table->json('safety_reasons')->nullable();
|
||||
$table->string('failure_code', 80)->nullable();
|
||||
$table->string('failure_message', 500)->nullable();
|
||||
$table->timestamp('queued_at')->nullable();
|
||||
$table->timestamp('started_at')->nullable();
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['tenant_id', 'idempotency_key']);
|
||||
$table->index(['tenant_id', 'event_id', 'status']);
|
||||
$table->index(['event_id', 'photo_id']);
|
||||
$table->index(['provider', 'status']);
|
||||
$table->index('queued_at');
|
||||
});
|
||||
|
||||
Schema::create('ai_edit_outputs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('request_id')->constrained('ai_edit_requests')->cascadeOnDelete();
|
||||
$table->foreignId('photo_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('storage_disk', 40)->nullable();
|
||||
$table->string('storage_path')->nullable();
|
||||
$table->string('mime_type', 80)->nullable();
|
||||
$table->unsignedInteger('width')->nullable();
|
||||
$table->unsignedInteger('height')->nullable();
|
||||
$table->unsignedBigInteger('bytes')->nullable();
|
||||
$table->string('checksum', 128)->nullable();
|
||||
$table->string('provider_asset_id', 191)->nullable();
|
||||
$table->text('provider_url')->nullable();
|
||||
$table->boolean('is_primary')->default(true);
|
||||
$table->string('safety_state', 30)->default('pending');
|
||||
$table->json('safety_reasons')->nullable();
|
||||
$table->timestamp('generated_at')->nullable();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['request_id', 'is_primary']);
|
||||
$table->index(['safety_state', 'generated_at']);
|
||||
$table->index('provider_asset_id');
|
||||
});
|
||||
|
||||
Schema::create('ai_provider_runs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('request_id')->constrained('ai_edit_requests')->cascadeOnDelete();
|
||||
$table->string('provider', 40);
|
||||
$table->unsignedSmallInteger('attempt')->default(1);
|
||||
$table->string('provider_task_id', 191)->nullable();
|
||||
$table->string('status', 30)->default('pending');
|
||||
$table->unsignedSmallInteger('http_status')->nullable();
|
||||
$table->timestamp('started_at')->nullable();
|
||||
$table->timestamp('finished_at')->nullable();
|
||||
$table->unsignedInteger('duration_ms')->nullable();
|
||||
$table->decimal('cost_usd', 12, 5)->nullable();
|
||||
$table->unsignedInteger('tokens_input')->nullable();
|
||||
$table->unsignedInteger('tokens_output')->nullable();
|
||||
$table->json('request_payload')->nullable();
|
||||
$table->json('response_payload')->nullable();
|
||||
$table->string('error_message', 500)->nullable();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['request_id', 'attempt']);
|
||||
$table->index(['provider', 'provider_task_id']);
|
||||
$table->index(['status', 'started_at']);
|
||||
});
|
||||
|
||||
Schema::create('ai_usage_ledgers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('event_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('request_id')->nullable()->constrained('ai_edit_requests')->nullOnDelete();
|
||||
$table->string('entry_type', 30);
|
||||
$table->integer('quantity')->default(1);
|
||||
$table->decimal('unit_cost_usd', 12, 5)->default(0);
|
||||
$table->decimal('amount_usd', 12, 5)->default(0);
|
||||
$table->string('currency', 3)->default('USD');
|
||||
$table->string('package_context', 50)->nullable();
|
||||
$table->string('notes', 500)->nullable();
|
||||
$table->timestamp('recorded_at');
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['tenant_id', 'recorded_at']);
|
||||
$table->index(['tenant_id', 'event_id']);
|
||||
$table->index(['entry_type', 'recorded_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ai_usage_ledgers');
|
||||
Schema::dropIfExists('ai_provider_runs');
|
||||
Schema::dropIfExists('ai_edit_outputs');
|
||||
Schema::dropIfExists('ai_edit_requests');
|
||||
Schema::dropIfExists('ai_styles');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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('ai_editing_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->boolean('is_enabled')->default(true);
|
||||
$table->string('default_provider', 40)->default('runware');
|
||||
$table->string('fallback_provider', 40)->nullable();
|
||||
$table->string('runware_mode', 20)->default('live');
|
||||
$table->boolean('queue_auto_dispatch')->default(false);
|
||||
$table->string('queue_name', 60)->default('default');
|
||||
$table->unsignedSmallInteger('queue_max_polls')->default(6);
|
||||
$table->json('blocked_terms')->nullable();
|
||||
$table->string('status_message', 255)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ai_editing_settings');
|
||||
}
|
||||
};
|
||||
@@ -131,6 +131,22 @@ class PackageAddonSeeder extends Seeder
|
||||
'sort' => 41,
|
||||
'metadata' => ['price_eur' => 38],
|
||||
],
|
||||
[
|
||||
'key' => 'ai_styling_unlock',
|
||||
'label' => 'AI Styling Add-on',
|
||||
'price_id' => null,
|
||||
'extra_photos' => 0,
|
||||
'extra_guests' => 0,
|
||||
'extra_gallery_days' => 0,
|
||||
'active' => true,
|
||||
'sort' => 42,
|
||||
'metadata' => [
|
||||
'price_eur' => 9,
|
||||
'entitlements' => [
|
||||
'features' => ['ai_styling'],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($addons as $addon) {
|
||||
|
||||
@@ -97,7 +97,7 @@ TEXT,
|
||||
'max_tasks' => 200,
|
||||
'watermark_allowed' => true,
|
||||
'branding_allowed' => true,
|
||||
'features' => ['basic_uploads', 'unlimited_sharing', 'custom_branding', 'custom_tasks', 'live_slideshow', 'advanced_analytics', 'priority_support'],
|
||||
'features' => ['basic_uploads', 'unlimited_sharing', 'custom_branding', 'custom_tasks', 'live_slideshow', 'advanced_analytics', 'priority_support', 'ai_styling'],
|
||||
'lemonsqueezy_product_id' => 'pro_01k8jcxvwp38gay6jj2akjg76s',
|
||||
'lemonsqueezy_variant_id' => 'pri_01k8jcxw5sap4r306wcvc0ephy',
|
||||
'description' => <<<'TEXT'
|
||||
|
||||
Reference in New Issue
Block a user