Skip to content

Commit d18fc32

Browse files
authored
Use storage/ instead of db/ for sqlite3 db files (rails#46699)
* Use storage/ instead of db/ for sqlite3 db files db/ should be for configuration only, not data. This will make it easier to mount a single volume into a container for testing, development, and even sqlite3 in production.
1 parent 16eaf44 commit d18fc32

File tree

21 files changed

+110
-149
lines changed

21 files changed

+110
-149
lines changed

actionmailbox/test/dummy/config/database.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ default: &default
1111

1212
development:
1313
<<: *default
14-
database: db/development.sqlite3
14+
database: storage/development.sqlite3
1515

1616
# Warning: The database defined as "test" will be erased and
1717
# re-generated from your development database when you run "rake".
1818
# Do not set this db to the same as development or production.
1919
test:
2020
<<: *default
21-
database: db/test.sqlite3
21+
database: storage/test.sqlite3
2222

2323
production:
2424
<<: *default
25-
database: db/production.sqlite3
25+
database: storage/production.sqlite3

actiontext/test/dummy/config/database.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ default: &default
1111

1212
development:
1313
<<: *default
14-
database: db/development.sqlite3
14+
database: storage/development.sqlite3
1515

1616
# Warning: The database defined as "test" will be erased and
1717
# re-generated from your development database when you run "rake".
1818
# Do not set this db to the same as development or production.
1919
test:
2020
<<: *default
21-
database: db/test.sqlite3
21+
database: storage/test.sqlite3
2222

2323
production:
2424
<<: *default
25-
database: db/production.sqlite3
25+
database: storage/production.sqlite3

activerecord/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@
697697
```yaml
698698
development:
699699
<<: *default
700-
database: db/development.sqlite3
700+
database: storage/development.sqlite3
701701
foreign_keys: false
702702
```
703703

activerecord/lib/active_record/connection_handling.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def primary_class? # :nodoc:
272272
#
273273
# ActiveRecord::Base.connection_db_config
274274
# #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",
275-
# @name="primary", @config={pool: 5, timeout: 5000, database: "db/development.sqlite3", adapter: "sqlite3"}>
275+
# @name="primary", @config={pool: 5, timeout: 5000, database: "storage/development.sqlite3", adapter: "sqlite3"}>
276276
#
277277
# Use only for reading.
278278
def connection_db_config

activerecord/lib/active_record/core.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@ def self.destroy_association_async_job
5353
#
5454
# development:
5555
# adapter: sqlite3
56-
# database: db/development.sqlite3
56+
# database: storage/development.sqlite3
5757
#
5858
# production:
5959
# adapter: sqlite3
60-
# database: db/production.sqlite3
60+
# database: storage/production.sqlite3
6161
#
6262
# ...would result in ActiveRecord::Base.configurations to look like this:
6363
#
6464
# #<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800 @configurations=[
6565
# #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",
66-
# @name="primary", @config={adapter: "sqlite3", database: "db/development.sqlite3"}>,
66+
# @name="primary", @config={adapter: "sqlite3", database: "storage/development.sqlite3"}>,
6767
# #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbdea90 @env_name="production",
68-
# @name="primary", @config={adapter: "sqlite3", database: "db/production.sqlite3"}>
68+
# @name="primary", @config={adapter: "sqlite3", database: "storage/production.sqlite3"}>
6969
# ]>
7070
def self.configurations=(config)
7171
@@configurations = ActiveRecord::DatabaseConfigurations.new(config)

activerecord/test/cases/connection_adapters/connection_handler_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ def test_symbolized_configurations_assignment
204204
development: {
205205
primary: {
206206
adapter: "sqlite3",
207-
database: "test/db/development.sqlite3",
207+
database: "test/storage/development.sqlite3",
208208
},
209209
},
210210
test: {
211211
primary: {
212212
adapter: "sqlite3",
213-
database: "test/db/test.sqlite3",
213+
database: "test/storage/test.sqlite3",
214214
},
215215
},
216216
}

activerecord/test/cases/schema_dumper_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def test_do_not_dump_foreign_keys_when_bypassed_by_config
418418
ActiveRecord::Base.establish_connection(
419419
{
420420
adapter: "sqlite3",
421-
database: "test/db/test.sqlite3",
421+
database: "test/storage/test.sqlite3",
422422
foreign_keys: false,
423423
}
424424
)

guides/source/configuring.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,7 +2772,7 @@ Here's the section of the default configuration file (`config/database.yml`) wit
27722772
```yaml
27732773
development:
27742774
adapter: sqlite3
2775-
database: db/development.sqlite3
2775+
database: storage/development.sqlite3
27762776
pool: 5
27772777
timeout: 5000
27782778
```
@@ -2844,7 +2844,7 @@ If you choose to use SQLite3 and are using JRuby, your `config/database.yml` wil
28442844
```yaml
28452845
development:
28462846
adapter: jdbcsqlite3
2847-
database: db/development.sqlite3
2847+
database: storage/development.sqlite3
28482848
```
28492849
28502850
#### Configuring a MySQL or MariaDB Database for JRuby Platform
@@ -3198,7 +3198,7 @@ Active Record database connections are managed by `ActiveRecord::ConnectionAdapt
31983198
```ruby
31993199
development:
32003200
adapter: sqlite3
3201-
database: db/development.sqlite3
3201+
database: storage/development.sqlite3
32023202
pool: 5
32033203
timeout: 5000
32043204
```

railties/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
* Always generate the storage/ directory with rails new to ensure there's a stable place to
2+
put permanent files, and a single mount point for containers to map. Then default sqlite3 databases
3+
to live there instead of db/, which is only meant for configuration, not data.
4+
5+
*DHH*
6+
17
* Rails console now disables `IRB`'s autocompletion feature in production by default.
28

39
Setting `IRB_USE_AUTOCOMPLETE=true` can override this default.

railties/lib/rails/generators/rails/app/app_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def create_system_test_files
406406
end
407407

408408
def create_storage_files
409-
build(:storage) unless skip_active_storage?
409+
build(:storage)
410410
end
411411

412412
def delete_app_assets_if_api_option

0 commit comments

Comments
 (0)