Created
February 20, 2012 15:52
-
-
Save jmlweb/1869810 to your computer and use it in GitHub Desktop.
Verificar que no exista una columna antes de añadirla
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER $$ | |
DROP PROCEDURE IF EXISTS add_has_detail_column $$ | |
CREATE PROCEDURE add_has_detail_column() | |
BEGIN | |
IF NOT EXISTS(SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME= 'events' AND COLUMN_NAME = 'has_detail') THEN | |
ALTER TABLE `events` ADD COLUMN `has_detail` BOOLEAN NOT NULL DEFAULT 1 AFTER `is_migrated`; | |
END IF; | |
END $$ | |
CALL add_has_detail_column() $$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment