diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-02 16:05:08 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-02 16:05:08 +0300 |
commit | d10b34a685509eebbe52391ffce861cde45cc0ca (patch) | |
tree | 0df013d6d209ec62a52588eb5b9adb1bbac6b6a1 /db | |
parent | 87c397f5774c4c11ba2e4c55098920c081e53670 (diff) | |
download | gitlab-ce-d10b34a685509eebbe52391ffce861cde45cc0ca.tar.gz |
Save repository size to projects table
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20140502115131_add_repo_size_to_db.rb | 5 | ||||
-rw-r--r-- | db/migrate/20140502125220_migrate_repo_size.rb | 21 | ||||
-rw-r--r-- | db/schema.rb | 3 |
3 files changed, 28 insertions, 1 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 diff --git a/db/schema.rb b/db/schema.rb index a26c60874a3..93837337afc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140428105831) do +ActiveRecord::Schema.define(version: 20140502125220) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -222,6 +222,7 @@ ActiveRecord::Schema.define(version: 20140428105831) do t.integer "visibility_level", default: 0, null: false t.boolean "archived", default: false, null: false t.string "import_status" + t.float "repository_size", default: 0.0 end add_index "projects", ["creator_id"], name: "index_projects_on_creator_id", using: :btree |