@@ -965,6 +965,26 @@ version to migrate to.
965
965
The ` bin/rails db:setup ` command will create the database, load the schema, and initialize
966
966
it with the seed data.
967
967
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
+
968
988
### Resetting the Database
969
989
970
990
The ` bin/rails db:reset ` command will drop the database and set it up again. This is
0 commit comments