From b3c075029582ff0ffa932ffd9f063e023cca740c Mon Sep 17 00:00:00 2001 From: Benny <62785232+bennyv8@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:39:01 -0700 Subject: [PATCH] Database schema (#528) * Update intro.md (#512) Hey updated a few steps for onboarding under the intro. * init sql file to create post table * Updated docker to create postgres database - updated git ignore to include /data directory * Updated dev.env example - found bug that prevented postgres from connecting --------- Co-authored-by: kchotani <87041811+kchotani@users.noreply.github.com> --- .gitignore | 1 - backend/config/settings.py | 16 +++++++++------- data/init.sql | 15 +++++++++++++++ dev/dev.env.example | 2 +- docker-compose.yml | 4 ++-- docs/joining-the-team/intro.md | 9 +++++---- 6 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 data/init.sql diff --git a/.gitignore b/.gitignore index 55e209e8..f37f74cc 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ app/frontend/static/frontend/* !app/frontend/static/frontend/.gitkeep app/frontend/templates/frontend/* !app/frontend/templates/frontend/.gitkeep -data/ **/super-linter.log app/staticfiles diff --git a/backend/config/settings.py b/backend/config/settings.py index 0fb42698..3ac53e31 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -96,17 +96,19 @@ # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { - "default": { - "ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"), - "NAME": os.environ.get("SQL_DATABASE", BASE_DIR / "db.sqlite3"), - "USER": os.environ.get("SQL_USER", "user"), - "PASSWORD": os.environ.get("SQL_PASSWORD"), - "HOST": os.environ.get("SQL_HOST", "localhost"), - "PORT": os.environ.get("SQL_PORT", "5432"), + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get('POSTGRES_NAME'), + 'USER': os.environ.get('POSTGRES_USER'), + 'PASSWORD': os.environ.get('POSTGRES_PASSWORD'), + 'HOST': 'pgdb', + 'PORT': 5432, #default port you don't need to mention in docker-compose } } + + # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators diff --git a/data/init.sql b/data/init.sql new file mode 100644 index 00000000..586f5193 --- /dev/null +++ b/data/init.sql @@ -0,0 +1,15 @@ +CREATE SCHEMA PostDatabase; + + +CREATE TABLE Post ( + id UUID PRIMARY KEY, + role VARCHAR, + subrole VARCHAR, + project VARCHAR, + meetings_times VARCHAR[], + difficulty_level INT, + details JSONB, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_by_or_token VARCHAR +); \ No newline at end of file diff --git a/dev/dev.env.example b/dev/dev.env.example index 0cf5e5e9..5fb31ede 100644 --- a/dev/dev.env.example +++ b/dev/dev.env.example @@ -1,7 +1,7 @@ # environment file to configure docker containers # postgres -POSTGRES_DB= +POSTGRES_NAME= POSTGRES_USER= POSTGRES_PASSWORD= diff --git a/docker-compose.yml b/docker-compose.yml index d7170f98..e278caa7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,10 +5,11 @@ services: image: postgres container_name: pgdb volumes: - - postgres_data:/lib/postgresql/data + - ./data/init.sql:/docker-entrypoint-initdb.d/init.sql env_file: - ./dev/dev.env + django: build: context: ./backend @@ -56,5 +57,4 @@ services: - ${HOME}/.cache:${HOME}/.cache:rw volumes: - postgres_data: node_modules: diff --git a/docs/joining-the-team/intro.md b/docs/joining-the-team/intro.md index 9ff9fc61..9d61be22 100644 --- a/docs/joining-the-team/intro.md +++ b/docs/joining-the-team/intro.md @@ -10,12 +10,13 @@ Welcome to the Civic Tech Jobs team! This guide will help get you up to speed on If you have not read the [Guide for New Volunteers](https://www.hackforla.org/getting-started), please do so. -1. Read [Introduction to the Project](https://hackforla.github.io/CivicTechJobs/) if you haven't already read it. -1. Join the [Civic Tech Jobs](https://hackforla.slack.com/archives/C02509WHFQQ) Slack channel and introduce yourself and mention the role you are interested in. Our PM's [Joyce Guo](https://hackforla.slack.com/team/U05JUKMMVDJ) & [Sabrina Heasley](https://hackforla.slack.com/team/U05GDBDPEDR) will help you get onboarded with the following steps. -1. Complete this form [Team Roster Onboarding Form](https://docs.google.com/forms/d/e/1FAIpQLSfv-VTLseKixhzbPvY_hBHW30CaokUh4FOmst-4ZEM639EinQ/viewform) and inform PM after you have done so. +1. Check the [Community of Practice -> Open Roles Board](https://github.com/hackforla/communities-of-practice) for current open roles in the Civic Tech Jobs project. +2. Read [Introduction to the Project](https://hackforla.github.io/CivicTechJobs/) if you haven't already read it. +3. If interested in joining the team, complete this form [Team Roster Onboarding Form](https://docs.google.com/forms/d/e/1FAIpQLSfv-VTLseKixhzbPvY_hBHW30CaokUh4FOmst-4ZEM639EinQ/viewform). +4. Join the [Civic Tech Jobs](https://hackforla.slack.com/archives/C02509WHFQQ) Slack channel and introduce yourself and mention the role you are interested in. Our PM's will help you get onboarded with the following steps. 1. Accept your Google Drive invite to access the [shared folder](https://drive.google.com/drive/u/0/folders/0AMdnUkSXicNCUk9PVA). 1. Review the [Glossary](https://hackforla.github.io/CivicTechJobs/misc/glossary/). -1. Attend our weekly meetings on Tuesdays at 5pm PST. You can find the link pinned in our slack channel. +1. Attend our monthly all team meeting on the third Tuesday at 5pm PST. You can find the link pinned in our slack channel. ---