Sample config/database.yml from Rails. Postgres, MySQL, and SQLite
source link: https://gist.github.com/jwo/4512764
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Sample config/database.yml from Rails. Postgres, MySQL, and SQLite · GitHub
Instantly share code, notes, and snippets.
I'm not convinced about the sqlite-database.yml
config/database.sqlite3.yml
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Pserg commented on Nov 8, 2017
Why you using unicode instead of utf8 in postgres.database.yml?
@Pserg it doesn't matter, unicode is just a standard
This is a huge help. thanks!
Hi,
Is it possible to use the same Postgres database name for development and production? E.g.
sample_postgres in the two environments?
if yes: How to ensure the same data content when running in production?
Author
jwo commented on Sep 20, 2019
Is it possible to use the same Postgres database name for development and production? E.g.
@dangerrg Yes, nothing will prevent that
if yes: How to ensure the same data content when running in production?
I don't know what you mean
I am using Rails 5.2 and mysql2 gem. Even though i am using actual host name in my database.yml for production config, when i run the command RAILS_ENV=production rake db:migrate it is taking host name as local ip address of my machine and shows below error.
rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: CREATE command denied to
user 'username'@'lamu02rr8r9fvh7.xxx.com' for table
'schema_migrations': CREATE TABLE `schema_migrations` (`version`
varchar(255) NOT NULL PRIMARY KEY)
/Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2
0.4.10/lib/mysql2/client.rb:120:in `_query'
/Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2-
0.4.10/lib/mysql2/client.rb:120:in `block in query'
/Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2-
0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
/Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2-
0.4.10/lib/mysql2/client.rb:119:in `query'
And when i run the below command it shows different error.
RAILS_ENV=production rake db:create
rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Access denied for user
'username'@'%' to database 'dashboard': CREATE DATABASE `dashboard`
DEFAULT CHARACTER SET `utf8mb4`
/Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2-
0.4.10/lib/mysql2/client.rb:120:in `_query'
/Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2-
0.4.10/lib/mysql2/client.rb:120:in `block in query'
/Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2-
0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
/Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2-
0.4.10/lib/mysql2/client.rb:119:in `query'
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK