From 06227a5d29ca574fddbc6faede1b5ae0782d5ad1 Mon Sep 17 00:00:00 2001 From: Beni Cherniavsky-Paskin Date: Wed, 10 Jan 2018 14:27:34 +0200 Subject: [PATCH] Change container_quota_items float columns to decimals Fixes https://github.com/ManageIQ/manageiq-providers-kubernetes/issues/208 Kubernetes quotas are mostly integers but cpu-related quotas are in "millicores", multiples of 0.001. With decimal columns, we'll be able to round-trip quotas exactly to DB and back to Ruby, so refresh can determine whether they changed or not. https://bugzilla.redhat.com/show_bug.cgi?id=1504560 --- ...1417_change_container_quota_items_to_decimals.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/migrate/20180118131417_change_container_quota_items_to_decimals.rb diff --git a/db/migrate/20180118131417_change_container_quota_items_to_decimals.rb b/db/migrate/20180118131417_change_container_quota_items_to_decimals.rb new file mode 100644 index 000000000..d64d1cab4 --- /dev/null +++ b/db/migrate/20180118131417_change_container_quota_items_to_decimals.rb @@ -0,0 +1,13 @@ +class ChangeContainerQuotaItemsToDecimals < ActiveRecord::Migration[5.0] + def up + %i(quota_desired quota_enforced quota_observed).each do |column| + change_column :container_quota_items, column, :decimal, :scale => 3, :precision => 30 + end + end + + def down + %i(quota_desired quota_enforced quota_observed).each do |column| + change_column :container_quota_items, column, :float + end + end +end