Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Latest commit

 

History

History
22 lines (16 loc) · 1.39 KB

HOW-TO-MIGRATE-README.md

File metadata and controls

22 lines (16 loc) · 1.39 KB

How to migrate with TypeORM

This Readme will shortly explain how to create database migrations for model changes introduced by a new branch (hereinafter referred to as "target branch").

Prerequisites

It is necessary to have a local postgres database for development with the credentials stored in the corresponding environment variables when creating the migrations. This database is later used to store the state of the dev branch which is then compared by TypeORM to the state on the target branch.

Steps

You'll need to perform the following steps to use TypeORM's auto generation feature for migrations:

  • Make sure your branch is up-to-date with remote branch dev
  • Change your local branch to dev
  • Run command npm run build:clean && npm run web:dev. Your local db is now in the state defined by the current code on the dev branch.
  • Change back to your target branch
  • Generate a migration file with the command npm run db:migration:generate NAME_OF_MIGRATION where NAME_OF_MIGRATION is a simple and short description of what the new migration should do.
  • Check the generated file and delete unnecessary statements in up like ALTER COLUMN "verification" SET DEFAULT null and in down like ALTER COLUMN "verification" DROP DEFAULT (please also see typeorm/typeorm#3076)

Local testing

Comming soon...

See corona-school#114