@contember/database-migrations
Advanced tools
Comparing version 0.8.0-alpha.0 to 0.8.0-alpha.1
import { MigrationBuilder } from 'node-pg-migrate'; | ||
import { Client, ClientConfig } from 'pg'; | ||
export declare function createMigrationBuilder(): MigrationBuilder & { | ||
getSql: () => string; | ||
getSqlSteps: () => string[]; | ||
}; | ||
export declare function escapeValue(value: any): any; | ||
export declare function createPgClient(cfg: ClientConfig): Client; | ||
//# sourceMappingURL=helpers.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const pg_1 = require("pg"); | ||
function createMigrationBuilder() { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const builderClass = require('node-pg-migrate/dist/migration-builder'); | ||
const builderClass = require('node-pg-migrate/dist/migration-builder').default; | ||
return new builderClass({}, { | ||
@@ -18,2 +19,6 @@ query: null, | ||
exports.escapeValue = escapeValue; | ||
function createPgClient(cfg) { | ||
return new pg_1.Client(cfg); | ||
} | ||
exports.createPgClient = createPgClient; | ||
//# sourceMappingURL=helpers.js.map |
export * from './MigrationsRunner'; | ||
export * from './helpers'; | ||
export { MigrationBuilder } from 'node-pg-migrate'; | ||
export { MigrationBuilder, Name } from 'node-pg-migrate'; | ||
export { DatabaseCredentials } from '@contember/database'; | ||
//# sourceMappingURL=index.d.ts.map |
import { DatabaseCredentials } from '@contember/database'; | ||
import { ClientBase } from 'pg'; | ||
export declare class MigrationsRunner { | ||
@@ -6,6 +7,7 @@ private readonly db; | ||
private readonly dir; | ||
constructor(db: DatabaseCredentials, schema: string, dir: string); | ||
migrate(log?: boolean): Promise<void>; | ||
private readonly dbClient?; | ||
constructor(db: DatabaseCredentials, schema: string, dir: string, dbClient?: ClientBase | undefined); | ||
migrate<MigrationArgs>(log?: boolean, migrationArgs?: MigrationArgs): Promise<void>; | ||
private createDatabaseIfNotExists; | ||
} | ||
//# sourceMappingURL=MigrationsRunner.d.ts.map |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const database_1 = require("@contember/database"); | ||
const runner_1 = __importDefault(require("./runner")); | ||
class MigrationsRunner { | ||
constructor(db, schema, dir) { | ||
constructor(db, schema, dir, dbClient) { | ||
this.db = db; | ||
this.schema = schema; | ||
this.dir = dir; | ||
this.dbClient = dbClient; | ||
} | ||
async migrate(log = true) { | ||
async migrate(log = true, migrationArgs) { | ||
await this.createDatabaseIfNotExists(); | ||
const pgMigrate = (await Promise.resolve().then(() => __importStar(require('node-pg-migrate')))).default; | ||
await pgMigrate({ | ||
databaseUrl: this.db, | ||
const dbParams = this.dbClient | ||
? { dbClient: this.dbClient } | ||
: { databaseUrl: this.db }; | ||
await runner_1.default({ | ||
...dbParams, | ||
dir: this.dir, | ||
schema: this.schema, | ||
migrationsTable: 'migrations', | ||
checkOrder: true, | ||
direction: 'up', | ||
count: Infinity, | ||
ignorePattern: '^\\..*$', | ||
ignorePattern: '(\\..*)|(.+\\.ts)|tsconfig\\..+|.+\\.map|.+\\.test\\.js', | ||
createSchema: true, | ||
singleTransaction: true, | ||
migrationArgs, | ||
log: (msg) => { | ||
log && msg.startsWith('> ') && console.log(msg.substring(2)); | ||
log && console.log(msg); | ||
}, | ||
@@ -34,0 +31,0 @@ }); |
{ | ||
"name": "@contember/database-migrations", | ||
"version": "0.8.0-alpha.0", | ||
"version": "0.8.0-alpha.1", | ||
"license": "Apache-2.0", | ||
@@ -8,4 +8,4 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@contember/database": "^0.8.0-alpha.0", | ||
"node-pg-migrate": "~3.22.1" | ||
"@contember/database": "^0.8.0-alpha.1", | ||
"node-pg-migrate": "^4.8.0" | ||
}, | ||
@@ -19,3 +19,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "e8480ed2e4f612537e229c6017565ec43917618e" | ||
"gitHead": "c20d28db4163768b7e479fabf8ffb2d15a7fc153" | ||
} |
import { MigrationBuilder } from 'node-pg-migrate' | ||
import { Client, ClientConfig } from 'pg' | ||
export function createMigrationBuilder(): MigrationBuilder & { getSql: () => string } { | ||
export function createMigrationBuilder(): MigrationBuilder & { getSql: () => string; getSqlSteps: () => string[] } { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const builderClass = require('node-pg-migrate/dist/migration-builder') | ||
const builderClass = require('node-pg-migrate/dist/migration-builder').default | ||
return new builderClass( | ||
@@ -21,1 +22,5 @@ {}, | ||
} | ||
export function createPgClient(cfg: ClientConfig) { | ||
return new Client(cfg) | ||
} |
export * from './MigrationsRunner' | ||
export * from './helpers' | ||
export { MigrationBuilder } from 'node-pg-migrate' | ||
export { MigrationBuilder, Name } from 'node-pg-migrate' | ||
export { DatabaseCredentials } from '@contember/database' |
import { DatabaseCredentials, Connection, wrapIdentifier } from '@contember/database' | ||
import migrate from './runner' | ||
import { ClientBase } from 'pg' | ||
import { RunnerOptionClient, RunnerOptionUrl } from 'node-pg-migrate/dist/types' | ||
@@ -8,20 +11,20 @@ export class MigrationsRunner { | ||
private readonly dir: string, | ||
private readonly dbClient?: ClientBase, | ||
) {} | ||
public async migrate(log: boolean = true) { | ||
public async migrate<MigrationArgs>(log: boolean = true, migrationArgs?: MigrationArgs) { | ||
await this.createDatabaseIfNotExists() | ||
const pgMigrate = (await import('node-pg-migrate')).default | ||
await pgMigrate({ | ||
databaseUrl: this.db, | ||
const dbParams: RunnerOptionClient | RunnerOptionUrl = this.dbClient | ||
? { dbClient: this.dbClient } | ||
: { databaseUrl: this.db } | ||
await migrate({ | ||
...dbParams, | ||
dir: this.dir, | ||
schema: this.schema, | ||
migrationsTable: 'migrations', | ||
checkOrder: true, | ||
direction: 'up', | ||
count: Infinity, | ||
ignorePattern: '^\\..*$', | ||
ignorePattern: '(\\..*)|(.+\\.ts)|tsconfig\\..+|.+\\.map|.+\\.test\\.js', | ||
createSchema: true, | ||
singleTransaction: true, | ||
migrationArgs, | ||
log: (msg: string) => { | ||
log && msg.startsWith('> ') && console.log(msg.substring(2)) | ||
log && console.log(msg) | ||
}, | ||
@@ -28,0 +31,0 @@ }) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
252718
27
574
2
1
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedcliui@6.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddecamelize@4.0.0(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedfind-up@4.1.0(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedlocate-path@5.0.0(transitive)
+ Addedmkdirp@1.0.4(transitive)
+ Addednode-pg-migrate@4.8.0(transitive)
+ Addedp-locate@4.1.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
+ Addedyargs@15.3.1(transitive)
+ Addedyargs-parser@18.1.3(transitive)
- Removedansi-regex@4.1.1(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedcliui@5.0.0(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedconfig@3.3.12(transitive)
- Removeddotenv@16.4.7(transitive)
- Removedemoji-regex@7.0.3(transitive)
- Removedfind-up@3.0.0(transitive)
- Removedis-fullwidth-code-point@2.0.0(transitive)
- Removedjson5@2.2.3(transitive)
- Removedlocate-path@3.0.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removednode-pg-migrate@3.22.1(transitive)
- Removedp-locate@3.0.0(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedstring-width@3.1.0(transitive)
- Removedstrip-ansi@5.2.0(transitive)
- Removedwrap-ansi@5.1.0(transitive)
- Removedyargs@14.0.0(transitive)
- Removedyargs-parser@13.1.2(transitive)
Updatednode-pg-migrate@^4.8.0