Skip to content

Create namespace_ldap_settings table to move columns from namespaces

Drew Blessing requested to merge dblessing_create_namespace_ldap_settings into master

What does this MR do and why?

Describe in detail what your merge request does and why.

Related to #349198

Creates namespace_ldap_settings table so we can migrate data from namespaces ldap_sync_* columns and reduce the table width.

This MR creates the new table and columns and backfills the timestamp and error message. This does not add a trigger or mechanism to keep the columns updated. That isn't necessary because this data is fairly ephemeral - groups that have an ongoing sync are updated every hour. The only reason to even bother backfilling this data is to ensure some historical reference to when the last sync happened, and the error message, if any, in case syncs are no longer happening for that group.

The next MR will add the state machine to the new model and update usage. A final MR will remove the columns in namespaces.

Database

Migrate

Click to expand
main: == 20230113164245 CreateNamespaceLdapSettings: migrating ======================
main: -- create_table(:namespace_ldap_settings, {:if_not_exists=>true, :id=>false})
main: -- quote_column_name(:sync_status)
main:    -> 0.0000s
main: -- quote_column_name(:sync_error)
main:    -> 0.0000s
main:    -> 0.0068s
main: == 20230113164245 CreateNamespaceLdapSettings: migrated (0.0082s) =============

main: == 20230113201308 BackfillNamespaceLdapSettings: migrating ==================== main: == 20230113201308 BackfillNamespaceLdapSettings: migrated (0.0473s) ===========

ci: == 20230113164245 CreateNamespaceLdapSettings: migrating ====================== ci: -- create_table(:namespace_ldap_settings, {:if_not_exists=>true, :id=>false}) ci: -- quote_column_name(:sync_status) ci: -> 0.0000s ci: -- quote_column_name(:sync_error) ci: -> 0.0000s ci: -> 0.0053s ci: == 20230113164245 CreateNamespaceLdapSettings: migrated (0.0104s) =============

ci: == 20230113201308 BackfillNamespaceLdapSettings: migrating ==================== ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main]. ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_shared, :gitlab_internal]. ci: == 20230113201308 BackfillNamespaceLdapSettings: migrated (0.0047s) ===========

Rollback

Click to expand
main: == 20230113201308 BackfillNamespaceLdapSettings: reverting ====================
main: == 20230113201308 BackfillNamespaceLdapSettings: reverted (0.0339s) ===========

main: == 20230113164245 CreateNamespaceLdapSettings: reverting ====================== main: -- drop_table(:namespace_ldap_settings, {:if_not_exists=>true, :id=>false}) main: -> 0.0186s main: == 20230113164245 CreateNamespaceLdapSettings: reverted (0.0235s) =============

ci: == 20230113201308 BackfillNamespaceLdapSettings: reverting ==================== ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main]. ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_shared, :gitlab_internal]. ci: == 20230113201308 BackfillNamespaceLdapSettings: reverted (0.0081s) ===========

ci: == 20230113164245 CreateNamespaceLdapSettings: reverting ====================== ci: -- drop_table(:namespace_ldap_settings, {:if_not_exists=>true, :id=>false}) ci: -> 0.0128s ci: == 20230113164245 CreateNamespaceLdapSettings: reverted (0.0544s) =============

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

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 Drew Blessing

Merge request reports