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

View file

@ -12,6 +12,6 @@ post {
body:json { 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/mapped-types": "*",
"@nestjs/platform-express": "^11.0.1", "@nestjs/platform-express": "^11.0.1",
"@nestjs/typeorm": "^11.0.0", "@nestjs/typeorm": "^11.0.0",
"pg": "^8.18.0",
"reflect-metadata": "^0.2.2", "reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",
"sqlite3": "^5.1.7",
"typeorm": "^0.3.28" "typeorm": "^0.3.28"
}, },
"devDependencies": { "devDependencies": {

View file

@ -1,6 +1,6 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { MerchantsModule } from './merchants/merchants.module'; import { MerchantsModule } from './merchants/merchants.module';
import { Merchant } from './merchants/entities/merchant.entity'; import { Merchant } from './merchants/entities/merchant.entity';
import { TagsModule } from './tags/tags.module'; 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 { ExpensesModule } from './expenses/expenses.module';
import { Expense } from './expenses/entities/expense.entity'; 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({ @Module({
imports: [ 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, MerchantsModule,
TagsModule, TagsModule,
CategoriesModule, CategoriesModule,