-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #573 from coopdevs/develop
Release v3.0
- Loading branch information
Showing
15 changed files
with
1,308 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class AddTsvectorColumnToPost < ActiveRecord::Migration | ||
def up | ||
execute <<-SQL | ||
ALTER TABLE posts ADD COLUMN tsv tsvector; | ||
CREATE FUNCTION posts_trigger() RETURNS trigger AS $$ | ||
begin | ||
new.tsv := | ||
to_tsvector('simple', unaccent(coalesce(new.title::text, ''))) || | ||
to_tsvector('simple', unaccent(coalesce(new.description::text, ''))) || | ||
to_tsvector('simple', unaccent(coalesce(new.tags::text, ''))); | ||
return new; | ||
end | ||
$$ LANGUAGE plpgsql; | ||
CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE | ||
ON posts FOR EACH ROW EXECUTE PROCEDURE posts_trigger(); | ||
SQL | ||
|
||
add_index :posts, :tsv, using: "gin" | ||
end | ||
|
||
def down | ||
execute <<-SQL | ||
DROP TRIGGER tsvectorupdate ON posts; | ||
DROP FUNCTION posts_trigger(); | ||
SQL | ||
|
||
remove_index :posts, :tsv | ||
remove_column :posts, :tsv | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class EnableUnaccentExtension < ActiveRecord::Migration | ||
def up | ||
enable_extension "unaccent" | ||
end | ||
|
||
def down | ||
disable_extension "unaccent" | ||
end | ||
end |
Oops, something went wrong.