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

Migrate existing values for column to default locale #16

Closed
sergio-rivas opened this issue Jan 30, 2020 · 2 comments
Closed

Migrate existing values for column to default locale #16

sergio-rivas opened this issue Jan 30, 2020 · 2 comments

Comments

@sergio-rivas
Copy link

I was wondering how to migrate existing data to the jsonb?

My existing schema for an application as setup with title and content However, after a decision to make the content available internationally, we decided to incorporate a translation gem.

Here is the result:

    t.string "title"
    t.text "content"
    t.jsonb "title_translations"
    t.jsonb "content_translations"

The problem here is that the values originally stored in title are no longer accessible. I can only access them when I comment out the translates :title, :content line at the top of the model, which means I can't do it via simple script.

I think one simple solution to this would be to give users of the gem the ability to turn the translation on/off similar to how easy you made it to do i18n fallbacks on/off. That way at least users can write a simple script to migrate existing values.

@sergio-rivas
Copy link
Author

sergio-rivas commented Jan 30, 2020

@cfabianski

I've added a pull request fulfilling an enable/disable translations feature.
#17

@sergio-rivas
Copy link
Author

Actually, just realized this much easier realized just by using .attributes directly in a migration script. The PR is still worth looking at though. 💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant