diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-02 17:05:08 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-02 17:05:08 +0400 |
commit | d10b34a685509eebbe52391ffce861cde45cc0ca (patch) | |
tree | 0df013d6d209ec62a52588eb5b9adb1bbac6b6a1 /db/migrate | |
parent | 87c397f5774c4c11ba2e4c55098920c081e53670 (diff) |
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.rb | 5 | ||||
-rw-r--r-- | db/migrate/20140502125220_migrate_repo_size.rb | 21 |
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 |