Closed harshith30 closed 10 years ago
Is that system function exits without executing those two lines from the setup file ?
May be check the exit status of the system functions.
Since it is a ruby code you can very well use ruby debug tools to trace the root cause of it.
A fix for this issue was deployed in commit https://github.com/msjit/testcasedb/commit/03b066cb7d4927b02826abac83efe31c93a8fc74
Hi, In the file setup ( ~/testcasedb/script/setup ) , when we run this file under production environment
harshith@harshith-Inspiron-3520:~/testcasedb$ script/setup -p
the following code triggers
system "bundle"
if options[:production] == false puts "Creating all databases" system "bundle exec rake db:create:all" system "bundle exec rake db:migrate" system "bundle exec rake install:base" else puts "Migrating production database" system "RAILS_ENV=production bundle exec rake db:migrate" puts "Installing base function" system "RAILS_ENV=production bundle exec rake install:base" end
According to my understanding both the tasks ( db:migrate and install:base ) should execute, and migration should take place .
But what i observe when i run the file are as follows
harshith@harshith-Inspiron-3520:~/testcasedb$ script/setup -p Generated config/app_config.yml Updated secret key Migrating production database Installing base function
The puts command works perfectly .
Now when i check the database for the tables i don't see them.
harshith@harshith-Inspiron-3520:~$ mysql -u harshith -p tcdb_production Enter password:
mysql> show tables; Empty set (0.00 sec)
Only if i run the
db:migrate
separately the migration takes placeharshith@harshith-Inspiron-3520:~/testcasedb$ RAILS_ENV=production bundle exec rake db:migrate --trace * Invoke db:migrate (first_time) * Invoke environment (first_time) * Execute environment * Invoke db:load_config (first_time) * Execute db:load_config * Execute db:migrate . . * Invoke db:_dump (first_time) * Execute db:_dump * Invoke db:schema:dump (first_time) * Invoke environment * Invoke db:load_config * Execute db:schema:dump
After which i need to run
install:base
separately so that the default user gets createdharshith@harshith-Inspiron-3520:~/testcasedb$ RAILS_ENV=production bundle exec rake install:base --trace * Invoke install:base (first_time) * Invoke environment (first_time) * Execute environment * Execute install:base Install is complete.
RAILS_ENV=production bundle exec rake db:migrate RAILS_ENV=production bundle exec rake install:base
again for the application to run successfully , when its already been used in the script /setup file.
Thanks Harshith