summaryrefslogtreecommitdiff
path: root/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
diff options
context:
space:
mode:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-09-02 15:24:19 +0200
committerZ.J. van de Weg <zegerjan@gitlab.com>2016-09-05 19:15:22 +0200
commit2246218cc00e1f8db92cae7234131ca00943f567 (patch)
treef30f4ac6f1d264d06bb4c4ba86101646f7777ce4 /db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
parent553180e1c87664aae3efba01c30a345a1a2a2a00 (diff)
downloadgitlab-ce-2246218cc00e1f8db92cae7234131ca00943f567.tar.gz
Remove gitorious from import_sources on ApplicationSetting model
Diffstat (limited to 'db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb')
-rw-r--r--db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
new file mode 100644
index 00000000000..5395d38ea8f
--- /dev/null
+++ b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
@@ -0,0 +1,31 @@
+class DropGitoriousFieldFromApplicationSettings < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # After the deploy the caches will be cold anyway
+ DOWNTIME = false
+
+ def up
+ require 'yaml'
+
+ yaml = connection.execute('SELECT import_sources FROM application_settings;').values[0][0]
+ yaml = YAML.safe_load(yaml)
+ yaml.delete 'gitorious'
+
+ # No need for a WHERE clause as there is only one
+ connection.execute("UPDATE application_settings SET import_sources = #{update_yaml(yaml)}")
+ end
+
+ def down
+ # noop, gitorious still yields a 404 anyway
+ end
+
+ private
+
+ def connection
+ ActiveRecord::Base.connection
+ end
+
+ def update_yaml(yaml)
+ connection.quote(YAML.dump(yaml))
+ end
+end