diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2019-06-13 00:11:14 +0300 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-06-25 17:54:47 +0300 |
commit | bde41ee866d0fe0b1bb5ece1130fb6e24d95ad17 (patch) | |
tree | 8d52bc34eb73832357142b1cf5cb34a372b27f7f /db/migrate | |
parent | d6c7d4c48db51fdc3eb479e53d40ce4358695218 (diff) |
Add two new ActiveRecord models
- Namespace::Storagestatistics will persist root namespace statistics
- Namespace::AggregationSchedule will save information when a new update
to the namespace statistics needs to be scheduled
Both tables use 'namespace_id' as primary key
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20190531153110_create_namespace_root_storage_statistics.rb | 22 | ||||
-rw-r--r-- | db/migrate/20190605184422_create_namespace_aggregation_schedules.rb | 14 |
2 files changed, 36 insertions, 0 deletions
diff --git a/db/migrate/20190531153110_create_namespace_root_storage_statistics.rb b/db/migrate/20190531153110_create_namespace_root_storage_statistics.rb new file mode 100644 index 00000000000..702560d05cc --- /dev/null +++ b/db/migrate/20190531153110_create_namespace_root_storage_statistics.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class CreateNamespaceRootStorageStatistics < ActiveRecord::Migration[5.1] + DOWNTIME = false + + def change + create_table :namespace_root_storage_statistics, id: false, primary_key: :namespace_id do |t| + t.integer :namespace_id, null: false, primary_key: true + t.datetime_with_timezone :updated_at, null: false + + t.bigint :repository_size, null: false, default: 0 + t.bigint :lfs_objects_size, null: false, default: 0 + t.bigint :wiki_size, null: false, default: 0 + t.bigint :build_artifacts_size, null: false, default: 0 + t.bigint :storage_size, null: false, default: 0 + t.bigint :packages_size, null: false, default: 0 + + t.index :namespace_id, unique: true + t.foreign_key :namespaces, column: :namespace_id, on_delete: :cascade + end + end +end diff --git a/db/migrate/20190605184422_create_namespace_aggregation_schedules.rb b/db/migrate/20190605184422_create_namespace_aggregation_schedules.rb new file mode 100644 index 00000000000..5e8cb616cc1 --- /dev/null +++ b/db/migrate/20190605184422_create_namespace_aggregation_schedules.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CreateNamespaceAggregationSchedules < ActiveRecord::Migration[5.1] + DOWNTIME = false + + def change + create_table :namespace_aggregation_schedules, id: false, primary_key: :namespace_id do |t| + t.integer :namespace_id, null: false, primary_key: true + + t.index :namespace_id, unique: true + t.foreign_key :namespaces, column: :namespace_id, on_delete: :cascade + end + end +end |