fix: add migration to re-add lid column for existing installations

Creates new migration to ensure lid column exists even in databases
where it was previously dropped by the Kafka integration migration.

Uses prepared statement to check column existence before adding,
ensuring compatibility with both fresh and existing installations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
augustolima1
2025-12-23 09:55:22 -03:00
parent d6262ca4f4
commit 0aedee53d4
@@ -0,0 +1,21 @@
-- Re-add lid column that was incorrectly dropped by previous migration
-- This migration ensures backward compatibility for existing installations
-- Check if column exists before adding
SET @dbname = DATABASE();
SET @tablename = 'IsOnWhatsapp';
SET @columnname = 'lid';
SET @preparedStatement = (SELECT IF(
(
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
WHERE
(table_name = @tablename)
AND (table_schema = @dbname)
AND (column_name = @columnname)
) > 0,
'SELECT 1',
CONCAT('ALTER TABLE `', @tablename, '` ADD COLUMN `', @columnname, '` VARCHAR(100);')
));
PREPARE alterIfNotExists FROM @preparedStatement;
EXECUTE alterIfNotExists;
DEALLOCATE PREPARE alterIfNotExists;