Type Alias: MigrationContext
MigrationContext =
object
Defined in: migrations/types.ts:38
What a migration's up receives. The helpers run raw SQL on a connection
that belongs to the runner, deliberately beside the ORM: a migration running
through the models would describe the schema it is in the middle of
changing.
Properties
addColumnIfMissing
addColumnIfMissing: (
args) =>Promise<void>
Defined in: migrations/types.ts:70
ALTER TABLE … ADD COLUMN IF NOT EXISTS, nullable. type is SQL and is
inlined, so it must come from the migration, never from its arguments.
Parameters
| Parameter | Type |
|---|---|
args | ColumnArgs & object |
Returns
Promise<void>
args
args:
MigrationArgs
Defined in: migrations/types.ts:48
client
client:
Sequelize
Defined in: migrations/types.ts:40
The runner's own Sequelize instance, for anything the helpers do not cover.
columnExists
columnExists: (
args) =>Promise<boolean>
Defined in: migrations/types.ts:64
Parameters
| Parameter | Type |
|---|---|
args | ColumnArgs |
Returns
Promise<boolean>
countOf
countOf: (
args) =>Promise<number>
Defined in: migrations/types.ts:62
One number out of a count(*), which Postgres returns as a bigint string.
Parameters
| Parameter | Type |
|---|---|
args | SqlArgs |
Returns
Promise<number>
dropColumnIfExists
dropColumnIfExists: (
args) =>Promise<void>
Defined in: migrations/types.ts:73
Parameters
| Parameter | Type |
|---|---|
args | ColumnArgs |
Returns
Promise<void>
dryRun
dryRun:
boolean
Defined in: migrations/types.ts:47
When true, every write helper (run, sync, addColumnIfMissing,
setNotNull, dropColumnIfExists) logs what it would do and does
nothing. select and the existence probes still read, so a migration can
report what a real run would change.
indexExists
indexExists: (
args) =>Promise<boolean>
Defined in: migrations/types.ts:65
Parameters
| Parameter | Type |
|---|---|
args | { index: string; } |
args.index | string |
Returns
Promise<boolean>
run
run: (
args) =>Promise<void>
Defined in: migrations/types.ts:60
Any statement that writes. Skipped on a dry run.
Parameters
| Parameter | Type |
|---|---|
args | SqlArgs |
Returns
Promise<void>
say
say: (
message) =>void
Defined in: migrations/types.ts:50
Progress lines, written through the runner's logger.
Parameters
| Parameter | Type |
|---|---|
message | string |
Returns
void
select
select: <
T>(args) =>Promise<T[]>
Defined in: migrations/types.ts:58
SELECT rows out. Always executes, even on a dry run.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
args | SqlArgs |
Returns
Promise<T[]>
setNotNull
setNotNull: (
args) =>Promise<void>
Defined in: migrations/types.ts:72
Idempotent: Postgres accepts SET NOT NULL on a column that has it.
Parameters
| Parameter | Type |
|---|---|
args | ColumnArgs |
Returns
Promise<void>
sync
sync: () =>
Promise<void>
Defined in: migrations/types.ts:56
The application's schema sync, when the runner was given one. A migration calls it after making a column exist and before applying the constraints the models declare, so the sync can create the indexes over it.
Returns
Promise<void>
tableExists
tableExists: (
args) =>Promise<boolean>
Defined in: migrations/types.ts:63
Parameters
| Parameter | Type |
|---|---|
args | { table: string; } |
args.table | string |
Returns
Promise<boolean>