Skip to content

Latest commit

 

History

History
48 lines (28 loc) · 1.45 KB

README.md

File metadata and controls

48 lines (28 loc) · 1.45 KB

Database

This session description the workflow related to erd.txt and database schema migration.

Viewing database schema

You can copy the content of erd.txt into the hosted web ui.

The hosted version store the content in LocalStorage, so the changes are persisted across page reload. You can then paste the updated version back to erd.txt.

In some region, it may take quite some time to load the website, you can run the web ui locally as well.

Command to run the web ui of erd locally:

npm run ui

The local version can auto load and save the content of erd.txt on your disk.

Updating database schema (migration)

Remark: cd to db if not done already

Auto mode:

  1. update erd.txt with any text editor
  2. run npm run update

Manual mode:

  1. update erd.txt with any text editor
  2. run npm run gen-migrate
  3. review the generated migration script in the migrations directory
  4. run npm run migrate
  5. run npm run gen-proxy

Populating database (seeding)

You can setup configuration data and sample data in seed.ts, then run it with npm run seed.

Why a separate package?

This package is used to isolate knex from top-level package.

We're using esm on the top-level package but knex with typescript only works in commonjs package.

The files here are compiled and imported from the server directly, so the dependencies of this package should appear on the top-level package.json as well.