-- Add new_user_only column to subscribe table
SET @column_exists = (SELECT COUNT(*)
                      FROM INFORMATION_SCHEMA.COLUMNS
                      WHERE TABLE_SCHEMA = DATABASE()
                        AND TABLE_NAME = 'subscribe'
                        AND COLUMN_NAME = 'new_user_only');
SET @sql = IF(@column_exists = 0,
              'ALTER TABLE `subscribe` ADD COLUMN `new_user_only` tinyint(1) DEFAULT 0 COMMENT ''New user only: allow purchase within 24h of registration, once per user'' AFTER `quota`',
              'SELECT 1');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
