norman/friendly_id — Issue #249: Migration from FriendlyId 3 to 4 with history
Author: nono
Created: 2012-03-03 17:08:14+00:00
State: open

Hi,

I migrated a Rails app from FriendlyId 3 to FriendlyId 4. In the version 3, I was using cached_slugs and in version 4, I'm using the history extension. But it doesn't work: it doesn't find models from their old slugs.

I have a table `slugs`, but it seems that the history extension try to use `friendly_id_slugs`. Do you confirm? If yes, does the table name change from friendlyid 3 to 4? I didn't see any warning in [What's new?](http://rubydoc.info/github/norman/friendly_id/master/file/WhatsNew.md), so I'm perplexed.

Moreover, in the current configuration, the history extension fails but very silently: no exception, no warning in the Rails logs. I even saw the SQL queries on the new missing table:

```text
FriendlyId::Slug Load (0.3ms) SELECT id FROM `friendly_id_slugs` WHERE `friendly_id_slugs`.`sluggable_id` = 28071 AND `friendly_id_slugs`.`sluggable_type` = 'News' AND `friendly_id_slugs`.`slug` = 'essai-tags-2' ORDER BY `friendly_id_slugs`.id DESC FOR UPDATE
SQL (0.5ms) INSERT INTO `friendly_id_slugs` (`created_at`, `scope`, `sequence`, `slug`, `sluggable_id`, `sluggable_type`) VALUES ('2012-03-03 16:33:50', NULL, 1, 'essai-tags-2', 28071, 'News')
```

Do you have some insight about to come back to a normal state? Is there a simple way to create the missing rows in friendly_id_slugs from the models?