From 515f84ded70a67170df664b2222501e28d58b9f5 Mon Sep 17 00:00:00 2001 From: Alex Young Date: Tue, 31 Mar 2015 11:29:30 +0100 Subject: Use DROP VIEW on postgres, DROP TABLE on sqlite --- lib/mauve/alert.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/mauve/alert.rb b/lib/mauve/alert.rb index e8647f7..4cee65f 100644 --- a/lib/mauve/alert.rb +++ b/lib/mauve/alert.rb @@ -30,18 +30,20 @@ module Mauve the_distant_future = (Time.now + 2000.days).to_i # it is the year 2000 - the humans are dead case DataMapper.repository(:default).adapter.class.to_s - when "DataMapper::Adapters::PostgresAdapter" - ifnull = "COALESCE" - min = "LEAST" - else - ifnull = "IFNULL" - min = "MIN" + when "DataMapper::Adapters::PostgresAdapter" + ifnull = "COALESCE" + min = "LEAST" + drop_view = "DROP VIEW" + else + ifnull = "IFNULL" + min = "MIN" + # This was previously a DROP VIEW, but the sqlite adapter complains + # about DROP VIEW here. + drop_view = "DROP TABLE" end ["BEGIN TRANSACTION", - # This was previously a DROP VIEW, but the sqlite adapter complains - # about DROP VIEW here. - "DROP TABLE IF EXISTS mauve_alert_earliest_dates", + "#{drop_view} IF EXISTS mauve_alert_earliest_dates", "CREATE VIEW mauve_alert_earliest_dates AS -- cgit v1.2.1