0.2.1 • Published 4 years ago

converse-db v0.2.1

Weekly downloads
-
License
-
Repository
bitbucket
Last release
4 years ago

converse-db

This repo holds all the TypeORM DB models used in different projects. It also exposes some helper functions that allow for memoization of queries.

The repo url can be used as a NPM package source with the build files functioning as a NPM package.

Init

For migrations you need to create a separate ormconfig.env file with this content:

TYPEORM_CONNECTION = postgres
TYPEORM_HOST = HOST
TYPEORM_USERNAME = USERNAME
TYPEORM_PASSWORD = PASSWORD
TYPEORM_DATABASE = postgres
TYPEORM_LOGGING = true
TYPEORM_ENTITIES = dist/src/entities/*.js
TYPEORM_MIGRATIONS = dist/migrations/*.js
TYPEORM_MIGRATIONS_DIR = migrations

How to update the DB entities/fixtures

  • make sure the ormconfig-file points to a DB that is up-to-date or first run the migration on a local DB to have a correct point of starting
  • make the desired changes to the DB entitity files and/or add fixtures to niches, publications or providers
  • run npm run migration:create MIGRATION_NAME to create a new migration file based on changes made to the entities
  • Check the newly created migration file to see if it makes sense!!! Because of us using an older version of TypeORM the automatic creation of the update scripts is quite poor and most cases need to be manually updated/cleaned up in order for the update file to be correct
  • commiting changes will run the build process so all files committed will be up to date
  • push changes and run the desired pipeline for DEV or PROD on Bitbucket to run the migration on their respective DBs

Manually/local running of scripts

  • npm run migration create MIGRATION_NAME to create a new migration file of of entity changes
  • npm run migration:run to run a migration on the DB specified in the ormconfig.env file. TAKE CAUTION WHEN RUNNING THIS ON A LIVE DB
  • npm run migration:revert to revert a migration one step at the time on the DB specified in the ormconfig.env file. TAKE CAUTION WHEN RUNNING THIS ON A LIVE DB
  • seed:publications/seed:niches/seed:providers to update publications/niches/providers TAKE CAUTION WHEN RUNNING THIS ON A LIVE DB
0.2.1-AD-1266

4 years ago

0.2.1

4 years ago