Skip to content

Remove never-used appearances.updated_by column

Gregory Stark requested to merge remove-unused-updated-by-column into master

Remove the appearances.updated_by column which appears to have been added to schema.rb but was never added in a migration. This has caused inconsistencies between developer and customer databases and caused schema.rb to vary from one state and the other over time.

In commit 40104eea the appearances table was added with the updated_by column but the 20160222153918_create_appearances_ce.rb migration in commit 9a2869ab never added the updated_by column. As a result the schema.rb has flipped back and forth several times since as different developers have checked in schemas with or without this column....

It's not used so let's remove it once and for all.

stark@tweedle:~/gitlab/gdk/gitlab-development-kit/gitlab$ bundle exec rake db:rollback
== 20171002160123 RemoveNeverUsedUpdatedBy: reverting =========================
-- add_column(:appearances, :updated_by, :integer)
   -> 0.0089s
== 20171002160123 RemoveNeverUsedUpdatedBy: reverted (0.0090s) ================

stark@tweedle:~/gitlab/gdk/gitlab-development-kit/gitlab$ bundle exec rake db:migrate
== 20171002160123 RemoveNeverUsedUpdatedBy: migrating =========================
-- column_exists?(:appearances, :updated_by)
   -> 0.0016s
-- remove_column(:appearances, :updated_by)
   -> 0.0190s
== 20171002160123 RemoveNeverUsedUpdatedBy: migrated (0.0208s) ================

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 the execution time of the migration(s) to the MR body
  • Added tests for the migration in spec/migrations if necessary (e.g. when migrating data)
  • Made sure the migration won't interfere with a running GitLab cluster, for example by disabling transactions for long running migrations

When adding or modifying queries to improve performance:

  • Included the raw SQL queries of the relevant queries
  • Included the output of EXPLAIN ANALYZE and execution timings of the relevant queries
  • Added tests for the relevant changes

When adding indexes:

  • Described the need for these indexes in the MR body
  • Made sure existing indexes can not be reused instead

When adding foreign keys to existing tables:

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

When adding tables:

  • Ordered columns based on their type sizes in descending order
  • Added foreign keys if necessary
  • Added indexes if necessary

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

Edited by Gregory Stark

Merge request reports