diff options
author | Alex Young <alex@bytemark.co.uk> | 2015-03-31 11:29:30 +0100 |
---|---|---|
committer | Alex Young <alex@bytemark.co.uk> | 2015-03-31 11:29:30 +0100 |
commit | 515f84ded70a67170df664b2222501e28d58b9f5 (patch) | |
tree | f9beefe2395f4e0883aff083090456d6cdf7d571 /lib/mauve | |
parent | 49d462c6e2b92e254534cedca1e856079a456749 (diff) |
Use DROP VIEW on postgres, DROP TABLE on sqlite
Diffstat (limited to 'lib/mauve')
-rw-r--r-- | lib/mauve/alert.rb | 20 |
1 files changed, 11 insertions, 9 deletions
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 |