You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/source/active_record_multiple_databases.md
+32-30Lines changed: 32 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,39 +160,41 @@ multiply the number of connections you have since Rails uses the model class nam
160
160
connection specification name.
161
161
162
162
Now that we have the `database.yml` and the new model set up, it's time to create the databases.
163
-
Rails 6.0 ships with all the rails tasks you need to use multiple databases in Rails.
163
+
Rails ships with all the commands you need to use multiple databases.
164
164
165
-
You can run `bin/rails -T` to see all the commands you're able to run. You should see the following:
165
+
You can run `bin/rails --help` to see all the commands you're able to run. You should see the following:
166
166
167
167
```bash
168
-
$ bin/rails -T
169
-
bin/rails db:create # Create the database from DATABASE_URL or config/database.yml for the ...
170
-
bin/rails db:create:animals # Create animals database for current environment
171
-
bin/rails db:create:primary # Create primary database for current environment
172
-
bin/rails db:drop # Drop the database from DATABASE_URL or config/database.yml for the cu...
173
-
bin/rails db:drop:animals # Drop animals database for current environment
174
-
bin/rails db:drop:primary # Drop primary database for current environment
175
-
bin/rails db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
176
-
bin/rails db:migrate:animals # Migrate animals database for current environment
177
-
bin/rails db:migrate:primary # Migrate primary database for current environment
178
-
bin/rails db:migrate:status # Display status of migrations
179
-
bin/rails db:migrate:status:animals # Display status of migrations for animals database
180
-
bin/rails db:migrate:status:primary # Display status of migrations for primary database
181
-
bin/rails db:reset # Drop and recreates all databases from their schema for the current environment and loads the seeds
182
-
bin/rails db:reset:animals # Drop and recreates the animals database from its schema for the current environment and loads the seeds
183
-
bin/rails db:reset:primary # Drop and recreates the primary database from its schema for the current environment and loads the seeds
184
-
bin/rails db:rollback # Roll the schema back to the previous version (specify steps w/ STEP=n)
185
-
bin/rails db:rollback:animals # Rollback animals database for current environment (specify steps w/ STEP=n)
186
-
bin/rails db:rollback:primary # Rollback primary database for current environment (specify steps w/ STEP=n)
187
-
bin/rails db:schema:dump # Create a database schema file (either db/schema.rb or db/structure.sql ...
188
-
bin/rails db:schema:dump:animals # Create a database schema file (either db/schema.rb or db/structure.sql ...
189
-
bin/rails db:schema:dump:primary # Create a db/schema.rb file that is portable against any DB supported ...
190
-
bin/rails db:schema:load # Load a database schema file (either db/schema.rb or db/structure.sql ...
191
-
bin/rails db:schema:load:animals # Load a database schema file (either db/schema.rb or db/structure.sql ...
192
-
bin/rails db:schema:load:primary # Load a database schema file (either db/schema.rb or db/structure.sql ...
193
-
bin/rails db:setup # Create all databases, loads all schemas, and initializes with the seed data (use db:reset to also drop all databases first)
194
-
bin/rails db:setup:animals # Create the animals database, loads the schema, and initializes with the seed data (use db:reset:animals to also drop the database first)
195
-
bin/rails db:setup:primary # Create the primary database, loads the schema, and initializes with the seed data (use db:reset:primary to also drop the database first)
168
+
$ bin/rails --help
169
+
...
170
+
db:create # Create the database from DATABASE_URL or config/database.yml for the ...
171
+
db:create:animals # Create animals database for current environment
172
+
db:create:primary # Create primary database for current environment
173
+
db:drop # Drop the database from DATABASE_URL or config/database.yml for the cu...
174
+
db:drop:animals # Drop animals database for current environment
175
+
db:drop:primary # Drop primary database for current environment
176
+
db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
177
+
db:migrate:animals # Migrate animals database for current environment
178
+
db:migrate:primary # Migrate primary database for current environment
179
+
db:migrate:status # Display status of migrations
180
+
db:migrate:status:animals # Display status of migrations for animals database
181
+
db:migrate:status:primary # Display status of migrations for primary database
182
+
db:reset # Drop and recreates all databases from their schema for the current environment and loads the seeds
183
+
db:reset:animals # Drop and recreates the animals database from its schema for the current environment and loads the seeds
184
+
db:reset:primary # Drop and recreates the primary database from its schema for the current environment and loads the seeds
185
+
db:rollback # Roll the schema back to the previous version (specify steps w/ STEP=n)
186
+
db:rollback:animals # Rollback animals database for current environment (specify steps w/ STEP=n)
187
+
db:rollback:primary # Rollback primary database for current environment (specify steps w/ STEP=n)
188
+
db:schema:dump # Create a database schema file (either db/schema.rb or db/structure.sql ...
189
+
db:schema:dump:animals # Create a database schema file (either db/schema.rb or db/structure.sql ...
190
+
db:schema:dump:primary # Create a db/schema.rb file that is portable against any DB supported ...
191
+
db:schema:load # Load a database schema file (either db/schema.rb or db/structure.sql ...
192
+
db:schema:load:animals # Load a database schema file (either db/schema.rb or db/structure.sql ...
193
+
db:schema:load:primary # Load a database schema file (either db/schema.rb or db/structure.sql ...
194
+
db:setup # Create all databases, loads all schemas, and initializes with the seed data (use db:reset to also drop all databases first)
195
+
db:setup:animals # Create the animals database, loads the schema, and initializes with the seed data (use db:reset:animals to also drop the database first)
196
+
db:setup:primary # Create the primary database, loads the schema, and initializes with the seed data (use db:reset:primary to also drop the database first)
197
+
...
196
198
```
197
199
198
200
Running a command like `bin/rails db:create` will create both the primary and animals databases.
0 commit comments