summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-03-05 11:21:24 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2018-03-21 13:39:49 +0100
commitc4a82f1d7eef63a3682305789b07d6ce238437ec (patch)
tree6ae5720d243c63ce144dff5214e66388c8d5c7d3
parenta9a31ce31d47510ef2133f3389b8a1c0bbee3c35 (diff)
downloadgitlab-ce-c4a82f1d7eef63a3682305789b07d6ce238437ec.tar.gz
Remove `permanent` from `redirect_routes`
This removes the column that was added in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15670 since we will no longer be allowing _permanent_ redirects
-rw-r--r--db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb38
-rw-r--r--db/schema.rb1
2 files changed, 38 insertions, 1 deletions
diff --git a/db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb b/db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb
new file mode 100644
index 00000000000..64b4dce7fac
--- /dev/null
+++ b/db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb
@@ -0,0 +1,38 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class RemovePermanentFromRedirectRoutes < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ disable_ddl_transaction!
+
+ INDEX_NAME_PERM = "index_redirect_routes_on_path_text_pattern_ops_where_permanent"
+ INDEX_NAME_TEMP = "index_redirect_routes_on_path_text_pattern_ops_where_temporary"
+
+ def up
+ # These indexes were created on Postgres only in:
+ # ReworkRedirectRoutesIndexes:
+ # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16211
+ if Gitlab::Database.postgresql?
+ disable_statement_timeout
+
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME_PERM};"
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME_TEMP};"
+ end
+
+ remove_column(:redirect_routes, :permanent)
+ end
+
+ def down
+ add_column(:redirect_routes, :permanent, :boolean)
+
+ if Gitlab::Database.postgresql?
+ disable_statement_timeout
+ if_not_exists = Gitlab::Database.version.to_f >= 9.5 ? "IF NOT EXISTS" : ""
+
+ execute("CREATE INDEX CONCURRENTLY #{if_not_exists} #{INDEX_NAME_PERM} ON redirect_routes (lower(path) varchar_pattern_ops) where (permanent);")
+ execute("CREATE INDEX CONCURRENTLY #{if_not_exists} #{INDEX_NAME_TEMP} ON redirect_routes (lower(path) varchar_pattern_ops) where (not permanent or permanent is null) ;")
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 3ff1a8754e2..c90ba535565 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1598,7 +1598,6 @@ ActiveRecord::Schema.define(version: 20180309160427) do
t.string "path", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.boolean "permanent"
end
add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree