Skip to content

Commit

Permalink
Seeding script (#12)
Browse files Browse the repository at this point in the history
* Add Prisma and create Prisma models

* Add MailingList table

* Add seeding script commmand

* Add seeding script

* Add seeding script command in package.json

* Fix code formatting with prettier

* Fix prettier issues

* Install react-calendar library

* Add instructions to run seeding script in README

* Fix dataModel.json syntax

* Add dotenvConfig function in seed config

* Update README with seeding instructions

* Fix merge conflicts

* Add types to seeding functions

* Fix type error

* Fix build error

* Update deploy.yml with syncing

* Build fix

* Update data models and seeding script with Subject Model

* Update docker-compose.yml

* deploy.yml

* Update docker-compose.yml

* Update docker-compose.yml

* Update deploy.yml

* Update package.json

* Update README.md

* Testing preview deployment url change

* Testing Next Auth compatibility 2

* updated datamodel

* Update README.md

* Renamed Secrets

* Updated Readme

* Update package.json-lock + remove comments

* testing reseeding during deployment

* Changed Schema

* Update README.md

* testing seeding during deployment

* rm stuff

* trying vercel deploy

* Added Conditional JS function

* Seeding Complete added to DockerFile

* Added commands

* test

* remove the empty vercel.json

* Update schema.prisma

* Update start.sh

* merge conflicts

* Update README.md

* testing vercel deployment

* Update package-lock.json

* Removed Mcafee antivirus

* Rewrite to get rid of start.sh and addressed issues

* Rewrite to get rid of start.sh and addressed issues

* removed mcafee antivirus

* Last commit

* Commit inflation goes brrrrrr

* Commit inflation goes brrrrrr

---------

Co-authored-by: Kelly Pham <[email protected]>
Co-authored-by: Chinemerem <[email protected]>
Co-authored-by: ludavidca <[email protected]>
Co-authored-by: ludavidca <[email protected]>
Co-authored-by: Rahul Tandon <[email protected]>
Co-authored-by: Chinemerem <[email protected]>
  • Loading branch information
7 people authored Sep 28, 2024
1 parent 01dcb40 commit 00f787e
Show file tree
Hide file tree
Showing 10 changed files with 3,662 additions and 1,996 deletions.
14 changes: 12 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ WORKDIR /sistema
# Copy package.json and package-lock.json
COPY package.json package-lock.json ./

# Copy Prisma Schema
COPY prisma ./prisma

# Install dependencies using npm
RUN npm install

# Expose the port the app runs on
EXPOSE 3000

# Start the Next.js application in development mode
CMD ["npm", "run", "dev"]
# Run the application
CMD echo "Waiting for database to be ready..." && \
echo "Running Prisma commands..." && \
npx prisma generate && \
npx prisma db push && \
npx @snaplet/seed sync && \
npx prisma db seed && \
echo "Starting Next.js application..." && \
npm run dev
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ docker system prune -a --volumes

### Accessing PostgreSQL Database

Run in two lines (View Absences Table):
```bash
docker exec -it sistema-db-1 psql -U sistema -d sistema
SELECT * FROM public."Absence";
```

Running the commands line by line.
```bash
# run a bash shell in the container
docker exec -it sistema-db-1 /bin/bash
Expand All @@ -139,7 +146,32 @@ psql -U sistema -d sistema
# quit
\q
# you can run any SQL query, don't forget the semicolon!
SELECT * FROM <table-name>;
SELECT * FROM public."<table-name>";
```

### Seeding the Production Database
** Database seeds automatically locally when docker compose build --up is run. Only run the following commands to seed the production database.

In the schema.prisma, set env variable to VERCEL_DATABASE_NON_POOLING. Then run the following command.

```bash
npx prisma generate; npx prisma db push; npx @snaplet/seed sync; npx prisma db seed
```

Run the following commands:

```bash
npx prisma generate
npx prisma db push
```

```bash
# In the root directory to sync seed.ts to the current data models of the database
npx @snaplet/seed sync

# Seeding the database according to seed.ts
npx prisma db seed

```

## Formatting and Linting
Expand Down
Loading

0 comments on commit 00f787e

Please sign in to comment.