Skip to content

Commit ffee8a0

Browse files
committed
Add description for db:prepare
Review by ChatGPT Minor fix on db:prepare document Update by review Add hard wrap
1 parent 536d168 commit ffee8a0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

guides/source/active_record_migrations.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,26 @@ version to migrate to.
965965
The `bin/rails db:setup` command will create the database, load the schema, and initialize
966966
it with the seed data.
967967

968+
## Preparing the Database
969+
970+
The `bin/rails db:prepare` command is similar to `bin/rails db:setup`, but it
971+
operates idempotently.
972+
973+
* If the database has not been created yet, the command will run as the
974+
`bin/rails db:setup` does.
975+
* If the database exists but the tables have not been created, the command will
976+
load the schema, run any pending migrations, dump the updated schema, and
977+
finally load the seed data.
978+
* If both the database and tables exist but the seed data has not been loaded,
979+
the command will only load the seed data.
980+
* If the database, tables, and seed data are all in place, the command will do
981+
nothing.
982+
983+
NOTE: Once the database, tables, and seed data are all established, the command
984+
will not try to reload the seed data, even if the previously loaded seed data or
985+
the existing seed file have been altered or deleted. To reload the seed data,
986+
you can manually run `bin/rails db:seed`.
987+
968988
### Resetting the Database
969989

970990
The `bin/rails db:reset` command will drop the database and set it up again. This is

0 commit comments

Comments
 (0)