- 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
87 lines
3.1 KiB
PHP
87 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Advertising\Database\Migrations;
|
|
|
|
use App\Core\Database\Migration;
|
|
|
|
class UpdateCuidLengthTo64 extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
// Tabelas que precisam ter o campo cuid atualizado para VARCHAR(64)
|
|
$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) {
|
|
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";
|
|
}
|
|
} |