Merge pull request #7160 from opf/fix/tsv-migration-revert

Allow down migration of tsv to happen
pull/7165/head
ulferts 6 years ago committed by GitHub
commit bd3eb42766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      db/migrate/20180122135443_add_tsv_columns_to_attachments.rb

@ -29,7 +29,7 @@
#++
class AddTsvColumnsToAttachments < ActiveRecord::Migration[5.0]
def change
def up
if OpenProject::Database.allows_tsv?
add_column :attachments, :fulltext_tsv, :tsvector
add_column :attachments, :file_tsv, :tsvector
@ -37,11 +37,25 @@ class AddTsvColumnsToAttachments < ActiveRecord::Migration[5.0]
add_index :attachments, :fulltext_tsv, using: "gin"
add_index :attachments, :file_tsv, using: "gin"
else
reversible do |dir|
dir.up do
warn "Your installation does not support full-text search features. Better use PostgreSQL in version 9.5 or higher."
end
end
def down
if column_exists? :attachments, :fulltext_tsv
remove_column :attachments, :fulltext_tsv, :tsvector
end
if column_exists? :attachments, :file_tsv
remove_column :attachments, :file_tsv, :tsvector
end
if index_exists? :attachments, :fulltext_tsv
remove_index :attachments, :fulltext_tsv
end
if index_exists? :attachments, :file_tsv
remove_index :attachments, :file_tsv
end
end
end

Loading…
Cancel
Save