Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README for Database Configuration and Migration Scripts #144

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,99 @@ scholarx-backend/
- `package.json`: Contains information about the project and its dependencies.
- `tsconfig.json`: Configuration file for the TypeScript compiler.

Database Configuration and Migration
------------------------------------

### Setting up the Database

1. Ensure you have PostgreSQL installed on your machine. If not, you can download it from [here](https://www.postgresql.org/download/).

2. Create a new PostgreSQL database:

```bash
CREATE DATABASE scholarx;
```


3. Update your `.env` file with your database configuration:

```bash
DB_HOST=localhost
DB_PORT=5432
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=scholarx
```

### Running Migrations and Seeding the Database

#### Migration Commands

1. **Generate a new migration**:


```bash
npm run migration:generate -- -n MigrationName
```

This command generates a new migration file with the specified name.

2. **Run migrations**:


```bash
npm run migration:run
```

This command runs all pending migrations.

3. **Synchronize the database schema**:


```bash
npm run sync:db
```

This command synchronizes your database schema with the current state of your entities.

4. **Seed the database**:


```bash
npm run seed
```

This command builds the project and runs the database seeding script located in `dist/src/scripts/seed-db.js`.

### Example Migration and Seeding Commands

- To generate a new migration named `AddUserTable`:


```bash
npm run migration:generate -- -n AddUserTable
```

- To run all pending migrations:


```bash
npm run migration:run
```

- To synchronize the database schema:

```bash
npm run sync:db
```

- To seed the database:


```bash
npm run seed
```

## Setting up Google Authentication

1. Open Google Cloud Console:
Expand Down
Loading