Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contember/database-migrations

Package Overview
Dependencies
Maintainers
5
Versions
247
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/database-migrations - npm Package Compare versions

Comparing version 0.8.0-alpha.0 to 0.8.0-alpha.1

dist/src/runner.d.ts

3

dist/src/helpers.d.ts
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

2

dist/src/index.d.ts
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc