summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-05-04 18:11:20 +0300
committerValery Sizov <vsv2711@gmail.com>2015-05-04 18:11:20 +0300
commitce534e9395b9c6eaaef7400547a5adc613f046a7 (patch)
treec869863d978a26d4864436d91d129b635c18d564 /db/migrate
parent5b7589664297fd066324acfb9b6eafe2ad1d432c (diff)
downloadgitlab-ci-ce534e9395b9c6eaaef7400547a5adc613f046a7.tar.gz
Refactoring. Clean up advanced settings. Migrate from gotlab_url to path
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20150504010150_migrate_url_to_path.rb11
-rw-r--r--db/migrate/20150504010250_rename_gitlab_url_to_path.rb5
2 files changed, 16 insertions, 0 deletions
diff --git a/db/migrate/20150504010150_migrate_url_to_path.rb b/db/migrate/20150504010150_migrate_url_to_path.rb
new file mode 100644
index 0000000..31d8c54
--- /dev/null
+++ b/db/migrate/20150504010150_migrate_url_to_path.rb
@@ -0,0 +1,11 @@
+class MigrateUrlToPath < ActiveRecord::Migration
+ def up
+ select_all("SELECT id, gitlab_url FROM projects").each do |project|
+ path = project['gitlab_url'].sub(/.*\/(.*\/.*)$/, '\1')
+ execute("UPDATE projects SET gitlab_url = '#{path}' WHERE id = '#{project['id']}'")
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/20150504010250_rename_gitlab_url_to_path.rb b/db/migrate/20150504010250_rename_gitlab_url_to_path.rb
new file mode 100644
index 0000000..6040c32
--- /dev/null
+++ b/db/migrate/20150504010250_rename_gitlab_url_to_path.rb
@@ -0,0 +1,5 @@
+class RenameGitlabUrlToPath < ActiveRecord::Migration
+ def change
+ rename_column :projects, :gitlab_url, :path
+ end
+end