diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-12-27 16:34:20 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-12-27 16:34:20 +0000 |
commit | 6024697c100e003ec456b9ad2e9461d73250dbb8 (patch) | |
tree | bdcf59573e81e21b1d43b09a47b399f1028f3ee6 /db/migrate/20161201160452_migrate_project_statistics.rb | |
parent | 123bc1d5ebc102c75456b54cbce8f1ec1bfe0eff (diff) | |
parent | f264ec6ee74a0263b4e5212e921c4638c25f8fcd (diff) | |
download | gitlab-ce-6024697c100e003ec456b9ad2e9461d73250dbb8.tar.gz |
Merge branch 'master' into 'dz-rename-reserved-project-names'
# Conflicts:
# db/schema.rb
Diffstat (limited to 'db/migrate/20161201160452_migrate_project_statistics.rb')
-rw-r--r-- | db/migrate/20161201160452_migrate_project_statistics.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20161201160452_migrate_project_statistics.rb b/db/migrate/20161201160452_migrate_project_statistics.rb new file mode 100644 index 00000000000..3ae3f2c159b --- /dev/null +++ b/db/migrate/20161201160452_migrate_project_statistics.rb @@ -0,0 +1,23 @@ +class MigrateProjectStatistics < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = true + DOWNTIME_REASON = 'Removes two columns from the projects table' + + def up + # convert repository_size in float (megabytes) to integer (bytes), + # initialize total storage_size with repository_size + execute <<-EOF + INSERT INTO project_statistics (project_id, namespace_id, commit_count, storage_size, repository_size) + SELECT id, namespace_id, commit_count, (repository_size * 1024 * 1024), (repository_size * 1024 * 1024) FROM projects + EOF + + remove_column :projects, :repository_size + remove_column :projects, :commit_count + end + + def down + add_column_with_default :projects, :repository_size, :float, default: 0.0 + add_column_with_default :projects, :commit_count, :integer, default: 0 + end +end |