- Fix storage permissions to use 'www' user instead of 'www-data' - Fix UserModel getAllForAdmin query to avoid placeholders in LIMIT/OFFSET - Import missing modules: Advertising, Dashboard, Analytics - Update deploy script to copy files to public directory
64 lines
2.5 KiB
PHP
64 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Core\Database\Migration;
|
|
use App\Core\Database\SchemaBuilder;
|
|
|
|
/**
|
|
* Migration: Add Google Sheets integration fields to advertising_creatives table
|
|
*
|
|
* This migration adds the necessary fields to integrate Google Sheets rotator data
|
|
* with the existing advertising creatives system, maintaining backward compatibility.
|
|
*/
|
|
class AddGoogleSheetsFieldsToCreativesTable extends Migration
|
|
{
|
|
/**
|
|
* Run the migration
|
|
*/
|
|
public function up(): void
|
|
{
|
|
// Add Google Sheets integration fields using direct SQL
|
|
$sql = "
|
|
ALTER TABLE advertising_creatives
|
|
ADD COLUMN script_id VARCHAR(32) NULL COMMENT 'Related campaign script_id from Google Sheets',
|
|
ADD COLUMN creative_slug VARCHAR(100) NULL UNIQUE COMMENT 'Creative slug (unique identifier)',
|
|
ADD COLUMN geo VARCHAR(10) NULL COMMENT 'Specific geo/country for this creative',
|
|
ADD COLUMN click_mode_override BOOLEAN NULL COMMENT 'Override campaign click_mode setting',
|
|
ADD COLUMN view_url TEXT NULL COMMENT 'View URL for this creative',
|
|
ADD COLUMN rotator_hash VARCHAR(32) NULL COMMENT 'Hash for rotator sync control',
|
|
ADD COLUMN creative_type ENUM('primary', 'rotator') DEFAULT 'rotator' COMMENT 'Type of creative',
|
|
ADD COLUMN last_sync_at TIMESTAMP NULL COMMENT 'Last synchronization timestamp'
|
|
";
|
|
|
|
$this->db->query($sql);
|
|
|
|
// Add indexes
|
|
$this->db->query("ALTER TABLE advertising_creatives ADD INDEX idx_script_id (script_id)");
|
|
$this->db->query("ALTER TABLE advertising_creatives ADD INDEX idx_creative_slug (creative_slug)");
|
|
$this->db->query("ALTER TABLE advertising_creatives ADD INDEX idx_creative_type (creative_type)");
|
|
$this->db->query("ALTER TABLE advertising_creatives ADD INDEX idx_last_sync_at (last_sync_at)");
|
|
|
|
echo "✅ Added Google Sheets integration fields to advertising_creatives\n";
|
|
}
|
|
|
|
/**
|
|
* Reverse the migration
|
|
*/
|
|
public function down(): void
|
|
{
|
|
$this->schema->table('advertising_creatives', function (SchemaBuilder $table) {
|
|
// Remove Google Sheets integration fields
|
|
$table->dropColumn([
|
|
'script_id',
|
|
'creative_slug',
|
|
'geo',
|
|
'click_mode_override',
|
|
'view_url',
|
|
'rotator_hash',
|
|
'creative_type',
|
|
'last_sync_at'
|
|
]);
|
|
});
|
|
}
|
|
} |