diff options
author | Kyle Fazzari <gitlab_cloud@status.e4ward.com> | 2014-02-26 12:38:20 -0500 |
---|---|---|
committer | Kyle Fazzari <gitlab_cloud@status.e4ward.com> | 2014-02-26 12:38:20 -0500 |
commit | a6d54b40e60d15e9e214f27cd7023225dbec5854 (patch) | |
tree | 83f15a82f23d8406ae4b81d1e6d6a5325ad9621e /db | |
parent | 75f40d7a91e0df6f4ac4df98d789597ea861314e (diff) | |
download | gitlab-ci-a6d54b40e60d15e9e214f27cd7023225dbec5854.tar.gz |
Fixed PostgreSQL cast error caused by changing the polling interval type.
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).
This fixes #3.
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20130114153451_change_schedule_invertal.rb | 20 |
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 |