summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-05-05 17:52:59 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-05-05 17:52:59 +0000
commit99a14cb59b4ae94995b959d7fd4f378aa3c57cf6 (patch)
treeb1f70b2876759063cf4c95b4dbcb87ce1d32a69f
parent6fa1c12973d5f166cc4b0ac6de853950d64acad4 (diff)
parenta6d54b40e60d15e9e214f27cd7023225dbec5854 (diff)
downloadgitlab-ci-99a14cb59b4ae94995b959d7fd4f378aa3c57cf6.tar.gz
Merge branch 'bugfix/3/fix_polling_interval_column_change_cast_error_in_postgresql' into 'master'
Fix Polling Interval Column Change Cast Error In Postgresql This merge request fixes issue #3. This was done by adding SQL specifically for PostgreSQL making use of the USING clause to successfully cast from string to integer (and vice-versa for down). See the [PostgreSQL docs](http://www.postgresql.org/docs/9.1/interactive/sql-altertable.html) for more information.
-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