From 44c8eecd16fc7e54a08b3dc9ee11ace7eb550b62 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Fri, 17 Nov 2023 09:21:04 +0100 Subject: [PATCH] Updated README for Backend. Renamed skills to fix sql importation. --- backend/README.md | 54 +++++++++++++++++++------ backend/db/{skills.sql => a_skills.sql} | 0 2 files changed, 42 insertions(+), 12 deletions(-) rename backend/db/{skills.sql => a_skills.sql} (100%) diff --git a/backend/README.md b/backend/README.md index 63f6d44..a966599 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,32 +1,62 @@ +## 📄⚠️ Important note ⚠️📄 + +Later, an autonomus bash file will be created to make all this config simplier. For now this is the way to go: **manually**. + # Creation of the Database `[name]` being the username you created in postgres\ `[pwd]` being its password -``` -sudo dnf install postgresql postgresql-client postgresql-server postgresql-contrib -sudo -u postgres createdb --owner=name cv -sudo service postgresql restart +### 🐘 Make sure you installed Postgresql 🐘 + +#### For Fedora + +```bash +sudo dnf install postgresql postgresql-server postgresql-contrib +sudo /usr/bin/postgresql-setup --initdb ``` -## Importing `.sql` files +### ⚠️ Be sure to modify your config file to access the postgres database ⚠️ -Idk for now (xd) - -## ⚠️ Be sure to modify your config file to access the postgres database ⚠️ - -``` +```bash sudo nano /var/lib/pgsql/data/pg_hba.conf ``` -Check if those lines are correct : +Then check if those lines are correct: ``` # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 ``` +### _If modified, restart psql service :_ +``` +sudo service postgresql restart +``` -# Env file configuration +### 💻 Create a new user and the database 💻 + +```sql +sudo -u postgres psql -U postgres +CREATE USER [name] WITH PASSWORD '[pwd]'; +CREATE DATABASE cv OWNER [name]; +GRANT ALL PRIVILEGES ON DATABASE cv TO [name]; +\q +sudo service postgresql restart +``` + +### ⬆️ Import the sql tables ⬆️ + +In the `backend` directory you can find a `db` folder which contains all the tables structures for the data base. To import those definitions you can type this command: + +```bash +for file in backend/db/*.sql; do + psql -U [name] -d cv -a -f "$file" +done +``` + +## Env file configuration + +Create the `.env` file in this folder root. The file must be composed of the following line: ``` DATABASE_URL=postgres://[name]:[pwd]@localhost/cv diff --git a/backend/db/skills.sql b/backend/db/a_skills.sql similarity index 100% rename from backend/db/skills.sql rename to backend/db/a_skills.sql