Skip to content

Commit

Permalink
Add db:migrate-one and db:rollback-one npm scripts (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
imsitnikov authored May 22, 2024
1 parent 598943f commit 8582d1f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@gravity-ui/expresskit": "^1.2.1",
"@gravity-ui/gateway": "^2.0.0",
"@gravity-ui/nodekit": "^1.1.1",
"@gravity-ui/postgreskit": "^1.1.1",
"@gravity-ui/postgreskit": "^1.3.0",
"ajv": "^6.12.4",
"axios": "^1.6.0",
"axios-retry": "^3.1.9",
Expand Down Expand Up @@ -59,7 +59,9 @@
"build:test:int": "npm run build && npm run test:int",
"test": "npm run build && npm run test:unit && npm run test:int",
"db:migrate": "node dist/server/db/scripts/migrate.js",
"db:migrate-one": "node dist/server/db/scripts/migrate-one.js",
"db:rollback": "node dist/server/db/scripts/rollback.js",
"db:rollback-one": "node dist/server/db/scripts/rollback-one.js",
"console": "node dist/server/console",
"prepare-and-test": "rm -rf dist/server && npm run build && npm test",
"prepare:db": "npm run build && CI_MODE=true SQL_DEBUG=false DEBUG=false node dist/server/db/scripts/clear-and-prepare",
Expand Down
13 changes: 13 additions & 0 deletions src/db/scripts/migrate-one.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require('dotenv').config();
require('../../index');
import {helpers} from '../index';

helpers
.migrateDatabase({onlyOne: true})
.then(() => {
process.exit(0);
})
.catch((error) => {
console.error(error);
process.exit(1);
});
13 changes: 13 additions & 0 deletions src/db/scripts/rollback-one.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require('dotenv').config();
require('../../index');
import {helpers} from '../index';

helpers
.rollbackDatabase({onlyOne: true})
.then(() => {
process.exit(0);
})
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit 8582d1f

Please sign in to comment.