USE dating_app; -- Existing users keep a NULL county until they submit an updated location. SET @column_exists = ( SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'user_profiles' AND column_name = 'county' ); SET @statement = IF( @column_exists = 0, 'ALTER TABLE user_profiles ADD COLUMN county VARCHAR(120) NULL AFTER city', 'SELECT 1' ); PREPARE migration_statement FROM @statement; EXECUTE migration_statement; DEALLOCATE PREPARE migration_statement;