Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add a section about uuid primary key in README.md #1142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [Removing owned tags](#removing-owned-tags)
- [Dirty objects](#dirty-objects)
- [Tag cloud calculations](#tag-cloud-calculations)
- [UUID Primary keys](#uuid-primary-keys)
- [Configuration](#configuration)
- [Upgrading](#upgrading)
- [Contributors](#contributors)
Expand Down Expand Up @@ -74,6 +75,9 @@ Install migrations
rake acts_as_taggable_on_engine:install:migrations
```

> If you're using UUIDs as Primary Keys for your tables, you'll have to update
> the generated migrations accordingly. See [UUID Primary keys](#uuid-primary-keys)

Review the generated migrations then migrate :
```shell
rake db:migrate
Expand Down Expand Up @@ -491,6 +495,31 @@ CSS:
.css4 { font-size: 1.6em; }
```

### UUID Primary Keys

If your app is using UUIDs as primary key for your tables, you'll need to update
one of the generated migrations: the one creating the tables. (db/migrate/xxx_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb)

If the tables that you want to tag are using UUIDs as PK, you'll need to replace

``` ruby
t.references :taggable, polymorphic: true
```

with:

``` ruby
t.references :taggable, polymorphic: true, uuid: true
```

The same goes for the `tagger` reference, if your users (or whatever is
producing tags) table as a UUID PK.


If you want to use UUIDs as PK for the acts-as-taggable-on tables themselves,
you'll need to add `type: uuid` to each of the `create_table` calls in the same
file

## Configuration

If you would like to remove unused tag objects after removing taggings, add:
Expand Down