This Node.js PostgreSQL project exemplifies a streamlined database setup using db-migration for efficient table creation and data seeding. The integration of the pg module enhances data querying capabilities, providing a seamless interface between the Node.js application and PostgreSQL database. Ideal for developers seeking a concise and effective solution for database management in Node.js projects, this GitHub repository offers a combination of structured migration workflows and powerful data querying using the 'pg' module.The migration scripts, conveniently managed through a dedicated tool, facilitate version control and ease of deployment.
- Install the dependencies
npm install
- Start the app in dev mode
npm run start:dev
- Builds the app at build, cleaning the folder first.
npm run build,
- Start the app in production
npm run start
Get your application DB up. Ensure that you have docker installed. We are using Postgres Docker container as the Database
-
Pull the PostgreSQL Docker Image
docker pull postgres
-
Run the PostgreSQL Container
docker run --name postgres-db -p 5432:5432 -e POSTGRES_PASSWORD=password -d postgres
-
Connect to the PostgreSQL Container
docker exec -it postgres-db psql -U postgres
Create the table and seed random data into it
npm run migrate:initialize
Delete the table
npm run migrate:all-delete
If you want to create new migration, execute the following command
node node_modules/db-migrate/bin/db-migrate create migration-name --sql-file
And then update the up sql file with the database statements
Step A : Identify the Entities and their relationship
- Employee has name , email ,contact number, designation, role
- Every employee is associated with a Business Unit
Step C: Export the ERD as plsql statements