Skip to content

Instantly share code, notes, and snippets.

@davidimoore
Created May 7, 2019 16:16
Show Gist options
  • Save davidimoore/6cce9f7a9f64796abedcad0d93a27d01 to your computer and use it in GitHub Desktop.
Save davidimoore/6cce9f7a9f64796abedcad0d93a27d01 to your computer and use it in GitHub Desktop.
rails_scripts
#!/bin/bash
function bundle_rspec {
bundle exec rspec $1
}
function rails_update_gems {
echo "Running bundle install"
bundle install
}
function rails_update_dependencies {
rails_update_gems
node_update_dependencies
}
function node_update_dependencies {
if [ -e package.json ]
then
echo "Running npm install"
yarn
fi
}
function rails_recreate_db {
environments=(development test)
for t in ${environments[@]}; do
bundle exec rails db:environment:set RAILS_ENV=${t}
bundle exec rake db:drop:_unsafe RAILS_ENV=${t}
bundle exec rake db:create RAILS_ENV=${t}
done
bundle exec rails db:environment:set RAILS_ENV=development
}
function rails_recreate_db {
environments=(development test)
for t in ${environments[@]}; do
bundle exec rake db:drop RAILS_ENV=${t}
bundle exec rake db:create RAILS_ENV=${t}
done
}
function rails_reset_db {
environments=(development test)
for t in ${environments[@]}; do
bundle exec rake db:drop RAILS_ENV=${t}
bundle exec rake db:create RAILS_ENV=${t}
bundle exec rake db:migrate RAILS_ENV=${t}
done
}
function rails_db_migrations {
environments=(development test)
for t in ${environments[@]}; do
bundle exec rake db:migrate RAILS_ENV=${t}
done
}
function rails_update_elasticsearch {
echo "running bundle exec rake ops:elastic_search:create"
bundle exec rake ops:elastic_search:create
echo "running bundle exec rake ops:elastic_search:migrate"
bundle exec rake ops:elastic_search:migrate
echo "running bundle exec rake ops:elastic_search:seed"
bundle exec rake ops:elastic_search:seed
}
function rails_ignore_skylight {
bundle exec skylight disable_dev_warning
}
function rails_rm_fixtures
{
echo "removing tmp/fixture_builder.yml"
rm tmp/fixture_builder.yml
}
function rails_update_project {
rails_update_dependencies
rails_update_db
}
function rails_reset_clone_prod_migrate {
DISABLE_DATABASE_ENVIRONMENT_CHECK=1 rails_recreate_db
heroku pg:backups:download -a hofr
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d hofr_development latest.dump
rails_db_migrations
bin/rails db:environment:set RAILS_ENV=development
rm latest.dump
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment