migrated from sqlite to postgres

This commit is contained in:
Joe Arndt 2026-02-09 14:51:04 -06:00
parent 6600745072
commit 8e7016d15c
5 changed files with 341 additions and 64 deletions

View file

@ -7,27 +7,14 @@ $ npm install
```
## Compile and run the project
Run local Postgres DB:
```bash
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
docker run --name common-cents-db -e POSTGRES_USER=common-cents -e POSTGRES_PASSWORD=CommonCents_123! -p 5432:5432 -d postgres
```
## Run tests
Then run the API:
```bash
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
npm run start:dev
```
## Deployment

View file

@ -12,6 +12,6 @@ post {
body:json {
{
"name": "Category Three"
"name": "First Cat"
}
}

358
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -25,9 +25,9 @@
"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/typeorm": "^11.0.0",
"pg": "^8.18.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"sqlite3": "^5.1.7",
"typeorm": "^0.3.28"
},
"devDependencies": {

View file

@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
import { TypeOrmModule } from '@nestjs/typeorm';
import { MerchantsModule } from './merchants/merchants.module';
import { Merchant } from './merchants/entities/merchant.entity';
import { TagsModule } from './tags/tags.module';
@ -12,18 +12,18 @@ import { SubCategory } from './sub-categories/entities/sub-category.entity';
import { ExpensesModule } from './expenses/expenses.module';
import { Expense } from './expenses/entities/expense.entity';
const entities = [Merchant, Tag, Category, SubCategory, Expense];
const sqliteConfig: TypeOrmModuleOptions = {
synchronize: true,
type: 'sqlite',
database: 'common-cents.db',
entities
}
@Module({
imports: [
TypeOrmModule.forRoot(sqliteConfig),
TypeOrmModule.forRoot({
synchronize: true,
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'common-cents',
password: 'CommonCents_123!',
database: 'common-cents',
entities: [Merchant, Tag, Category, SubCategory, Expense]
}),
MerchantsModule,
TagsModule,
CategoriesModule,