From 504e8d2bb47371a5d7fe9df957d3881cd1458f82 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 11 Apr 2013 17:04:22 +0000 Subject: [PATCH] use a pseudo "add index if not exists" statement --- db_scripts/diff/13474.up | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db_scripts/diff/13474.up b/db_scripts/diff/13474.up index 9d4b1f50..1107165f 100644 --- a/db_scripts/diff/13474.up +++ b/db_scripts/diff/13474.up @@ -1,2 +1,5 @@ use billing; -create index bfhsems_idx on billing_fees_history (billing_profile_id,bf_id,type,destination) using btree; +set @exist := (select count(*) from information_schema.statistics where table_name = 'billing_fees_history' and index_name = 'bfhsems_idx'); +set @sqlstmt := if( @exist > 0, 'select ''INFO: Index already exists.''', 'create index bfhsems_idx on billing_fees_history (billing_profile_id,bf_id,type,destination) using btree'); +PREPARE stmt FROM @sqlstmt; +EXECUTE stmt;