Skip to content

Backend data model for serverless domains

What does this MR do?

Implement data model for #35591 (closed), as described in #35591 (comment 250505939)

Output of migrations:

== 20191127030005 CreateServerlessDomainCluster: migrating ====================
-- create_table(:serverless_domain_cluster, {:id=>false, :primary_key=>:uuid})
   -> 0.0124s
== 20191127030005 CreateServerlessDomainCluster: migrated (0.0125s) ===========

== 20191127221608 AddWildcardAndDomainTypeToPagesDomains: migrating ===========
-- transaction_open?()
   -> 0.0000s
-- execute("SET statement_timeout TO 0")
   -> 0.0003s
-- transaction()
-- add_column(:pages_domains, :wildcard, :boolean, {:default=>nil})
   -> 0.0007s
-- change_column_default(:pages_domains, :wildcard, false)
   -> 0.0019s
   -> 0.0033s
-- columns(:pages_domains)
   -> 0.0015s
-- transaction_open?()
   -> 0.0000s
-- exec_query("SELECT COUNT(*) AS count FROM \"pages_domains\"")
   -> 0.0006s
-- exec_query("SELECT  \"pages_domains\".\"id\" FROM \"pages_domains\" ORDER BY \"pages_domains\".\"id\" ASC LIMIT 1")
   -> 0.0003s
-- exec_query("SELECT  \"pages_domains\".\"id\" FROM \"pages_domains\" WHERE \"pages_domains\".\"id\" >= 1 ORDER BY \"pages_domains\".\"id\" ASC LIMIT 1 OFFSET 1")
   -> 0.0003s
-- execute("UPDATE \"pages_domains\" SET \"wildcard\" = FALSE WHERE \"pages_domains\".\"id\" >= 1")
   -> 0.0006s
-- change_column_null(:pages_domains, :wildcard, false)
   -> 0.0005s
-- execute("RESET ALL")
   -> 0.0002s
-- transaction_open?()
   -> 0.0000s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- transaction()
-- add_column(:pages_domains, :domain_type, :integer, {:default=>nil, :limit=>2})
   -> 0.0005s
-- change_column_default(:pages_domains, :domain_type, 2)
   -> 0.0018s
   -> 0.0030s
-- columns(:pages_domains)
   -> 0.0018s
-- transaction_open?()
   -> 0.0000s
-- exec_query("SELECT COUNT(*) AS count FROM \"pages_domains\"")
   -> 0.0004s
-- exec_query("SELECT  \"pages_domains\".\"id\" FROM \"pages_domains\" ORDER BY \"pages_domains\".\"id\" ASC LIMIT 1")
   -> 0.0003s
-- exec_query("SELECT  \"pages_domains\".\"id\" FROM \"pages_domains\" WHERE \"pages_domains\".\"id\" >= 1 ORDER BY \"pages_domains\".\"id\" ASC LIMIT 1 OFFSET 1")
   -> 0.0003s
-- execute("UPDATE \"pages_domains\" SET \"domain_type\" = 2 WHERE \"pages_domains\".\"id\" >= 1")
   -> 0.0005s
-- change_column_null(:pages_domains, :domain_type, false)
   -> 0.0005s
-- execute("RESET ALL")
   -> 0.0002s
== 20191127221608 AddWildcardAndDomainTypeToPagesDomains: migrated (0.0159s) ==

== 20191206022133 AddIndexesToPagesDomainsOnWildcardAndDomainType: migrating ==
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:pages_domains, :wildcard, {:algorithm=>:concurrently})
   -> 0.0045s
-- execute("SET statement_timeout TO 0")
   -> 0.0003s
-- add_index(:pages_domains, :wildcard, {:algorithm=>:concurrently})
   -> 0.0029s
-- execute("RESET ALL")
   -> 0.0003s
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:pages_domains, :domain_type, {:algorithm=>:concurrently})
   -> 0.0033s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- add_index(:pages_domains, :domain_type, {:algorithm=>:concurrently})
   -> 0.0020s
-- execute("RESET ALL")
   -> 0.0002s
== 20191206022133 AddIndexesToPagesDomainsOnWildcardAndDomainType: migrated (0.0139s)

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)
  • Added rollback procedure. Include either a rollback procedure or description how to rollback changes

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

/cc @mattkasa

Edited by 🤖 GitLab Bot 🤖

Merge request reports