-
Notifications
You must be signed in to change notification settings - Fork 21.9k
[ci-skip][Docs]Add description for db:prepare
command
#49480
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for updating this! I suggested one small tweak.
The `bin/rails db:prepare` command is similar to `bin/rails db:setup`, but it operates idempotently. | ||
|
||
* If the database has not been created yet, the command will run as the `bin/rails db:setup` does. | ||
* If the database exists but the tables have not been created, the command will load the schema, run any pending migrations to dump schema, and finally load the seed data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* If the database exists but the tables have not been created, the command will load the schema, run any pending migrations to dump schema, and finally load the seed data. | |
* If the database exists but the tables have not been created, the command will load the schema, run any pending migrations, dump the updated schema, and finally load the seed data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review! Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Squashed the commits.
* If both the database and tables exist but the seed data has not been loaded, the command will only load the seed data. | ||
* If the database, tables, and seed data are all in place, the command will do nothing. | ||
|
||
NOTE: Once the database, tables, and seed data are all established, the command will not try to reload the seed data, even if the previously loaded seed data or the existing seed file have been altered or deleted. To reload the seed data, you can manually run `bin/rails db:seed`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Can you wrap the docs to 80 characters like the rest of the document?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added hard wrap and squashed.
Review by ChatGPT Minor fix on db:prepare document Update by review Add hard wrap
[ci-skip][Docs]Add description for `db:prepare` command
Introduces a new database config property `seeds` to control whether seeds are loaded during `db:prepare` which defaults to `true` for primary database configs and `false otherwise. Previously, the `db:prepare` task would load seeds whenever a new database is created, leading to potential loss of data if a database is added to an existing environment. Also, update the Active Record Migrations guide to more accurately describe what the `db:prepare` task does, correcting some misinformation introduced in rails#49480 along the way. Closes rails#53348
Introduces a new database config property `seeds` to control whether seeds are loaded during `db:prepare` which defaults to `true` for primary database configs and `false otherwise. Previously, the `db:prepare` task would load seeds whenever a new database is created, leading to potential loss of data if a database is added to an existing environment. Also, update the Active Record Migrations guide to more accurately describe what the `db:prepare` task does, correcting some misinformation introduced in rails#49480 along the way. Closes rails#53348
Introduces a new database config property `seeds` to control whether seeds are loaded during `db:prepare` which defaults to `true` for primary database configs and `false otherwise. Previously, the `db:prepare` task would load seeds whenever a new database is created, leading to potential loss of data if a database is added to an existing environment. Also, update the Active Record Migrations guide to more accurately describe what the `db:prepare` task does, correcting some misinformation introduced in rails#49480 along the way. Closes rails#53348
Introduces a new database config property `seeds` to control whether seeds are loaded during `db:prepare` which defaults to `true` for primary database configs and `false otherwise. Previously, the `db:prepare` task would load seeds whenever a new database is created, leading to potential loss of data if a database is added to an existing environment. Also, update the Active Record Migrations guide to more accurately describe what the `db:prepare` task does, correcting some misinformation introduced in rails#49480 along the way. Closes rails#53348
Introduces a new database config property `seeds` to control whether seeds are loaded during `db:prepare` which defaults to `true` for primary database configs and `false otherwise. Previously, the `db:prepare` task would load seeds whenever a new database is created, leading to potential loss of data if a database is added to an existing environment. Also, update the Active Record Migrations guide to more accurately describe what the `db:prepare` task does, correcting some misinformation introduced in rails#49480 along the way. Closes rails#53348
Motivation / Background
This Pull Request has been created because
bin/rails db:prepare
is missing in current migration guide since Rails 6.0.db:prepare
to load schema if database already exists but is empty; also dumps schema after migrations #45464 -- improved in 7.1cc: @bensheldon, the author of #45464
Detail
This Pull Request add a description for
db:prepare
.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]