Use SQL heredoc on long statement lines in migrations (#29112)

This commit is contained in:
Matt Jankowski 2024-02-06 11:42:25 -05:00 committed by GitHub
parent 64300e0fe3
commit 1e0b0a3486
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 62 additions and 7 deletions

View file

@ -2,7 +2,17 @@
class AddSearchIndexToAccounts < ActiveRecord::Migration[5.0]
def up
execute 'CREATE INDEX search_index ON accounts USING gin((setweight(to_tsvector(\'simple\', accounts.display_name), \'A\') || setweight(to_tsvector(\'simple\', accounts.username), \'B\') || setweight(to_tsvector(\'simple\', coalesce(accounts.domain, \'\')), \'C\')));'
execute <<~SQL.squish
CREATE INDEX search_index
ON accounts
USING gin(
(
setweight(to_tsvector('simple', accounts.display_name), 'A') ||
setweight(to_tsvector('simple', accounts.username), 'B') ||
setweight(to_tsvector('simple', coalesce(accounts.domain, '')), 'C')
)
)
SQL
end
def down