Add dedicated group accounts flag & feature flag

Merged Pavel Shutsin requested to merge sso-dedicated-group-accounts-flag into master

What does this MR do?

This MR creates a database flag and feature flag for dedicated group accounts feature. See

Database checklist

When adding migrations:

  • Updated db/schema.rb
  • Added a down method so the migration can be reverted
  • Added the output of the migration(s) to the MR body
  • Added tests for the migration in spec/migrations if necessary (e.g. when migrating data)

When adding or modifying queries to improve performance:

  • Included data that shows the performance improvement, preferably in the form of a benchmark
  • Included the output of EXPLAIN (ANALYZE, BUFFERS) of the relevant queries

When adding foreign keys to existing tables:

  • Included a migration to remove orphaned rows in the source table before adding the foreign key
  • Removed any instances of dependent: ... that may no longer be necessary

When adding tables:

  • Ordered columns based on the Ordering Table Columns guidelines
  • Added foreign keys to any columns pointing to data in other tables
  • Added indexes for fields that are used in statements such as WHERE, ORDER BY, GROUP BY, and JOINs

When removing columns, tables, indexes or other structures:

  • Removed these in a post-deployment migration
  • Made sure the application no longer uses (or ignores) these structures

General checklist

Migration output:

== 20190220112238 AddSamlProviderDedicatedAccountsFlag: migrating =============
-- transaction_open?()
   -> 0.0000s
-- execute("SET statement_timeout TO 0")
   -> 0.0006s
-- transaction()
-- add_column(:saml_providers, :dedicated_accounts, :boolean, {:default=>nil})
   -> 0.0092s
-- change_column_default(:saml_providers, :dedicated_accounts, false)
   -> 0.0077s
   -> 0.0184s
-- transaction_open?()
   -> 0.0000s
-- exec_query("SELECT COUNT(*) AS count FROM \"saml_providers\"")
   -> 0.0021s
-- exec_query("SELECT  \"saml_providers\".\"id\" FROM \"saml_providers\" ORDER BY \"saml_providers\".\"id\" ASC LIMIT 1")
   -> 0.0019s
-- exec_query("SELECT  \"saml_providers\".\"id\" FROM \"saml_providers\" WHERE \"saml_providers\".\"id\" >= 1 ORDER BY \"saml_providers\".\"id\" ASC LIMIT 1 OFFSET 1")
   -> 0.0008s
-- execute("UPDATE \"saml_providers\" SET \"dedicated_accounts\" = 'f' WHERE \"saml_providers\".\"id\" >= 1")
   -> 0.0084s
-- change_column_null(:saml_providers, :dedicated_accounts, false)
   -> 0.0007s
-- execute("RESET ALL")
   -> 0.0003s
== 20190220112238 AddSamlProviderDedicatedAccountsFlag: migrated (0.0369s) ====
Edited by Pavel Shutsin