This belongs to a royal PITA moment, thus needs a worthy post. I’m trying to do a
with my Gemfile as follows:
group :development, :test do
gem 'capybara'
gem 'cucumber'
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'rspec-rails'
gem 'autotest'
gem 'spork'
gem 'launchy'
end
At the time of writing this, these are the errors that I encountered. Since you are reading this, then I guess something is still wrong here.
Installing cucumber (1.0.6)
Installing cucumber-rails (1.0.4) Invalid gemspec in [/Users/rupert/.rvm/gems/ruby-1.9.2-p180@cws/specifications/cucumber-rails-1.0.4.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000104b82a40> 0.7.2"]
Installing database_cleaner (0.6.7) Invalid gemspec in [/Users/rupert/.rvm/gems/ruby-1.9.2-p180@cws/specifications/cucumber-rails-1.0.4.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000104b82a40> 0.7.2"]
Installing orm_adapter (0.0.5) Invalid gemspec in [/Users/rupert/.rvm/gems/ruby-1.9.2-p180@cws/specifications/cucumber-rails-1.0.4.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000104b82a40> 0.7.2"]
Installing warden (1.0.5) Invalid gemspec in [/Users/rupert/.rvm/gems/ruby-1.9.2-p180@cws/specifications/cucumber-rails-1.0.4.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000104b82a40> 0.7.2"]
Installing devise (1.4.5) Invalid gemspec in [/Users/rupert/.rvm/gems/ruby-1.9.2-p180@cws/specifications/cucumber-rails-1.0.4.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000104b82a40> 0.7.2"]
Installing meta_programming (0.2.2) Invalid gemspec in [/Users/rupert/.rvm/gems/ruby-1.9.2-p180@cws/specifications/cucumber-rails-1.0.4.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000104b82a40> 0.7.2"]
Ok, avoid the PITA moment by reading this. And make the changes to the Gemfile like this:
group :development, :test do
gem 'capybara'
gem 'cucumber', "1.0.6"
gem 'cucumber-rails', :git => "https://github.com/cucumber/cucumber-rails.git"
gem 'database_cleaner'
gem 'rspec-rails'
gem 'autotest'
gem 'spork'
gem 'launchy'
end
Now, I understand why the commit message is like this: I EAT YAML AND RUBYGEMS FOR toot…
1. Want to change crontab’s editor?
2. crontab -e
PATH=/sbin:/bin:/usr/sbin:/usr/bin
30 * * * * /home/rupert/bin/rvm-shell 'ruby-1.9.2-p180@travelspotsinasia' -c 'RAILS_ENV=production rake -f /srv/rails/travelspotsinasia/Rakefile thinking_sphinx:rebuild' > $HOME/travelspotsinasia.index.log
3. Didn’t work the first time. Argh.
robin:~% mail
Heirloom mailx version 12.4 7/29/08. Type ? for help.
"/var/mail/rupert": 2 messages
>O 1 Cron Daemon Mon Aug 22 21:08 32/1314 Cron <rupert@robin> /home/rupert/bin/rvm-shell 'ruby-1.9.2-p180@travelspotsinasia' -c 'RAILS_ENV=producti
Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
* bin_path
* searchd_binary_name
* indexer_binary_name
</mail>
4. Quick fix
% cd /usr/bin
% sudo ln -s /usr/local/sphinx/bin/indexer indexer
% sudo ln -s /usr/local/sphinx/bin/indextool indextool
% sudo ln -s /usr/local/sphinx/bin/search search
% sudo ln -s /usr/local/sphinx/bin/searchd searchd
% sudo ln -s /usr/local/sphinx/bin/spelldump spelldump
5. Test by adjusting the date on cron. Wait for cron to kick in. Check the log file.
Awesome.
robin:~% tail -f travelspotsinasia.index.log
(in /home/rupert)
Stopped search daemon (pid 16831).
Generating Configuration to /srv/rails/travelspotsinasia/config/production.sphinx.conf
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew Aksyonoff
using config file '/srv/rails/travelspotsinasia/config/production.sphinx.conf'...
indexing index 'poi_core'...
collected 10700 docs, 1.1 MB
sorted 0.2 Mhits, 100.0% done
total 10700 docs, 1106049 bytes
total 0.363 sec, 3042131 bytes/sec, 29429.80 docs/sec
distributed index 'poi' can not be directly indexed; skipping.
total 2 reads, 0.001 sec, 592.8 kb/call avg, 0.8 msec/call avg
total 7 writes, 0.005 sec, 393.1 kb/call avg, 0.7 msec/call avg
Started successfully (pid 17764).
Using a table_name in a function.
The parameter p_schema_name will be passed as a string to the sql string statement processed by EXECUTE. Possible gotchas I encountered here was the FOUND variable is useless after an EXECUTE statement.
EXECUTE 'UPDATE...";
IF found THEN --this is not set when we use EXECUTE.
END IF;
CREATE OR REPLACE FUNCTION dfms.upsert_ncm_execution(p_schema_name text, p_fleet_id integer, p_ncm_number integer, p_version text, p_hostname text, p_process_id integer, p_execution_id integer)
RETURNS integer AS
$BODY$
DECLARE
record_found BOOLEAN;
execution_id INTEGER;
BEGIN
EXECUTE 'SELECT count(*) FROM ' || p_schema_name || '.ncm_executions WHERE fleet_id = $1 AND ncm_number = $2' INTO record_found USING p_fleet_id, p_ncm_number;
IF record_found THEN
EXECUTE 'UPDATE ' || p_schema_name || '.ncm_executions SET execution_id = execution_id + 1 WHERE fleet_id = $1 AND ncm_number = $2' USING p_fleet_id, p_ncm_number;
ELSE
BEGIN
EXECUTE 'INSERT INTO ' || p_schema_name || '.ncm_executions(fleet_id, ncm_number, version, hostname, process_id, execution_id) VALUES($1, $2, $3, $4, $5, $6)' USING p_fleet_id, p_ncm_number, p_version, p_hostname, p_process_id, p_execution_id;
EXCEPTION WHEN unique_violation THEN
-- do nothing
END;
END IF;
EXECUTE 'SELECT execution_id FROM ' || p_schema_name || '.ncm_executions WHERE fleet_id = $1 AND ncm_number = $2' INTO execution_id USING p_fleet_id, p_ncm_number;
RETURN execution_id;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
Below is a summary of my experiences with migrating from MySQL to Postgres using mysql2psql – https://github.com/maxlapshin/mysql2postgres
To migrate a “tsa” database from mysql to postgres, create a tsa.yml
mysql:
hostname: localhost
port: 3306
socket: /tmp/mysql.sock
username: dbadmin
password: password
database: tsa
destination:
# if file is given, output goes to file, else postgres
#file: tsa.dump
postgres:
hostname: localhost
port: 5432
database: tsa:hotels #database_name:schema_name
username: dbadmin
password: password
# if tables is given, only the listed tables will be converted. leave empty to convert all tables.
#tables:
#- table1
#- table2
# if exclude_tables is given, exclude the listed tables from the conversion.
#exclude_tables:
#- table3
#- table4
# if supress_data is true, only the schema definition will be exported/migrated, and not the data
supress_data: false
# if supress_ddl is true, only the data will be exported/imported, and not the schema
supress_ddl: false
# if force_truncate is true, forces a table truncate before table loading
force_truncate: false
Run.
References:
http://en.wikibooks.org/wiki/Converting_MySQL_to_PostgreSQL