Commit c1e1970e authored by Tiger Watson's avatar Tiger Watson

Merge branch 'store-seats_currently_in_use' into 'master'

Add seats_in_use and seats_owed to gitlab_subscriptions

See merge request gitlab-org/gitlab!40470
parents 001b718a f218e2da
---
title: Add seats related columns for easier data analysis
merge_request: 40470
author:
type: other
# frozen_string_literal: true
class AddSeatsCurrentlyInUseInGitlabSubscriptions < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
add_column :gitlab_subscriptions, :seats_in_use, :integer, default: 0, null: false
add_column :gitlab_subscriptions, :seats_owed, :integer, default: 0, null: false
end
end
def down
with_lock_retries do
remove_column :gitlab_subscriptions, :seats_in_use
remove_column :gitlab_subscriptions, :seats_owed
end
end
end
bdcfd7dbccc73d6e2754d67bf099cc2dd2b919e4125cec47e853ff91911cc82e
\ No newline at end of file
......@@ -12133,7 +12133,9 @@ CREATE TABLE public.gitlab_subscriptions (
seats integer DEFAULT 0,
trial boolean DEFAULT false,
trial_starts_on date,
auto_renew boolean
auto_renew boolean,
seats_in_use integer DEFAULT 0 NOT NULL,
seats_owed integer DEFAULT 0 NOT NULL
);
CREATE SEQUENCE public.gitlab_subscriptions_id_seq
......
......@@ -99,7 +99,7 @@ class GitlabSubscription < ApplicationRecord
attrs['gitlab_subscription_id'] = self.id
attrs['change_type'] = change_type
omitted_attrs = %w(id created_at updated_at)
omitted_attrs = %w(id created_at updated_at seats_in_use seats_owed)
GitlabSubscriptionHistory.create(attrs.except(*omitted_attrs))
end
......
......@@ -324,7 +324,7 @@ RSpec.describe GitlabSubscription do
end
it 'gitlab_subscription columns are contained in gitlab_subscription_history columns' do
diff_attrs = %w(updated_at)
diff_attrs = %w(updated_at seats_in_use seats_owed)
expect(described_class.attribute_names - GitlabSubscriptionHistory.attribute_names).to eq(diff_attrs)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment