I have a sinatra service that reads from postgres and we changed the postgres schema of those models. How can I set the schema path.
In rails and active record you can do as follows:
performance_tracking:
adapter: postgresql
encoding: utf8
database: db_name
username: my_user
password: pass11121212
host: 172.30.1.12
schema_search_path: my_new_schema
So I am trying to do the same using sequel
But it ignores the field of schema_search_path
How can I set the schema_search_path for postgres
This is my database.yml file.
I am trying to create database for a ruby app but the error always pops up
"fe_sendauth: no password supplied"
Tried to createuser - w --no-password on the CLI ended up with the same error.
Any help to fix this please ?
default: &default
adapter: postgresql
encoding: unicode
development:
<<: *default
database: app_development
test:
<<: *default
database: app_test
production:
<<: *default
database: app_production
username: app
password: <%= ENV['APP_DATABASE_PASSWORD'] %>
The commands I run:
config['development']
=> {"adapter"=>"mysql2", "encoding"=>"utf8mb4", "collation"=>"utf8mb4_bin", "pool"=>1, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"my_db"}
ActiveRecord::Base.establish_connection(config['development'])
=> #<ActiveRecord::ConnectionAdapters::ConnectionPool:0x007fe20592b348 ...
ActiveRecord::Base.connection.create_database(config['development']['database'])
ActiveRecord::NoDatabaseError: Unknown database 'my_db'
It says unknown database but I am actually trying to create the database with create_database and I follow the docs:
https://apidock.com/rails/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter/create_database
Why is it not working?
Given database.yml:
database.yml
default: &default
adapter: mysql2
encoding: utf8mb4
collation: utf8mb4_bin
pool: 5
username: root
password:
host: localhost
development:
<<: *default
database: my_db
test:
<<: *default
database: my_db_test
I got it working by establishing a connection without the database and then creating the database:
#config = YAML.load(File.open(File.expand_path('../../lib/my_gem_config/database.yml', __FILE__)))
ActiveRecord::Base.establish_connection(config['default'])
ActiveRecord::Base.connection.create_database(#config['development']['database'])
When creating a database in postgres it will use a "template" database to make a copy. I haven't read the source code on how ActiveRecord::Base.connection.create_database actually works and if it indeed does the same. I was able to create the database with your code except that for my config hash I merged: database: 'postgres', schema_search_path: 'public' and that seemed to do the trick. In my case 'postgres' is my template database.
rails 3.2
In my database.yml, I have:
development: &default
adapter: mysql2
encoding: utf8
reconnect: false
database: mydb
pool: 5
username: 'mydb'
password: 'mypwd'
staging:
<<: *default
host: localhost
sandbox:
<<: *default
host: localhost
When I run:
RAILS_ENV=sandbox
RAILS_GROUPS=assets
bundle exec rake assets:precompile
I get the following:
rake aborted!
ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter
If I do:
RAILS_ENV=staging
RAILS_GROUPS=assets
bundle exec rake assets:precompile
It completes correctly. The staging and sandbox setting are the same. Any idea what's going on here?
I followed the directions here https://github.com/gitlabhq/gitlab-recipes/blob/master/install/centos/README.md and have the gitlab community page up and running but I cannot login.
Someone suggested doing this:
bundle exec rake db:seed_fu RAILS_ENV=production
(in /home/git/gitlab)
I got a FATAL error suggesting no role for root, I then followed this:
FATAL: role "root" does not exist
and created a role, now I get this error:
[root#gitlab gitlab]# bundle exec rake db:seed_fu RAILS_ENV=production
== Seed from /home/git/gitlab/db/fixtures/production/001_admin.rb
rake aborted!
ActiveRecord::StatementInvalid: PG::Error: ERROR: permission denied for relation users
: SELECT 1 AS one FROM "users" WHERE "users"."email" = 'admin#example.com' LIMIT 1
/home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/seed-fu-2.3.1/lib/seed-fu/runner.rb:46:in `eval'
[root#gitlab gitlab]# sudo -u git -H cat config/database.yml
#
# PRODUCTION
#
production:
adapter: postgresql
encoding: unicode
database: gitlabhq_production
pool: 10
# username: git
# password:
# host: localhost
# port: 5432
#
# Development specific
#
development:
adapter: postgresql
encoding: unicode
database: gitlabhq_development
pool: 5
username: postgres
password:
#
# Staging specific
#
staging:
adapter: postgresql
encoding: unicode
database: gitlabhq_staging
pool: 5
username: postgres
password:
# 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: &test
adapter: postgresql
encoding: unicode
database: gitlabhq_test
pool: 5
username: postgres
password:
Please help. I do not know ruby and I also don't know postgresql