Last active
April 26, 2024 18:41
-
-
Save MyklClason/338536e05dcb09e093fca3f562d50bbc to your computer and use it in GitHub Desktop.
Cloud9 workspace setup with Rails and Postgresql | Copy/Pastable Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo service postgresql start | |
sudo sudo -u postgres psql | |
CREATE USER username SUPERUSER PASSWORD 'password'; | |
\q | |
. ~/.bashrc | |
echo "export USERNAME=username" >> ~/.bashrc | |
echo "export PASSWORD=password" >> ~/.bashrc | |
. ~/.bashrc | |
sudo sudo -u postgres psql | |
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1'; | |
DROP DATABASE template1; | |
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE'; | |
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1'; | |
\c template1 | |
VACUUM FREEZE; | |
\q |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: &default | |
adapter: postgresql | |
encoding: unicode | |
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | |
username: <%= ENV['USERNAME'] %> | |
password: <%= ENV['PASSWORD'] %> | |
host: <%= ENV['IP'] %> | |
development: | |
<<: *default | |
database: Application_development | |
test: | |
<<: *default | |
database: Application_test | |
production: | |
<<: *default | |
database: Application_production | |
username: Application | |
password: <%= ENV['DATABASE_PASSWORD'] %> |
Note: It may be needed to close the terminal tabs and copy/paste the c9pg.txt
again if there are issues with the "ubuntu" user causing the database to not migration/setup.
Note: You'll need to start a postgres server, sometimes you may need to restart it via stop then start. I recommend stop then start always.
sudo service postgresql stop && sudo service postgresql start
Running this command will also require you to reload your rails console if you have it up via reload!
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is just a copy/pastable version of:
https://github.com/Aerogami/guides/wiki/Cloud9-workspace-setup-with-Rails-and-Postgresql
All credit goes to them. This should be copy/pasted into the terminal after "Postgresql setup" section has been completed.
Once finished ALL console tabs need to be reloaded (closed and reopened for example) to prevent odd errors.
After failing to workout how to create a bash script of this (not clear on the SQL parts) and using it dozens of times via tedious line-by-line copy/paste, I decided to go this route.