Re: rake about > Environment staging

tom
2012-06-10T11:19:30Z

inline

On Sun, Jun 10, 2012 at 12:30 PM, Colin Law
<clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:

> On 10 June 2012 11:19, tom
<tomabroad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> Top posting still :(
>
> > yes, thats correct
> >
> > RAILS_ENV=development rake db:migrate
> >>> runs in staging env.
>
> I don''t understand why you then went on to ask
> >> > where does rake get the environment info if i ommit
''RAILS_ENV'' when
> >> > executing a rake command?
>
> Two points (please reply inline so that it makes it easier to follow
> the thread.  Thanks
>
> 1. How do you know that rake db:migrate is running in staging environment?
> > because the migrations are being executed on the staging-db (eg adding
a
> new colum)
> 2. Please post database.yml here.
>

>> database.yml is pretty much standard:

staging:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: myproject_staging
  pool: 5
  username: myproject_dbuser
  password: myproject_dbuser
  socket: /var/run/mysqld/mysqld.sock
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: myproject_development
  pool: 5
  username: myproject_dbuser
  password: myproject_dbuser
  socket: /var/run/mysqld/mysqld.sock
test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: myproject_test
  pool: 5
  username: myproject_dbuser
  password: myproject_dbuser
  socket: /var/run/mysqld/mysqld.sock
production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: myproject_production
  pool: 5
  username: myproject_dbuser
  password: myproject_dbuser
  socket: /var/run/mysqld/mysqld.sock


>> as i said, starting webrick works fine in different environments,
whereas rake tasks always use "staging", no matter what specify. here
a
sample of a migration:
rails g migration add name_to_testbooks name:string
/home/tom/.rvm/gems/ruby-1.9.3-p194@mygemset/gems/railties-3.2.1/lib/rails/script_rails_loader.rb:11:
warning: Insecure world writable dir /home/tom in PATH, mode 040777
/home/tom/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:211:
warning: Insecure world writable dir /home/tom in PATH, mode 040777
      invoke  active_record
      create    db/migrate/20120610111033_add.rb
tom@debian6ror3:~/rails3/myproject$ RAILS_ENV=development rake db:migrate
--trace
/home/tom/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:211:
warning: Insecure world writable dir /home/tom in PATH, mode 040777
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
==  Add: migrating
===========================================================--
add_column(:testbooks, :name, :string)
   -> 0.3212s
==  Add: migrated (0.3216s)
==================================================
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:dump


furthermore, removing staging from the database.yml results in rake telling
me that it doesnt find a staging adapter - even though when i run in
''''dev
mode"

@rvm i installed a user-rvm, straight from the docs. does that interfere?

@ill setup a new user and rvm  again, then reusing the GEMFILE/rvmrc







> Colin