node-pg-migrate
Advanced tools
Comparing version 7.3.0 to 7.3.1
@@ -16,3 +16,3 @@ export { Migration } from './migration'; | ||
export type { Sql } from './operations/sql'; | ||
export type { Action, AddColumns, AddColumnsFn, AddColumnsOptions, AlterColumn, AlterColumnOptions, AlterTable, AlterTableOptions, ColumnDefinition, ColumnDefinitions, ConstraintOptions, CreateConstraint, CreateConstraintFn, CreateConstraintFn1, CreateConstraintFn2, CreateTable, CreateTableFn, DropColumns, DropColumnsOptions, DropConstraint, DropConstraintOptions, DropTable, DropTableOptions, ForeignKeyOptions, Like, LikeOptions, ReferencesOptions, RenameColumn, RenameColumnFn, RenameConstraint, RenameConstraintFn, RenameTable, RenameTableFn, SequenceGeneratedOptions, TableOptions, } from './operations/tables'; | ||
export type { Action, AddColumns, AddColumnsFn, AddColumnsOptions, AlterColumn, AlterColumnOptions, AlterTable, AlterTableOptions, ColumnDefinition, ColumnDefinitions, ConstraintOptions, CreateConstraint, CreateConstraintFn, CreateTable, CreateTableFn, DropColumns, DropColumnsOptions, DropConstraint, DropConstraintOptions, DropTable, DropTableOptions, ForeignKeyOptions, Like, LikeOptions, ReferencesOptions, RenameColumn, RenameColumnFn, RenameConstraint, RenameConstraintFn, RenameTable, RenameTableFn, SequenceGeneratedOptions, TableOptions, } from './operations/tables'; | ||
export type { CreateTrigger, CreateTriggerFn, CreateTriggerFn1, CreateTriggerFn2, DropTrigger, DropTriggerOptions, RenameTrigger, RenameTriggerFn, TriggerOptions, } from './operations/triggers'; | ||
@@ -19,0 +19,0 @@ export type { AddTypeAttribute, AddTypeAttributeFn, AddTypeValue, AddTypeValueOptions, CreateType, CreateTypeFn, DropType, DropTypeAttribute, DropTypeAttributeOptions, DropTypeOptions, RenameType, RenameTypeAttribute, RenameTypeAttributeFn, RenameTypeFn, RenameTypeValue, RenameTypeValueFn, SetTypeAttribute, } from './operations/types'; |
@@ -5,6 +5,4 @@ import type { MigrationOptions } from '../../types'; | ||
import type { ConstraintOptions } from './shared'; | ||
export declare type CreateConstraintFn1 = (tableName: Name, constraintName: string | null, constraintOptions: ConstraintOptions & DropConstraintOptions) => string; | ||
export declare type CreateConstraintFn2 = (tableName: Name, constraintName: string | null, expression: string) => string; | ||
export declare type CreateConstraintFn = CreateConstraintFn1 & CreateConstraintFn2; | ||
export declare type CreateConstraintFn = (tableName: Name, constraintName: string | null, constraintExpressionOrOptions: (ConstraintOptions & DropConstraintOptions) | string) => string; | ||
export declare type CreateConstraint = Reversible<CreateConstraintFn>; | ||
export declare function addConstraint(mOptions: MigrationOptions): CreateConstraint; |
@@ -28,6 +28,6 @@ "use strict"; | ||
function addConstraint(mOptions) { | ||
const _add = (tableName, constraintName, expression) => { | ||
const { constraints, comments } = typeof expression === "string" ? { | ||
const _add = (tableName, constraintName, expressionOrOptions) => { | ||
const { constraints, comments } = typeof expressionOrOptions === "string" ? { | ||
constraints: [ | ||
`${constraintName ? `CONSTRAINT ${mOptions.literal(constraintName)} ` : ""}${expression}` | ||
`${constraintName ? `CONSTRAINT ${mOptions.literal(constraintName)} ` : ""}${expressionOrOptions}` | ||
], | ||
@@ -37,3 +37,3 @@ comments: [] | ||
tableName, | ||
expression, | ||
expressionOrOptions, | ||
constraintName, | ||
@@ -49,3 +49,3 @@ mOptions.literal | ||
}; | ||
_add.reverse = (tableName, constraintName, options) => { | ||
_add.reverse = (tableName, constraintName, expressionOrOptions) => { | ||
if (constraintName === null) { | ||
@@ -56,3 +56,3 @@ throw new Error( | ||
} | ||
if (typeof options === "string") { | ||
if (typeof expressionOrOptions === "string") { | ||
throw new Error( | ||
@@ -62,3 +62,7 @@ "Impossible to automatically infer down migration for addConstraint with raw SQL expression" | ||
} | ||
return (0, import_dropConstraint.dropConstraint)(mOptions)(tableName, constraintName, options); | ||
return (0, import_dropConstraint.dropConstraint)(mOptions)( | ||
tableName, | ||
constraintName, | ||
expressionOrOptions | ||
); | ||
}; | ||
@@ -65,0 +69,0 @@ return _add; |
{ | ||
"name": "node-pg-migrate", | ||
"version": "7.3.0", | ||
"version": "7.3.1", | ||
"description": "PostgreSQL database migration management tool for node.js", | ||
@@ -5,0 +5,0 @@ "bin": { |
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
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
12917
522224