db->fetch("SHOW TABLES LIKE '$table'"); if (!$tableExists) { echo "⚠️ Table $table does not exist, skipping\n"; continue; } // Verificar se a coluna cuid existe $columnExists = $this->db->fetch("SHOW COLUMNS FROM $table LIKE 'cuid'"); if (!$columnExists) { echo "⚠️ Column cuid does not exist in $table, skipping\n"; continue; } // Atualizar o comprimento do campo cuid $sql = "ALTER TABLE $table MODIFY COLUMN cuid VARCHAR(64) NOT NULL UNIQUE COMMENT 'CUID2 identifier'"; $this->db->query($sql); echo "✅ Updated cuid length to 64 in table: $table\n"; } catch (\Exception $e) { echo "⚠️ Failed to update cuid in $table: " . $e->getMessage() . "\n"; } } echo "✅ CUID length update completed for all advertising tables\n"; } public function down(): void { // Reverter para VARCHAR(32) - cuidado: pode truncar dados se houver CUIDs > 32 chars $tables = [ 'advertising_campaigns', 'advertising_creatives', 'advertising_formats', 'advertising_site_groups', 'advertising_site_domains', 'advertising_campaign_domains' ]; foreach ($tables as $table) { try { // Verificar se a tabela existe $tableExists = $this->db->fetch("SHOW TABLES LIKE '$table'"); if (!$tableExists) { continue; } // Verificar se a coluna cuid existe $columnExists = $this->db->fetch("SHOW COLUMNS FROM $table LIKE 'cuid'"); if (!$columnExists) { continue; } $sql = "ALTER TABLE $table MODIFY COLUMN cuid VARCHAR(32) NOT NULL UNIQUE"; $this->db->query($sql); echo "✅ Reverted cuid length to 32 in table: $table\n"; } catch (\Exception $e) { echo "⚠️ Failed to revert cuid in $table: " . $e->getMessage() . "\n"; } } echo "✅ CUID length revert completed\n"; } }