summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/migrate/20130114153451_change_schedule_invertal.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/db/migrate/20130114153451_change_schedule_invertal.rb b/db/migrate/20130114153451_change_schedule_invertal.rb
index 28bc056..ef6ece8 100644
--- a/db/migrate/20130114153451_change_schedule_invertal.rb
+++ b/db/migrate/20130114153451_change_schedule_invertal.rb
@@ -1,9 +1,25 @@
class ChangeScheduleInvertal < ActiveRecord::Migration
def up
- change_column :projects, :polling_interval, :integer, null: true
+ if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
+ connection.execute(%q{
+ ALTER TABLE projects
+ ALTER COLUMN polling_interval
+ TYPE integer USING CAST(polling_interval AS integer)
+ })
+ else
+ change_column :projects, :polling_interval, :integer, null: true
+ end
end
def down
- change_column :projects, :polling_interval, :string, null: true
+ if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
+ connection.execute(%q{
+ ALTER TABLE projects
+ ALTER COLUMN polling_interval
+ TYPE integer USING CAST(polling_interval AS varchar)
+ })
+ else
+ change_column :projects, :polling_interval, :string, null: true
+ end
end
end