Skip to content

Commit

Permalink
feat: add migration script
Browse files Browse the repository at this point in the history
Signed-off-by: Nam Hoang <[email protected]>
  • Loading branch information
namhoang1604 committed Aug 16, 2023
1 parent a134e2f commit ecfc093
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"test:packages-watch": "pnpm test:packages --watch --verbose",
"test:oa-renderer": "cd packages/vckit-oa-renderers && pnpm test",
"test:oa-renderer-ci": "pnpm test:oa-renderer -- --coverage=true",
"migrate:db": "pnpm -r --stream typeorm migration:run",
"rollback:db": "pnpm -r --stream typeorm migration:revert",
"watch": "pnpm -r exec --if-present 'pnpm run watch'",
"vckit": "cross-env NODE_NO_WARNINGS=1 ./packages/cli/bin/vckit.js",
"prettier": "prettier --write \"{packages,docs,__tests__,!build}/**/*.{ts,js,json,md,yml}\"",
Expand Down
3 changes: 2 additions & 1 deletion packages/encrypted-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"scripts": {
"build": "tsc",
"extract-api": "node ../cli/bin/vckit.js dev extract-api"
"extract-api": "node ../cli/bin/vckit.js dev extract-api",
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d ./build/data-source.js"
},
"license": "Apache-2.0",
"keywords": [],
Expand Down
21 changes: 21 additions & 0 deletions packages/encrypted-storage/src/data-source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { DataSource, DataSourceOptions } from 'typeorm';
import { migrations, Entities } from './index.js';

const dataSource = {
// For postgres
// host: 'localhost',
// port: 5432,
// username: 'postgres',
// password: 'postgres',
// poolSize: 10,
// type: 'postgres',
// database: 'vckit',
type: 'sqlite',
database: '../../../database.sqlite',
entities: Entities,
synchronize: false,
logging: false,
migrations: migrations,
};

export default new DataSource(dataSource as DataSourceOptions);
3 changes: 2 additions & 1 deletion packages/revocation-list-2020/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"scripts": {
"build": "tsc",
"extract-api": "node ../cli/bin/vckit.js dev extract-api"
"extract-api": "node ../cli/bin/vckit.js dev extract-api",
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d ./build/data-source.js"
},
"license": "Apache-2.0",
"keywords": [],
Expand Down
21 changes: 21 additions & 0 deletions packages/revocation-list-2020/src/data-source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { DataSource, DataSourceOptions } from 'typeorm';
import { migrations, Entities } from './index.js';

const dataSource = {
// For postgres
// host: 'localhost',
// port: 5432,
// username: 'postgres',
// password: 'postgres',
// poolSize: 10,
// type: 'postgres',
// database: 'vckit',
type: 'sqlite',
database: '../../../database.sqlite',
entities: Entities,
synchronize: false,
logging: false,
migrations: migrations,
};

export default new DataSource(dataSource as DataSourceOptions);

0 comments on commit ecfc093

Please sign in to comment.