Update PagesDomains data model for serverless domains
What does this MR do?
Update data model of PagesDomains in response to discussion in !21222 (merged).
- Add
usage
enum to distinguish between serverless and pages domains - Replace unique index on
domain
with unique index on[domain, wildcard]
so that the wildcard and non-wildcard variants of a domain can coexist - Rename
domain_type
toscope
to be more semantic
/cc @ayufan @krasio @grzesiek @mattkasa
Output of migrations
== 20200128184209 AddUsageToPagesDomains: migrating ===========================
-- transaction_open?()
-> 0.0000s
-- execute("SET statement_timeout TO 0")
-> 0.0003s
-- transaction()
-- add_column(:pages_domains, :usage, :integer, {:default=>nil, :limit=>2})
-> 0.0013s
-- change_column_default(:pages_domains, :usage, 0)
-> 0.0039s
-> 0.0083s
-- columns(:pages_domains)
-> 0.0020s
-- transaction_open?()
-> 0.0000s
-- exec_query("SELECT COUNT(*) AS count FROM \"pages_domains\"")
-> 0.0018s
-- change_column_null(:pages_domains, :usage, false)
-> 0.0006s
-- execute("RESET ALL")
-> 0.0003s
== 20200128184209 AddUsageToPagesDomains: migrated (0.0136s) ==================
== 20200129034515 UpdateIndexesOfPagesDomainsAddUsageDomainWildcardRemoveDomain: migrating
-- transaction_open?()
-> 0.0000s
-- index_exists?(:pages_domains, :usage, {:algorithm=>:concurrently})
-> 0.0051s
-- execute("SET statement_timeout TO 0")
-> 0.0003s
-- add_index(:pages_domains, :usage, {:algorithm=>:concurrently})
-> 0.0055s
-- execute("RESET ALL")
-> 0.0002s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:pages_domains, [:domain, :wildcard], {:unique=>true, :algorithm=>:concurrently})
-> 0.0032s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- add_index(:pages_domains, [:domain, :wildcard], {:unique=>true, :algorithm=>:concurrently})
-> 0.0023s
-- execute("RESET ALL")
-> 0.0002s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:pages_domains, :domain, {:algorithm=>:concurrently})
-> 0.0037s
-- execute("SET statement_timeout TO 0")
-> 0.0003s
-- remove_index(:pages_domains, {:algorithm=>:concurrently, :column=>:domain})
-> 0.0072s
-- execute("RESET ALL")
-> 0.0002s
== 20200129034515 UpdateIndexesOfPagesDomainsAddUsageDomainWildcardRemoveDomain: migrated (0.0289s)
== 20200129035446 RenamePagesDomainsDomainTypeToScope: migrating ==============
-- transaction_open?()
-> 0.0000s
-- columns(:pages_domains)
-> 0.0024s
-- add_column(:pages_domains, :scope, :integer, {:limit=>2, :precision=>nil, :scale=>nil})
-> 0.0009s
-- change_column_default(:pages_domains, :scope, "2")
-> 0.0027s
-- transaction_open?()
-> 0.0000s
-- exec_query("SELECT COUNT(*) AS count FROM \"pages_domains\"")
-> 0.0006s
-- change_column_null(:pages_domains, :scope, false)
-> 0.0007s
-- indexes(:pages_domains)
-> 0.0041s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:pages_domains, ["scope"], {:unique=>false, :name=>"index_pages_domains_on_scope", :length=>{}, :order=>{}, :using=>:btree, :algorithm=>:concurrently})
-> 0.0042s
-- execute("SET statement_timeout TO 0")
-> 0.0003s
-- add_index(:pages_domains, ["scope"], {:unique=>false, :name=>"index_pages_domains_on_scope", :length=>{}, :order=>{}, :using=>:btree, :algorithm=>:concurrently})
-> 0.0028s
-- execute("RESET ALL")
-> 0.0003s
-- foreign_keys(:pages_domains)
-> 0.0024s
-- quote_table_name(:pages_domains)
-> 0.0000s
-- quote_column_name(:domain_type)
-> 0.0000s
-- quote_column_name(:scope)
-> 0.0000s
-- execute("CREATE OR REPLACE FUNCTION trigger_5e971e2e2c26()\nRETURNS trigger AS\n$BODY$\nBEGIN\n NEW.\"scope\" := NEW.\"domain_type\";\n RETURN NEW;\nEND;\n$BODY$\nLANGUAGE 'plpgsql'\nVOLATILE\n")
-> 0.0055s
-- execute("DROP TRIGGER IF EXISTS trigger_5e971e2e2c26\nON \"pages_domains\"\n")
NOTICE: trigger "trigger_5e971e2e2c26" for relation "pages_domains" does not exist, skipping
-> 0.0004s
-- execute("CREATE TRIGGER trigger_5e971e2e2c26\nBEFORE INSERT OR UPDATE\nON \"pages_domains\"\nFOR EACH ROW\nEXECUTE PROCEDURE trigger_5e971e2e2c26()\n")
-> 0.0008s
== 20200129035446 RenamePagesDomainsDomainTypeToScope: migrated (0.0547s) =====
== 20200129035708 CleanupRenamePagesDomainsDomainTypeToScope: migrating =======
-- execute("DROP TRIGGER IF EXISTS trigger_5e971e2e2c26 ON pages_domains")
-> 0.0007s
-- execute("DROP FUNCTION IF EXISTS trigger_5e971e2e2c26()")
-> 0.0005s
-- remove_column(:pages_domains, :domain_type)
-> 0.0017s
== 20200129035708 CleanupRenamePagesDomainsDomainTypeToScope: migrated (0.0221s)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖