indexer icon indicating copy to clipboard operation
indexer copied to clipboard

feat: add typeorm

Open lljxx1 opened this issue 1 year ago • 2 comments

File structure

src/data-source.ts
src/migration
src/entities

Init migration

run migrate but actually doesn't execute any SQL, used to set the database state to the latest migration

yarn typeorm-migrate-init

Migration

yarn typeorm-migrate

# revert to prev step
yarn typeorm-revert

Codebase Sync

auto sync Migration or Entitiy definitions to the src/data-source.ts

yarn typeorm-sync

lljxx1 avatar Oct 19 '23 03:10 lljxx1

Nice, a few questions / notes:

  • How does the new migration logic handles the old migrations (which I see were ported over)? Ideally it will skip them and only pick up the new ones (we don't want to have the old migrations re-run since that could create issues).
  • We should probably remove the node-pg-migrate dependency if it's not needed anymore together with any scripts for it (yarn migrate).

cc @nofir

georgeroman avatar Oct 19 '23 05:10 georgeroman

Nice, a few questions / notes:

  • How does the new migration logic handles the old migrations (which I see were ported over)? Ideally it will skip them and only pick up the new ones (we don't want to have the old migrations re-run since that could create issues).
  • We should probably remove the node-pg-migrate dependency if it's not needed anymore together with any scripts for it (yarn migrate).

cc @nofir

all the old migrations were converted to the TypeORM migration style from the original migration SQL, the migration state will be stored in the typeorm_migrations table, run yarn typeorm-migrate-init to skip all.

all the Entity was exported from the database by typeorm-model-generator. we could remove them if we don't really need them for now

lljxx1 avatar Oct 19 '23 07:10 lljxx1