Skip to content

Latest commit

 

History

History
128 lines (98 loc) · 4.94 KB

C2M2.md

File metadata and controls

128 lines (98 loc) · 4.94 KB

DRC-Portal - C2M2 branch

To safely merge recent changes at main into our local repo

git fetch origin main

git merge origin/main

To push these changes to the C2M2 branch of the GitHub repo

git status

if not already pointing to C2M2, do

git checkout C2M2

Make sure, head is C2M2, then

git push # or?: git add * && git commit -m 'Some message' && git push

To get the latest changes from C2M2 branch, just do

git pull # If more recent local changes, then it might ask to do: git add --all . && git stash

Getting Started

# prepare .env file & review
cp .env.example .env
# start database
#  (NOTE: If you're running another postgres database on your system, you should turn it off as the ports will conflict)
# Note that in line 110 (around that) for integration with other postgres containers, one may map other ports to 5432.
# The UCSD team will just use 5432:5432 port-binding to avoid confusion.
#  ports:
#      - 5432:5432
docker-compose up -d drc-portal-postgres
# To try another container from user account, Mano tried post 5433 while one postgres db is at 5432; created another yaml file and used 5433 in .env too; specified container name in new yaml file and used command: -p 5433; shm_size: 1024m; size: 120Gi
#docker-compose -f docker-compose_MRM.yaml up -d drc-portal-postgres

# install node modules
npm i
# initialize prisma: Sometimes, if many changes happened, it may help to do: 'npx prisma migrate reset' 
# Before that make sure you have all the migrations in prisma/migrations folder.
# Another useful option: npx prisma migrate deploy # deploy means: it will only update the public schema
# dev means it will update all schemas.
# It it still gives issues, you may have to clean the DB completely by removing the public schema as well in psql:
# DROP SCHEMA IF EXISTS public CASCADE; then, after the 'npx prisma migrate dev',
# go to database folder and re-populate by 'python3 ingestion.py' or 'python ingestion.py'
# Mano: if issues, may have to delete @@schema['public'] or @@schema['c2m2'] lines and a few other fixes
# Obsolete: npx prisma migrate dev
# Daniel: 2024/05/14: Below, primary means public schema
# npm run migrate:primary
npm run migrate
# to roll back a migration: npx prisma migrate resolve --rolled-back 20240405074418_mano_20240405
# After schema update, may need to run
npm run generate
# run dev server
npm run dev

Pulling and pushing from database via Prisma

# To describe models from the latest version of the database, use:
npx prisma db pull
# This will update column names, primary and foreign key relations etc from the database into the schema.prisma file.

# To write to the database from the latest version of the schema.prisma file, use:
npx prisma db push
# This will update column names, primary and foreign key relations etc from the schema.prisma file into the database. However, check docs to make sure data is not lost while updating columns.

Open http://localhost:3000 with your browser to see the platform.

The pages will auto-update as you edit the files.

Provisioning the Database

Much of the site is driven by contents of the database, see Provisioning the Database to populate your database with CFDE data.

Pulling New Changes

As the site evolves, changes may be made to the database. For the most part you can update your code base like so:

# get the latest changes
git pull
# update your database to match any added fields/tables
npx prisma migrate deploy
# then rerun-ingest as during Provisioning the Database above

# if the above doesn't work, you may need to run the below
#  command to completely recreate the database followed
#  by the ingest steps
npx prisma migrate reset

Learn More

To use authentication see the Auth README for more info.

To use prisma (the database) see the Prisma README for more info.

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Production Deployment to Kubernetes

# configure .env
# initiall install
helm repo add maayanlab https://maayanlab.github.io/helm-charts
helm install drc-portal maayanlab/docker-compose -f <(docker-compose config)

Releasing

# update versions, rebuild, and push docker container for this version
npm version patch

# create git release
VERSION=0.1.x
git add . && git commit -m $VERSION && git tag v$VERSION
git push && git push --tags

# update production (note that we have this in a drc namespace in prod)
helm upgrade -n drc drc-portal maayanlab/docker-compose -f <(docker-compose config)

# broke something? rollback with
helm rollback -n drc drc-portal <CURRENT_REVISION_NUMBER-1>