If you repeatedly create and erase sample apps during learning, Suddenly, I was wondering, "Can I just delete the folder?"
When I looked it up, It seems that ** DB (database) ** must be deleted before ** folder ** can be deleted! Make a note of the two methods below.
-** DB deletion → App folder deletion ** -** How to delete the DB after deleting the application folder **
In the folder of the corresponding application
$ rails db:drop
Go to the parent directory
$ rm -rf app name
It seems good to be sure to delete it according to the procedure of ① above. Here's what to do if you've deleted the app folder first.
$ psql -l (List DB names
#Execution result (when you want to delete the sample application) List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------------------+-------+----------+---------+-------+------------------- sample_development | user | UTF8 | C | C | sample_test | user | UTF8 | C | C | postgres | user | UTF8 | C | C | template0 | user | UTF8 | C | C | =c/user + | | | | | user=CTc/user template1 | user | UTF8 | C | C | =c/user + | | | | | user=CTc/user (5 rows)
$ psql postgres (Log in to PostgreSQL --- (postgres=#) \du (Check users and permissions (postgres=#) \q (Login from PostgreSQL --- $ dropdb -U user name DB name you want to delete
I have removed this supposed default
postgres. .. (Great reflection)
I uninstalled PostgreSQL because it was just a learning app.
When I checked after reinstalling, the above three DBs were there from the beginning! !!
I will write down the procedure after deleting the above default with caution.
$ ls /usr/local/Cellar/postgresql (Check installed PostgreSQL version $ brew info postgresql (Check the latest version at the moment $ brew uninstall --force postgresql (Uninstall all versions $ ls -l /usr/local/var/postgres (Display configuration files, logs, data, etc. $ rm -rf /usr/local/var/postgres (Delete configuration files, logs, data, etc.
Subsequent installations are the same as when installing for the first time.
While learning, the number of sample apps was increasing, I was able to solve it this way. I would appreciate it if you could point out any mistakes.
Ruby on Rails deletion related summary Forcibly delete database in PostgreSQL (https://qiita.com/sayama0402/items/b3d96c25ecb60733beb9) [MacOS] How to uninstall all versions of PostgreSQL ~ Homebrew Edition PostgreSQL documentation "dropdb"