summaryrefslogtreecommitdiff
path: root/db/migrate/20170809142252_cleanup_appearances_schema.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-08-09 16:41:51 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2017-08-10 12:45:49 +0200
commit26bb50412ce44be434d7bb86a952397b7983deb5 (patch)
treeae68cd680fc814930299c2c68f414bc2edb70757 /db/migrate/20170809142252_cleanup_appearances_schema.rb
parent53ee38053cb924b57447e385dee2a45b8e759ff5 (diff)
downloadgitlab-ce-26bb50412ce44be434d7bb86a952397b7983deb5.tar.gz
Cache Appearance instances in Redisappearances-caching-and-schema
This caches the result of Appearance.first in a similar fashion to how ApplicationSetting instances are cached. We also add some NOT NULL constraints to the table and correct the timestamp types. Fixes gitlab-org/gitlab-ce#36066, fixes gitlab-org/gitlab-ce#31698
Diffstat (limited to 'db/migrate/20170809142252_cleanup_appearances_schema.rb')
-rw-r--r--db/migrate/20170809142252_cleanup_appearances_schema.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/db/migrate/20170809142252_cleanup_appearances_schema.rb b/db/migrate/20170809142252_cleanup_appearances_schema.rb
new file mode 100644
index 00000000000..90d12925ba2
--- /dev/null
+++ b/db/migrate/20170809142252_cleanup_appearances_schema.rb
@@ -0,0 +1,33 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class CleanupAppearancesSchema < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ NOT_NULL_COLUMNS = %i[title description description_html created_at updated_at]
+
+ TIME_COLUMNS = %i[created_at updated_at]
+
+ def up
+ NOT_NULL_COLUMNS.each do |column|
+ change_column_null :appearances, column, false
+ end
+
+ TIME_COLUMNS.each do |column|
+ change_column :appearances, column, :datetime_with_timezone
+ end
+ end
+
+ def down
+ NOT_NULL_COLUMNS.each do |column|
+ change_column_null :appearances, column, true
+ end
+
+ TIME_COLUMNS.each do |column|
+ change_column :appearances, column, :datetime # rubocop: disable Migration/Datetime
+ end
+ end
+end