Sitelet https://web.archive.org/web/20211218055845/https://github.com/rails/rails/issues/43475
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

Suggestion of improvement for the getting started guide #43475

Open
psychoslave opened this issue Oct 16, 2021 · 5 comments · May be fixed by #43479
Open

Suggestion of improvement for the getting started guide #43475

psychoslave opened this issue Oct 16, 2021 · 5 comments · May be fixed by #43479

Comments

@psychoslave
Copy link

@psychoslave psychoslave commented Oct 16, 2021

Hello,

In section 8 of Getting Started, users learn how to add a status attribute. By the end of the section, they should have this feature working well, including a count of public posts on the index page. However if the user played with the blog application and already created some posts, this count won't include these posts as values have not been set.

The reader should be informed of that and indicated a way to tackle this kind of issue, either by modifying the migration scripts or run a console and run something equivalent to:

[Article, Comment].each{|model| model.all.each{|ens| ens.status = 'public'} }
@psychoslave psychoslave changed the title Suggestion of improvement of the getting started guide Suggestion of improvement for the getting started guide Oct 16, 2021
@ghiculescu
Copy link
Member

@ghiculescu ghiculescu commented Oct 16, 2021

Thanks for the feedback. Maybe it’s better to give the new status column a default, and backfill the data all in one migration. Anyway, would you like to make a PR to update the guide?

@psychoslave
Copy link
Author

@psychoslave psychoslave commented Oct 16, 2021

Ok to make a PR on that, but I'm unsure of when I'll have time to do it. If I don't find a window for this in the week-end, it might not be before two weeks or so.

@ghiculescu
Copy link
Member

@ghiculescu ghiculescu commented Oct 16, 2021

That's fine. There is no rush :)

@psychoslave
Copy link
Author

@psychoslave psychoslave commented Oct 16, 2021

here you are @ghiculescu, hopefully sending it directly in PR wasn't to bold here. Cheers.

@viktorianer
Copy link

@viktorianer viktorianer commented Nov 21, 2021

I think it is a really common case, to change data after or during a DB migration. In real projects, we will find different ways to deal with that problem. From "one shot rake task" to put this "modifying data" task in the migration himself. In later case, if some classes changing, the migration will not work (new developers in team).

I would love to see some best practice examples in Migration Guides. And if I am right, there are some examples already under section 3.9 using-reversible and following?!

So, maybe it is OK to write a small example at section 8 of Getting Started and add a link to the Migration Guides section 3.9?

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

Successfully merging a pull request may close this issue.

3 participants