Skip to content

Add database structure for add-ons

Corinna Gogolok requested to merge 408494_add_add_on_database_tables into master

What does this MR do and why?

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/408494+

This change adds the models and their database tables for add-ons.

Database migrations

Up migrations

main: == [advisory_lock_connection] object_id: 227960, pg_backend_pid: 29328
main: == 20230531135001 CreateSubscriptionAddOnPurchases: migrating =================
main: -- create_table(:subscription_add_on_purchases, {:if_not_exists=>true})
main: -- quote_column_name(:purchase_xid)
main:    -> 0.0000s
main:    -> 0.0064s
main: == 20230531135001 CreateSubscriptionAddOnPurchases: migrated (0.0983s) ========

main: == 20230531142032 AddForeignKeySubscriptionAddOnIdOnSubscriptionAddOnPurchases: migrating 
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE subscription_add_on_purchases ADD CONSTRAINT fk_410004d68b FOREIGN KEY (subscription_add_on_id) REFERENCES subscription_add_ons (id) ON DELETE CASCADE NOT VALID;")
main:    -> 0.0015s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- execute("ALTER TABLE subscription_add_on_purchases VALIDATE CONSTRAINT fk_410004d68b;")
main:    -> 0.0015s
main: -- execute("RESET statement_timeout")
main:    -> 0.0007s
main: == 20230531142032 AddForeignKeySubscriptionAddOnIdOnSubscriptionAddOnPurchases: migrated (0.0380s) 

main: == 20230531142053 AddForeignKeyNamespaceIdOnSubscriptionAddOnPurchases: migrating 
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE subscription_add_on_purchases ADD CONSTRAINT fk_a1db288990 FOREIGN KEY (namespace_id) REFERENCES namespaces (id) ON DELETE CASCADE NOT VALID;")
main:    -> 0.0012s
main: -- execute("ALTER TABLE subscription_add_on_purchases VALIDATE CONSTRAINT fk_a1db288990;")
main:    -> 0.0036s
main: == 20230531142053 AddForeignKeyNamespaceIdOnSubscriptionAddOnPurchases: migrated (0.0213s) 

main: == [advisory_lock_connection] object_id: 227960, pg_backend_pid: 29328
ci: == [advisory_lock_connection] object_id: 228480, pg_backend_pid: 29339
ci: == 20230531135001 CreateSubscriptionAddOnPurchases: migrating =================
ci: -- create_table(:subscription_add_on_purchases, {:if_not_exists=>true})
ci: -- quote_column_name(:purchase_xid)
ci:    -> 0.0001s
ci:    -> 0.0086s
I, [2023-06-07T11:09:14.903688 #28830]  INFO -- : Database: 'ci', Table: 'subscription_add_on_purchases': Lock Writes
ci: == 20230531135001 CreateSubscriptionAddOnPurchases: migrated (0.0194s) ========

ci: == 20230531142032 AddForeignKeySubscriptionAddOnIdOnSubscriptionAddOnPurchases: migrating 
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE subscription_add_on_purchases ADD CONSTRAINT fk_410004d68b FOREIGN KEY (subscription_add_on_id) REFERENCES subscription_add_ons (id) ON DELETE CASCADE NOT VALID;")
ci:    -> 0.0013s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0002s
ci: -- execute("ALTER TABLE subscription_add_on_purchases VALIDATE CONSTRAINT fk_410004d68b;")
ci:    -> 0.0014s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0002s
ci: == 20230531142032 AddForeignKeySubscriptionAddOnIdOnSubscriptionAddOnPurchases: migrated (0.0254s) 

ci: == 20230531142053 AddForeignKeyNamespaceIdOnSubscriptionAddOnPurchases: migrating 
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE subscription_add_on_purchases ADD CONSTRAINT fk_a1db288990 FOREIGN KEY (namespace_id) REFERENCES namespaces (id) ON DELETE CASCADE NOT VALID;")
ci:    -> 0.0013s
ci: -- execute("ALTER TABLE subscription_add_on_purchases VALIDATE CONSTRAINT fk_a1db288990;")
ci:    -> 0.0023s
ci: == 20230531142053 AddForeignKeyNamespaceIdOnSubscriptionAddOnPurchases: migrated (0.0217s) 

ci: == [advisory_lock_connection] object_id: 228480, pg_backend_pid: 29339

Down migrations

ci: == [advisory_lock_connection] object_id: 227720, pg_backend_pid: 30109
ci: == 20230531142053 AddForeignKeyNamespaceIdOnSubscriptionAddOnPurchases: reverting 
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- remove_foreign_key(:subscription_add_on_purchases, {:column=>:namespace_id})
ci:    -> 0.0042s
ci: == 20230531142053 AddForeignKeyNamespaceIdOnSubscriptionAddOnPurchases: reverted (0.0387s) 

ci: == 20230531142032 AddForeignKeySubscriptionAddOnIdOnSubscriptionAddOnPurchases: reverting 
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- remove_foreign_key(:subscription_add_on_purchases, {:column=>:subscription_add_on_id})
ci:    -> 0.0030s
ci: == 20230531142032 AddForeignKeySubscriptionAddOnIdOnSubscriptionAddOnPurchases: reverted (0.0167s) 

ci: == 20230531135001 CreateSubscriptionAddOnPurchases: reverting =================
ci: -- drop_table(:subscription_add_on_purchases, {:if_not_exists=>true})
ci:    -> 0.0013s
ci: == 20230531135001 CreateSubscriptionAddOnPurchases: reverted (0.0128s) ========

ci: == [advisory_lock_connection] object_id: 227720, pg_backend_pid: 30109

main: == [advisory_lock_connection] object_id: 227720, pg_backend_pid: 30527
main: == 20230531142053 AddForeignKeyNamespaceIdOnSubscriptionAddOnPurchases: reverting 
main: -- transaction_open?()
main:    -> 0.0000s
main: -- remove_foreign_key(:subscription_add_on_purchases, {:column=>:namespace_id})
main:    -> 0.0041s
main: == 20230531142053 AddForeignKeyNamespaceIdOnSubscriptionAddOnPurchases: reverted (0.0271s) 

main: == 20230531142032 AddForeignKeySubscriptionAddOnIdOnSubscriptionAddOnPurchases: reverting 
main: -- transaction_open?()
main:    -> 0.0000s
main: -- remove_foreign_key(:subscription_add_on_purchases, {:column=>:subscription_add_on_id})
main:    -> 0.0027s
main: == 20230531142032 AddForeignKeySubscriptionAddOnIdOnSubscriptionAddOnPurchases: reverted (0.0081s) 

main: == 20230531135001 CreateSubscriptionAddOnPurchases: reverting =================
main: -- drop_table(:subscription_add_on_purchases, {:if_not_exists=>true})
main:    -> 0.0012s
main: == 20230531135001 CreateSubscriptionAddOnPurchases: reverted (0.0062s) ========

main: == [advisory_lock_connection] object_id: 227720, pg_backend_pid: 30527

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Corinna Gogolok

Merge request reports

Loading