diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-11-13 08:40:20 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-12-05 06:24:48 +0800 |
commit | 329c68f610843ebded9ca31fc9cd6f3eed744a8e (patch) | |
tree | 166b089d14a10e47e206a971998597960e267790 /packages/pipeline | |
parent | 6fb333f2003a67277a7605332f146adb2758cdd0 (diff) | |
download | dexon-sol-tools-329c68f610843ebded9ca31fc9cd6f3eed744a8e.tar dexon-sol-tools-329c68f610843ebded9ca31fc9cd6f3eed744a8e.tar.gz dexon-sol-tools-329c68f610843ebded9ca31fc9cd6f3eed744a8e.tar.bz2 dexon-sol-tools-329c68f610843ebded9ca31fc9cd6f3eed744a8e.tar.lz dexon-sol-tools-329c68f610843ebded9ca31fc9cd6f3eed744a8e.tar.xz dexon-sol-tools-329c68f610843ebded9ca31fc9cd6f3eed744a8e.tar.zst dexon-sol-tools-329c68f610843ebded9ca31fc9cd6f3eed744a8e.zip |
Configure TypeORM for migrations. Add new package.json scripts.
Diffstat (limited to 'packages/pipeline')
-rw-r--r-- | packages/pipeline/package.json | 5 | ||||
-rw-r--r-- | packages/pipeline/src/ormconfig.ts | 25 | ||||
-rw-r--r-- | packages/pipeline/src/scripts/pull_missing_events.ts | 6 | ||||
-rw-r--r-- | packages/pipeline/src/scripts/update_relayer_info.ts | 6 | ||||
-rw-r--r-- | packages/pipeline/tsconfig.json | 2 | ||||
-rw-r--r-- | packages/pipeline/typedoc-tsconfig.json | 7 |
6 files changed, 21 insertions, 30 deletions
diff --git a/packages/pipeline/package.json b/packages/pipeline/package.json index 3380a970a..367296e05 100644 --- a/packages/pipeline/package.json +++ b/packages/pipeline/package.json @@ -13,7 +13,10 @@ "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", "clean": "shx rm -rf lib", - "lint": "tslint --project ." + "lint": "tslint --project .", + "migrate:run": "yarn typeorm migration:run --config ./lib/src/ormconfig", + "migrate:revert": "yarn typeorm migration:revert --config ./lib/src/ormconfig", + "migrate:create": "yarn typeorm migration:create --config ./lib/src/ormconfig --dir migrations" }, "config": { "postpublish": { diff --git a/packages/pipeline/src/ormconfig.ts b/packages/pipeline/src/ormconfig.ts index 39b496ace..95c27eeba 100644 --- a/packages/pipeline/src/ormconfig.ts +++ b/packages/pipeline/src/ormconfig.ts @@ -20,28 +20,13 @@ const entities = [ Transaction, ]; -export const testConfig: ConnectionOptions = { - type: 'sqlite', - database: 'database.sqlite', - synchronize: true, - logging: false, - entities, - migrations: ['./lib/src/migrations/**/*.js'], - cli: { - entitiesDir: 'lib/src/entities', - migrationsDir: 'lib/src/migrations', - }, -}; - -export const deployConfig: ConnectionOptions = { +const config: ConnectionOptions = { type: 'postgres', url: process.env.ZEROEX_DATA_PIPELINE_DB_URL, - synchronize: true, + synchronize: false, logging: false, entities, - migrations: ['./lib/src/migrations/**/*.js'], - cli: { - entitiesDir: 'lib/src/entities', - migrationsDir: 'lib/src/migrations', - }, + migrations: ['./lib/migrations/**/*.js'], }; + +module.exports = config as ConnectionOptions; diff --git a/packages/pipeline/src/scripts/pull_missing_events.ts b/packages/pipeline/src/scripts/pull_missing_events.ts index cca0d9cfe..e2b312280 100644 --- a/packages/pipeline/src/scripts/pull_missing_events.ts +++ b/packages/pipeline/src/scripts/pull_missing_events.ts @@ -2,11 +2,11 @@ import { web3Factory } from '@0x/dev-utils'; import { Web3ProviderEngine } from '@0x/subproviders'; import R = require('ramda'); import 'reflect-metadata'; -import { Connection, createConnection, Repository } from 'typeorm'; +import { Connection, ConnectionOptions, createConnection, Repository } from 'typeorm'; import { ExchangeEventsSource } from '../data_sources/contract-wrappers/exchange_events'; import { ExchangeFillEvent } from '../entities'; -import { deployConfig } from '../ormconfig'; +import * as ormConfig from '../ormconfig'; import { parseExchangeEvents } from '../parsers/events'; import { handleError } from '../utils'; @@ -17,7 +17,7 @@ const BATCH_SAVE_SIZE = 1000; // Number of events to save at once. let connection: Connection; (async () => { - connection = await createConnection(deployConfig); + connection = await createConnection(ormConfig as ConnectionOptions); const provider = web3Factory.getRpcProvider({ rpcUrl: 'https://mainnet.infura.io', }); diff --git a/packages/pipeline/src/scripts/update_relayer_info.ts b/packages/pipeline/src/scripts/update_relayer_info.ts index 051289992..af9dd726e 100644 --- a/packages/pipeline/src/scripts/update_relayer_info.ts +++ b/packages/pipeline/src/scripts/update_relayer_info.ts @@ -1,9 +1,9 @@ import 'reflect-metadata'; -import { Connection, createConnection } from 'typeorm'; +import { Connection, ConnectionOptions, createConnection } from 'typeorm'; import { RelayerRegistrySource } from '../data_sources/relayer-registry'; import { Relayer } from '../entities'; -import { deployConfig } from '../ormconfig'; +import * as ormConfig from '../ormconfig'; import { parseRelayers } from '../parsers/relayer_registry'; import { handleError } from '../utils'; @@ -15,7 +15,7 @@ const RELAYER_REGISTRY_URL = let connection: Connection; (async () => { - connection = await createConnection(deployConfig); + connection = await createConnection(ormConfig as ConnectionOptions); await getRelayers(); process.exit(0); })().catch(handleError); diff --git a/packages/pipeline/tsconfig.json b/packages/pipeline/tsconfig.json index 918d469ed..6f138f260 100644 --- a/packages/pipeline/tsconfig.json +++ b/packages/pipeline/tsconfig.json @@ -6,5 +6,5 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true }, - "include": ["./src/**/*", "./test/**/*"] + "include": ["./src/**/*", "./test/**/*", "./migrations/**/*"] } diff --git a/packages/pipeline/typedoc-tsconfig.json b/packages/pipeline/typedoc-tsconfig.json index b9c6b36f3..8b0ff51c1 100644 --- a/packages/pipeline/typedoc-tsconfig.json +++ b/packages/pipeline/typedoc-tsconfig.json @@ -1,7 +1,10 @@ { "extends": "../../typedoc-tsconfig", "compilerOptions": { - "outDir": "lib" + "outDir": "lib", + "rootDir": ".", + "emitDecoratorMetadata": true, + "experimentalDecorators": true }, - "include": ["src/**/*", "test/**/*"] + "include": ["./src/**/*", "./test/**/*", "./migrations/**/*"] } |