Sha256: c9c647c00eeb8bb89564eabcf8668a9b7130088db97d3a603f609c09fc4e2b70
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
#!/bin/bash dbuser=$(grep mysql-user /etc/citrin/citrin.conf | split -d"=" -f 2) dbpwd=$(grep mysql-password /etc/citrin/citrin.conf | split -d"=" -f 2 ) name=#{args[0]} env=#{args[1]} if [ -z $name ] ; then echo "usage: $0 appname [env]" exit 1; fi if [ -z $env ] ; then env="prod" fi if [ $env != "prod" -a $env != "dev" -a $env != "test" ]; then echo "usage: $0 appname env" echo "Options for env: prod dev test" exit 2; fi db_name="${name}_$env" db_user="${name}_$env" db_user_pw=$(pwgen -1) mysql --user $dbuser --password=$dbpwd -e "create database $db_name;" #echo "Database $db_name created" mysql --user $dbuser --password=$dbpwd -e "GRANT ALL ON $db_user.* TO '$db_name'@'localhost';" mysql --user $dbuser --password=$dbpwd -e "SET PASSWORD FOR '$db_user'@'localhost' = PASSWORD('$db_user_pw');" #echo "User $db_user with password $db_user_pw created" echo "Put this in your config/database.yml" if [ $env = "prod" ]; then fullenv="production" elif [ $env = "dev" ]; then fullenv="development" elif [ $env = "test" ]; then fullenv="test" else echo "Invalid Env" exit 3 fi echo "" echo "and run" echo " RAILS_ENV=$fullenv rake db:migrate"
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
citrin-0.0.10 | commands/create_database |
citrin-0.0.9 | commands/create_database |