Skip to content

Commit

Permalink
Add: note re: gin index for jsonb (#535)
Browse files Browse the repository at this point in the history
* Add: note re: gin index for jsonb

* Small edits to note on adding gin index

Co-authored-by: Hiren Mistry <hiren.mistry@chai-monsters.com>
  • Loading branch information
benkoshy and hmistry authored May 4, 2021
1 parent 76f8aec commit e442b68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ an "image" attachment on a `photos` table this would be an `image_data` column:
```
$ rails generate migration add_image_data_to_photos image_data:text # or :jsonb
```
If using `jsonb` consider adding a [gin index] for fast key-value pair searchability within `image_data`.

Now create an uploader class (which you can put in `app/uploaders`) and
register the attachment on your model:
Expand Down Expand Up @@ -175,3 +176,4 @@ The gem is available as open source under the terms of the [MIT License].
[CoC]: /CODE_OF_CONDUCT.md
[MIT License]: /LICENSE.txt
[Contributing]: https://github.com/shrinerb/shrine/blob/master/CONTRIBUTING.md
[gin index]: https://www.postgresql.org/docs/current/datatype-json.html#JSON-INDEXING
11 changes: 8 additions & 3 deletions doc/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,26 @@ will use to store all information about the attachment:
```rb
Sequel.migration do
change do
add_column :photos, :image_data, :text # or :jsonb
add_column :photos, :image_data, :text # or :jsonb
end
end
```

<!--ActiveRecord-->
```rb
class AddImageDataToPhotos < ActiveRecord::Migration
def change
add_column :photos, :image_data, :text # or :jsonb
add_column :photos, :image_data, :text # or :jsonb
end
end
```

<!--Rails-->
```
```rb
$ rails generate migration add_image_data_to_photos image_data:text # or image_data:jsonb
```
If using `jsonb` consider adding a [gin index] for fast key-value pair searchability within `image_data`.

<!--END_DOCUSAURUS_CODE_TABS-->

Now you can create an uploader class for the type of files you want to upload,
Expand Down Expand Up @@ -1108,3 +1112,4 @@ Shrine.logger.level = Logger::WARN
[storages]: https://shrinerb.com/docs/external/extensions#storages
[plugins]: https://shrinerb.com/plugins
[external plugins]: https://shrinerb.com/docs/external/extensions#plugins
[gin index]: https://www.postgresql.org/docs/current/datatype-json.html#JSON-INDEXING

0 comments on commit e442b68

Please sign in to comment.