rails/.devcontainer/boot.sh
eileencodes f136509ad9
Auto-create user and grant privs when creating dbs
Everytime I need to set up Rails locally on a new computer I have to
search for how to do this, then login to mysql, and run all these
commands.

In this change creating the rails user and running the grants is now
part of the `mysql` build rake task. This will default to using the
`root` user and no password. If this becomes problematic we can make it
configurable with env vars. I created the `rails` user twice for each
database defined even though the user is the same. This is in case we
decide to change it later on for arunit2.

This also updates the devcontainer for codespaces to use the rake tasks.
The container requires `sudo` so I had to provide an env var to make
that available.
2022-03-17 08:43:35 -04:00

19 lines
562 B
Bash
Executable File

bundle install
yarn install
sudo chown -R vscode:vscode /usr/local/bundle
sudo service postgresql start
sudo service mariadb start
sudo service redis-server start
sudo service memcached start
# Create PostgreSQL users and databases
sudo su postgres -c "createuser --superuser vscode"
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest"
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest2"
# Create MySQL database and databases
cd activerecord
MYSQL_CODESPACES=1 bundle exec rake db:mysql:build