-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure "sqlite3" is supported in addition to "sqlite" for testing
The current name is legacy and rails now uses "sqlite3", starting to move in that direction simplifies some setups (e.g. sandbox creation inside extensions). Also cleaned up the database.yml template which was barely readable.
- Loading branch information
Showing
6 changed files
with
52 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 47 additions & 112 deletions
159
core/lib/generators/spree/dummy/templates/rails/database.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,48 @@ | ||
<% db = case ENV['DB'] | ||
when 'mysql' | ||
'mysql' | ||
when 'postgres', 'postgresql' | ||
'postgres' | ||
when 'sqlite', '', nil | ||
'sqlite' | ||
else | ||
raise "Invalid DB specified: #{ENV['DB']}" | ||
end %> | ||
<% db_host = case db | ||
when 'mysql' | ||
ENV['DB_MYSQL_HOST'] || ENV['DB_HOST'] | ||
when 'postgres' | ||
ENV['DB_POSTGRES_HOST'] || ENV['DB_HOST'] | ||
else | ||
ENV['DB_HOST'] | ||
end %> | ||
<% db_username = ENV['DB_USERNAME'] %> | ||
<% db_password = ENV['DB_PASSWORD'] %> | ||
<%= | ||
require 'yaml' | ||
<% case ENV['DB'] | ||
when 'mysql' %> | ||
development: | ||
adapter: mysql2 | ||
database: <%= options[:lib_name] %>_solidus_development | ||
<% unless db_username.blank? %> | ||
username: <%= db_username %> | ||
<% end %> | ||
<% unless db_password.blank? %> | ||
password: <%= db_password %> | ||
<% end %> | ||
<% unless db_host.blank? %> | ||
host: <%= db_host %> | ||
<% end %> | ||
encoding: utf8 | ||
test: | ||
adapter: mysql2 | ||
database: <%= options[:lib_name] %>_solidus_test | ||
<% unless db_username.blank? %> | ||
username: <%= db_username %> | ||
<% end %> | ||
<% unless db_password.blank? %> | ||
password: <%= db_password %> | ||
<% end %> | ||
<% unless db_host.blank? %> | ||
host: <%= db_host %> | ||
<% end %> | ||
encoding: utf8 | ||
production: | ||
adapter: mysql2 | ||
database: <%= options[:lib_name] %>_solidus_production | ||
<% unless db_username.blank? %> | ||
username: <%= db_username %> | ||
<% end %> | ||
<% unless db_password.blank? %> | ||
password: <%= db_password %> | ||
<% end %> | ||
<% unless db_host.blank? %> | ||
host: <%= db_host %> | ||
<% end %> | ||
encoding: utf8 | ||
<% when 'postgres', 'postgresql' %> | ||
development: | ||
adapter: postgresql | ||
database: <%= options[:lib_name] %>_solidus_development | ||
<% unless db_username.blank? %> | ||
username: <%= db_username %> | ||
<% end %> | ||
<% unless db_password.blank? %> | ||
password: <%= db_password %> | ||
<% end %> | ||
<% unless db_host.blank? %> | ||
host: <%= db_host %> | ||
<% end %> | ||
min_messages: warning | ||
test: | ||
adapter: postgresql | ||
database: <%= options[:lib_name] %>_solidus_test | ||
<% unless db_username.blank? %> | ||
username: <%= db_username %> | ||
<% end %> | ||
<% unless db_password.blank? %> | ||
password: <%= db_password %> | ||
<% end %> | ||
<% unless db_host.blank? %> | ||
host: <%= db_host %> | ||
<% end %> | ||
min_messages: warning | ||
production: | ||
adapter: postgresql | ||
database: <%= options[:lib_name] %>_solidus_production | ||
<% unless db_username.blank? %> | ||
username: <%= db_username %> | ||
<% end %> | ||
<% unless db_password.blank? %> | ||
password: <%= db_password %> | ||
<% end %> | ||
<% unless db_host.blank? %> | ||
host: <%= db_host %> | ||
<% end %> | ||
min_messages: warning | ||
<% when 'sqlite', '', nil %> | ||
development: | ||
adapter: sqlite3 | ||
database: db/solidus_development.sqlite3 | ||
test: | ||
adapter: sqlite3 | ||
database: db/solidus_test.sqlite3 | ||
production: | ||
adapter: sqlite3 | ||
database: db/solidus_production.sqlite3 | ||
<% end %> | ||
lib = "#{options[:lib_name]}_solidus" | ||
case ENV['DB'].presence | ||
when /mysql/ | ||
default = { | ||
adapter: 'mysql2', | ||
encoding: 'utf8', | ||
host: (ENV['DB_MYSQL_HOST'] || ENV['DB_HOST']).presence, | ||
username: ENV['DB_PASSWORD'].presence, | ||
password: ENV['DB_USERNAME'].presence, | ||
}.compact | ||
config = { | ||
development: default.merge(database: "#{lib}_development"), | ||
production: default.merge(database: "#{lib}_production"), | ||
test: default.merge(database: "#{lib}_test"), | ||
} | ||
when /postgres/ then 'postgres' | ||
default = { | ||
adapter: 'postgresql', | ||
encoding: 'utf8', | ||
host: ENV['DB_POSTGRES_HOST'] || ENV['DB_HOST'], | ||
username: ENV['DB_PASSWORD'].presence, | ||
password: ENV['DB_USERNAME'].presence, | ||
}.compact | ||
config = { | ||
development: default.merge(database: "#{lib}_development"), | ||
production: default.merge(database: "#{lib}_production"), | ||
test: default.merge(database: "#{lib}_test"), | ||
} | ||
when /sqlite/, nil then 'sqlite3' | ||
default = { | ||
adapter: sqlite3 | ||
} | ||
config = { | ||
development: default.merge(database: "db/#{lib}_development.sqlite3"), | ||
production: default.merge(database: "db/#{lib}_production.sqlite3"), | ||
test: default.merge(database: "db/#{lib}_test.sqlite3"), | ||
} | ||
else raise "Invalid DB specified: #{ENV['DB'].inspect}" | ||
end | ||
config.deep_stringify_keys.to_yaml | ||
%> |