summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-05-02 16:05:08 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-05-02 16:05:08 +0300
commitd10b34a685509eebbe52391ffce861cde45cc0ca (patch)
tree0df013d6d209ec62a52588eb5b9adb1bbac6b6a1 /db/migrate
parent87c397f5774c4c11ba2e4c55098920c081e53670 (diff)
downloadgitlab-ce-d10b34a685509eebbe52391ffce861cde45cc0ca.tar.gz
Save repository size to projects table
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20140502115131_add_repo_size_to_db.rb5
-rw-r--r--db/migrate/20140502125220_migrate_repo_size.rb21
2 files changed, 26 insertions, 0 deletions
diff --git a/db/migrate/20140502115131_add_repo_size_to_db.rb b/db/migrate/20140502115131_add_repo_size_to_db.rb
new file mode 100644
index 00000000000..7361d1a9440
--- /dev/null
+++ b/db/migrate/20140502115131_add_repo_size_to_db.rb
@@ -0,0 +1,5 @@
+class AddRepoSizeToDb < ActiveRecord::Migration
+ def change
+ add_column :projects, :repository_size, :float, default: 0
+ end
+end
diff --git a/db/migrate/20140502125220_migrate_repo_size.rb b/db/migrate/20140502125220_migrate_repo_size.rb
new file mode 100644
index 00000000000..eed6d366814
--- /dev/null
+++ b/db/migrate/20140502125220_migrate_repo_size.rb
@@ -0,0 +1,21 @@
+class MigrateRepoSize < ActiveRecord::Migration
+ def up
+ Project.reset_column_information
+ Project.find_each(batch_size: 500) do |project|
+ begin
+ if project.empty_repo?
+ print '-'
+ else
+ project.update_repository_size
+ print '.'
+ end
+ rescue
+ print 'F'
+ end
+ end
+ puts 'Done'
+ end
+
+ def down
+ end
+end