rake-db 2.30.9 → 2.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +161 -87
- package/dist/index.js +987 -922
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +871 -806
- package/dist/index.mjs.map +1 -1
- package/dist/node-postgres.d.ts +1 -1
- package/dist/node-postgres.js +2 -2
- package/dist/node-postgres.js.map +1 -1
- package/dist/node-postgres.mjs +1 -1
- package/dist/node-postgres.mjs.map +1 -1
- package/dist/postgres-js.d.ts +1 -1
- package/dist/postgres-js.js +2 -2
- package/dist/postgres-js.js.map +1 -1
- package/dist/postgres-js.mjs +1 -1
- package/dist/postgres-js.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { SearchWeight, RecordOptionalString, DefaultPrivileges, AdapterBase, TableData, ColumnsShape, NoPrimaryKeyOption, MaybeArray, Column, RawSqlBase, RecordString, EnumColumn, EmptyObject, DbResult,
|
|
1
|
+
import * as pqb_internal from 'pqb/internal';
|
|
2
|
+
import { SearchWeight, RecordOptionalString, DefaultPrivileges, AdapterBase, TableData, ColumnsShape, NoPrimaryKeyOption, MaybeArray, Column, RawSqlBase, RecordString, EnumColumn, EmptyObject, DbResult, QueryLogObject, TableDataFn, TableDataItem, DbDomainArg, ColumnSchemaConfig, raw, DefaultColumnTypes, DefaultSchemaConfig, Db, QuerySchema, QueryLogger, MaybePromise, QueryLogOptions, ColumnsByType, DbStructureDomainsMap } from 'pqb/internal';
|
|
3
|
+
import * as packages_pqb_src_query from 'packages/pqb/src/query';
|
|
3
4
|
|
|
4
5
|
declare namespace DbStructure {
|
|
5
6
|
interface TableNameAndSchemaName {
|
|
@@ -491,18 +492,18 @@ declare const tableChangeMethods: {
|
|
|
491
492
|
columns: Columns_1 extends (string | TableData.Index.ColumnOptionsForColumn<string>)[] ? { [I in keyof Columns_1]: "column" extends keyof Columns_1[I] ? Columns_1[I][keyof Columns_1[I] & "column"] : Columns_1[I]; } : never;
|
|
492
493
|
name: string extends Name_1 ? never : Name_1;
|
|
493
494
|
};
|
|
494
|
-
index(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.OptionsArg | undefined):
|
|
495
|
-
searchIndex(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.TsVectorArg | undefined):
|
|
496
|
-
exclude(columns: TableData.Exclude.ColumnOrExpressionOptions<string>[], options?: TableData.Exclude.Options | undefined):
|
|
495
|
+
index(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.OptionsArg | undefined): pqb_internal.NonUniqDataItem;
|
|
496
|
+
searchIndex(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.TsVectorArg | undefined): pqb_internal.NonUniqDataItem;
|
|
497
|
+
exclude(columns: TableData.Exclude.ColumnOrExpressionOptions<string>[], options?: TableData.Exclude.Options | undefined): pqb_internal.NonUniqDataItem;
|
|
497
498
|
foreignKey<Shape>(columns: [string, ...string[]], fnOrTable: () => new () => {
|
|
498
499
|
columns: {
|
|
499
500
|
shape: Shape;
|
|
500
501
|
};
|
|
501
|
-
}, foreignColumns: [keyof Shape, ...(keyof Shape)[]], options?: TableData.References.Options | undefined):
|
|
502
|
-
foreignKey(columns: [string, ...string[]], fnOrTable: string, foreignColumns: [string, ...string[]], options?: TableData.References.Options | undefined):
|
|
503
|
-
check(check: RawSqlBase, name?: string | undefined):
|
|
504
|
-
sql:
|
|
505
|
-
enum(name: string): EnumColumn<
|
|
502
|
+
}, foreignColumns: [keyof Shape, ...(keyof Shape)[]], options?: TableData.References.Options | undefined): pqb_internal.NonUniqDataItem;
|
|
503
|
+
foreignKey(columns: [string, ...string[]], fnOrTable: string, foreignColumns: [string, ...string[]], options?: TableData.References.Options | undefined): pqb_internal.NonUniqDataItem;
|
|
504
|
+
check(check: RawSqlBase, name?: string | undefined): pqb_internal.NonUniqDataItem;
|
|
505
|
+
sql: packages_pqb_src_query.SqlFn;
|
|
506
|
+
enum(name: string): EnumColumn<pqb_internal.DefaultSchemaConfig, undefined, [string, ...string[]]>;
|
|
506
507
|
};
|
|
507
508
|
type TableChanger<CT> = MigrationColumnTypes<CT> & TableChangeMethods;
|
|
508
509
|
type TableChangeData = Record<string, RakeDbAst.ChangeTableItem.Column | RakeDbAst.ChangeTableItem.Rename | Change | SpecialChange | Column.Pick.Data>;
|
|
@@ -558,15 +559,22 @@ interface SilentQueries extends AdapterBase {
|
|
|
558
559
|
type DbMigration<CT> = DbResult<CT> & Migration<CT> & {
|
|
559
560
|
adapter: SilentQueries;
|
|
560
561
|
};
|
|
562
|
+
interface MigrationInterfaceResult {
|
|
563
|
+
adapter: SilentQueries;
|
|
564
|
+
getDb(columnTypes: unknown): DbMigration<DefaultColumnTypes<DefaultSchemaConfig>>;
|
|
565
|
+
}
|
|
561
566
|
/**
|
|
562
567
|
* Creates a new `db` instance that is an instance of `pqb` with mixed in migration methods from the `Migration` class.
|
|
563
568
|
* It overrides `query` and `array` db adapter methods to intercept SQL for the logging.
|
|
564
569
|
*
|
|
570
|
+
* A concrete `db` instance depends on column types, column types may vary between `change` calls,
|
|
571
|
+
* therefore it returns a function that accepts column types, caches db instance per given column types, and return the result.
|
|
572
|
+
*
|
|
565
573
|
* @param tx - database adapter that executes inside a transaction
|
|
566
574
|
* @param up - migrate or rollback
|
|
567
575
|
* @param config - config of `rakeDb`
|
|
568
576
|
*/
|
|
569
|
-
declare const createMigrationInterface: (tx: AdapterBase, up: boolean, config: Pick<RakeDbConfig, 'log' | 'logger'
|
|
577
|
+
declare const createMigrationInterface: (tx: AdapterBase, up: boolean, config: Pick<RakeDbConfig, 'log' | 'logger'>) => MigrationInterfaceResult;
|
|
570
578
|
type MigrationAdapter = AdapterBase;
|
|
571
579
|
declare class Migration<CT = unknown> {
|
|
572
580
|
adapter: MigrationAdapter;
|
|
@@ -1498,6 +1506,131 @@ declare const concatSchemaAndName: ({ schema, name, }: {
|
|
|
1498
1506
|
name: string;
|
|
1499
1507
|
}, excludeCurrentSchema?: string) => string;
|
|
1500
1508
|
|
|
1509
|
+
interface RakeDbChangeFnConfig {
|
|
1510
|
+
columnTypes: unknown;
|
|
1511
|
+
}
|
|
1512
|
+
/**
|
|
1513
|
+
* Function to use in migrations to wrap database changes
|
|
1514
|
+
* Saves the given callback to an internal queue,
|
|
1515
|
+
* and also returns the callback in case you want to export it from migration.
|
|
1516
|
+
*/
|
|
1517
|
+
interface MigrationChangeFn<ColumnTypes> {
|
|
1518
|
+
(fn: ChangeCallback$1<ColumnTypes>): MigrationChange;
|
|
1519
|
+
}
|
|
1520
|
+
declare const createMigrationChangeFn: <ColumnTypes = DefaultColumnTypes<DefaultSchemaConfig>>(config: {
|
|
1521
|
+
columnTypes?: ColumnTypes;
|
|
1522
|
+
}) => MigrationChangeFn<ColumnTypes>;
|
|
1523
|
+
interface MigrationChange {
|
|
1524
|
+
fn: ChangeCallback$1<unknown>;
|
|
1525
|
+
config: RakeDbChangeFnConfig;
|
|
1526
|
+
}
|
|
1527
|
+
type ChangeCallback$1<ColumnTypes> = (db: DbMigration<ColumnTypes>, up: boolean) => Promise<void>;
|
|
1528
|
+
|
|
1529
|
+
interface OrmParam {
|
|
1530
|
+
$getAdapter(): AdapterBase;
|
|
1531
|
+
}
|
|
1532
|
+
type DbParam = OrmParam | AdapterBase;
|
|
1533
|
+
|
|
1534
|
+
declare const saveMigratedVersion: (db: SilentQueries, version: string, name: string, config: Pick<RakeDbConfig, 'migrationsTable'>) => Promise<void>;
|
|
1535
|
+
declare const createMigrationsSchemaAndTable: (db: DbParam, config: {
|
|
1536
|
+
migrationsTable: string;
|
|
1537
|
+
logger?: QueryLogger;
|
|
1538
|
+
}) => Promise<void>;
|
|
1539
|
+
|
|
1540
|
+
interface MigrateFnParams {
|
|
1541
|
+
ctx?: RakeDbCtx;
|
|
1542
|
+
count?: number;
|
|
1543
|
+
force?: boolean;
|
|
1544
|
+
}
|
|
1545
|
+
interface MigrateConfigBase extends QueryLogOptions {
|
|
1546
|
+
migrationId?: RakeDbMigrationId;
|
|
1547
|
+
renameMigrations?: RakeDbRenameMigrationsInput;
|
|
1548
|
+
migrationsTable?: string;
|
|
1549
|
+
transaction?: 'single' | 'per-migration';
|
|
1550
|
+
transactionSearchPath?: SearchPath;
|
|
1551
|
+
forceDefaultExports?: boolean;
|
|
1552
|
+
beforeChange?: ChangeCallback;
|
|
1553
|
+
afterChange?: ChangeCallback;
|
|
1554
|
+
afterChangeCommit?: ChangeCommitCallback;
|
|
1555
|
+
beforeMigrate?: MigrationCallback;
|
|
1556
|
+
afterMigrate?: MigrationCallback;
|
|
1557
|
+
beforeRollback?: MigrationCallback;
|
|
1558
|
+
afterRollback?: MigrationCallback;
|
|
1559
|
+
}
|
|
1560
|
+
interface MigrateConfigFileBased extends MigrateConfigBase {
|
|
1561
|
+
basePath?: string;
|
|
1562
|
+
migrationsPath: string;
|
|
1563
|
+
import(path: string): Promise<unknown>;
|
|
1564
|
+
}
|
|
1565
|
+
interface MigrateConfigMigrationsProvided extends MigrateConfigBase {
|
|
1566
|
+
migrations: ModuleExportsRecord;
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Minimal configuration required by public migration functions
|
|
1570
|
+
* (`migrate`, `rollback`, `redo`) and the functions they invoke.
|
|
1571
|
+
*
|
|
1572
|
+
* Pass `log: true` to enable logging to console,
|
|
1573
|
+
* `log: false` to disable it, or leave `log` undefined to preserve the existing `logger`.
|
|
1574
|
+
*
|
|
1575
|
+
* All properties of {@link RakeDbConfig} that are unrelated to running migrations
|
|
1576
|
+
* (e.g. `commands`, `recurrentPath`, `schemaConfig`) are intentionally excluded.
|
|
1577
|
+
*/
|
|
1578
|
+
type MigrateConfig = MigrateConfigFileBased | MigrateConfigMigrationsProvided;
|
|
1579
|
+
interface MigrateFn {
|
|
1580
|
+
(db: DbParam, config: MigrateConfig, params?: MigrateFnParams): Promise<void>;
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* Will run all pending yet migrations, sequentially in order,
|
|
1584
|
+
* will apply `change` functions top-to-bottom.
|
|
1585
|
+
*
|
|
1586
|
+
* Supports `log?: boolean` option in config for programmatic use:
|
|
1587
|
+
* - `log: true` - enables logging to console
|
|
1588
|
+
* - `log: false` - disables logging
|
|
1589
|
+
* - `log: undefined` - preserves existing logger (for custom loggers)
|
|
1590
|
+
*
|
|
1591
|
+
* @param db - database adapter or transaction
|
|
1592
|
+
* @param config - specifies how to load migrations, callbacks, and logger
|
|
1593
|
+
* @param params - optional migration parameters (ctx, count, force)
|
|
1594
|
+
*/
|
|
1595
|
+
declare const migrate: MigrateFn;
|
|
1596
|
+
declare const migrateAndClose: MigrateFn;
|
|
1597
|
+
interface RunMigrationConfig extends QueryLogOptions {
|
|
1598
|
+
transactionSearchPath?: SearchPath;
|
|
1599
|
+
}
|
|
1600
|
+
declare function runMigration(db: DbParam, migration: () => MaybePromise<unknown>): Promise<void>;
|
|
1601
|
+
declare function runMigration(db: DbParam, config: RunMigrationConfig, migration: () => MaybePromise<unknown>): Promise<void>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Will roll back one latest applied migration,
|
|
1604
|
+
* will apply `change` functions bottom-to-top.
|
|
1605
|
+
*
|
|
1606
|
+
* Supports `log?: boolean` option in config for programmatic use:
|
|
1607
|
+
* - `log: true` - enables logging to console
|
|
1608
|
+
* - `log: false` - disables logging
|
|
1609
|
+
* - `log: undefined` - preserves existing logger (for custom loggers)
|
|
1610
|
+
*
|
|
1611
|
+
* Takes the same options as {@link migrate}.
|
|
1612
|
+
*
|
|
1613
|
+
* @param db - database adapter or transaction
|
|
1614
|
+
* @param config - specifies how to load migrations, callbacks, and logger
|
|
1615
|
+
* @param params - optional rollback parameters (ctx, count, force)
|
|
1616
|
+
*/
|
|
1617
|
+
declare const rollback: MigrateFn;
|
|
1618
|
+
/**
|
|
1619
|
+
* Calls {@link rollback} and then {@link migrate}.
|
|
1620
|
+
*
|
|
1621
|
+
* Supports `log?: boolean` option in config for programmatic use:
|
|
1622
|
+
* - `log: true` - enables logging to console
|
|
1623
|
+
* - `log: false` - disables logging
|
|
1624
|
+
* - `log: undefined` - preserves existing logger (for custom loggers)
|
|
1625
|
+
*
|
|
1626
|
+
* Takes the same options as {@link migrate}.
|
|
1627
|
+
*
|
|
1628
|
+
* @param db - database adapter or transaction
|
|
1629
|
+
* @param config - specifies how to load migrations, callbacks, and logger
|
|
1630
|
+
* @param params - optional redo parameters (ctx, count, force)
|
|
1631
|
+
*/
|
|
1632
|
+
declare const redo: MigrateFn;
|
|
1633
|
+
|
|
1501
1634
|
interface MigrationItemHasLoad {
|
|
1502
1635
|
path?: string;
|
|
1503
1636
|
/**
|
|
@@ -1547,7 +1680,7 @@ interface RakeDbCliConfigInputBase<SchemaConfig extends ColumnSchemaConfig, CT =
|
|
|
1547
1680
|
* @param arg.redo - whether it's migrating down and then up for `redo` command
|
|
1548
1681
|
* @param arg.migrations - array of executed (up or down) migrations
|
|
1549
1682
|
*/
|
|
1550
|
-
beforeChange?: ChangeCallback
|
|
1683
|
+
beforeChange?: ChangeCallback;
|
|
1551
1684
|
/**
|
|
1552
1685
|
* Is called once per db after migrating or rolling back a set of migrations.
|
|
1553
1686
|
* Runs inside the same transaction as migrations,
|
|
@@ -1558,7 +1691,7 @@ interface RakeDbCliConfigInputBase<SchemaConfig extends ColumnSchemaConfig, CT =
|
|
|
1558
1691
|
* @param arg.redo - whether it's migrating down and then up for `redo` command
|
|
1559
1692
|
* @param arg.migrations - array of executed (up or down) migrations
|
|
1560
1693
|
*/
|
|
1561
|
-
afterChange?: ChangeCallback
|
|
1694
|
+
afterChange?: ChangeCallback;
|
|
1562
1695
|
/**
|
|
1563
1696
|
* Is called once per db after migrating or rolling back a set of migrations.
|
|
1564
1697
|
* Runs **after** committing migrations transaction.
|
|
@@ -1624,8 +1757,8 @@ interface RakeDbConfig<ColumnTypes = unknown> extends QueryLogOptions {
|
|
|
1624
1757
|
migrationsTable: string;
|
|
1625
1758
|
recurrentPath?: string;
|
|
1626
1759
|
columnTypes: ColumnTypes;
|
|
1627
|
-
beforeChange?: ChangeCallback
|
|
1628
|
-
afterChange?: ChangeCallback
|
|
1760
|
+
beforeChange?: ChangeCallback;
|
|
1761
|
+
afterChange?: ChangeCallback;
|
|
1629
1762
|
beforeMigrate?: MigrationCallback;
|
|
1630
1763
|
afterMigrate?: MigrationCallback;
|
|
1631
1764
|
beforeRollback?: MigrationCallback;
|
|
@@ -1648,18 +1781,18 @@ interface RakeDbConfig<ColumnTypes = unknown> extends QueryLogOptions {
|
|
|
1648
1781
|
baseTable?: RakeDbBaseTable<unknown>;
|
|
1649
1782
|
commands: RakeDbCommands;
|
|
1650
1783
|
}
|
|
1651
|
-
declare const
|
|
1784
|
+
declare const rakeDbConfigDefaults: {
|
|
1652
1785
|
schemaConfig: DefaultSchemaConfig;
|
|
1653
|
-
migrationsPath: string;
|
|
1654
|
-
migrationId: {
|
|
1655
|
-
serial: number;
|
|
1656
|
-
};
|
|
1657
|
-
migrationsTable: string;
|
|
1658
1786
|
snakeCase: boolean;
|
|
1659
1787
|
commands: {};
|
|
1660
1788
|
log: boolean;
|
|
1661
1789
|
logger: Console;
|
|
1662
1790
|
import(): never;
|
|
1791
|
+
migrationId: {
|
|
1792
|
+
serial: number;
|
|
1793
|
+
};
|
|
1794
|
+
migrationsTable: string;
|
|
1795
|
+
transaction: string;
|
|
1663
1796
|
};
|
|
1664
1797
|
interface RakeDbCommandFn {
|
|
1665
1798
|
(adapters: AdapterBase[], config: RakeDbConfig, args: string[]): MaybePromise<unknown>;
|
|
@@ -1673,7 +1806,7 @@ interface RakeDbCommand {
|
|
|
1673
1806
|
interface RakeDbCommands {
|
|
1674
1807
|
[K: string]: RakeDbCommand;
|
|
1675
1808
|
}
|
|
1676
|
-
interface ChangeCallback
|
|
1809
|
+
interface ChangeCallback {
|
|
1677
1810
|
(arg: {
|
|
1678
1811
|
db: DbResult<unknown>;
|
|
1679
1812
|
up: boolean;
|
|
@@ -1721,34 +1854,20 @@ interface RakeDbRenameMigrationsInput {
|
|
|
1721
1854
|
to: RakeDbMigrationId;
|
|
1722
1855
|
map: RakeDbRenameMigrationsMap;
|
|
1723
1856
|
}
|
|
1724
|
-
declare const incrementIntermediateCaller: () => void;
|
|
1725
|
-
declare const makeRakeDbConfig: <ColumnTypes>(config: RakeDbCliConfigInput<ColumnSchemaConfig, ColumnTypes>, args?: string[]) => RakeDbConfig<ColumnTypes>;
|
|
1726
|
-
|
|
1727
|
-
/**
|
|
1728
|
-
* Function to use in migrations to wrap database changes
|
|
1729
|
-
* Saves the given callback to an internal queue,
|
|
1730
|
-
* and also returns the callback in case you want to export it from migration.
|
|
1731
|
-
*/
|
|
1732
|
-
interface RakeDbChangeFn<CT> {
|
|
1733
|
-
(fn: ChangeCallback<CT>): MigrationChange;
|
|
1734
|
-
}
|
|
1735
|
-
interface MigrationChange {
|
|
1736
|
-
fn: ChangeCallback<unknown>;
|
|
1737
|
-
config: RakeDbConfig;
|
|
1738
|
-
}
|
|
1739
|
-
type ChangeCallback<CT> = (db: DbMigration<CT>, up: boolean) => Promise<void>;
|
|
1740
1857
|
|
|
1741
1858
|
interface RakeDbCliResult<ColumnTypes, Options> {
|
|
1742
|
-
change:
|
|
1859
|
+
change: MigrationChangeFn<ColumnTypes>;
|
|
1743
1860
|
run(options: Options, args?: string[]): Promise<void>;
|
|
1744
1861
|
}
|
|
1745
1862
|
interface RakeDbFn<Options> {
|
|
1746
1863
|
<SchemaConfig extends ColumnSchemaConfig, ColumnTypes = DefaultColumnTypes<DefaultSchemaConfig>>(config: RakeDbCliConfigInput<SchemaConfig, ColumnTypes> | RakeDbConfig<ColumnTypes>, args?: string[]): RakeDbCliResult<ColumnTypes, Options>;
|
|
1747
|
-
run<SchemaConfig extends ColumnSchemaConfig, ColumnTypes = DefaultColumnTypes<DefaultSchemaConfig>>(options: Options, config: RakeDbCliConfigInput<SchemaConfig, ColumnTypes> | RakeDbConfig<ColumnTypes>, args?: string[]):
|
|
1864
|
+
run<SchemaConfig extends ColumnSchemaConfig, ColumnTypes = DefaultColumnTypes<DefaultSchemaConfig>>(options: Options, config: RakeDbCliConfigInput<SchemaConfig, ColumnTypes> | RakeDbConfig<ColumnTypes>, args?: string[]): MigrationChangeFn<ColumnTypes>;
|
|
1748
1865
|
}
|
|
1749
1866
|
declare const rakeDbCliWithAdapter: RakeDbFn<MaybeArray<AdapterBase>>;
|
|
1750
1867
|
declare const setRakeDbCliRunFn: <T>(rakeDbCli: RakeDbFn<T>) => void;
|
|
1868
|
+
|
|
1751
1869
|
declare const rakeDbCommands: RakeDbCommands;
|
|
1870
|
+
declare const incrementIntermediateCaller: () => void;
|
|
1752
1871
|
|
|
1753
1872
|
declare const encodeColumnDefault: (def: unknown, values: unknown[], column?: Column.Pick.Data) => string | null;
|
|
1754
1873
|
declare const getConstraintName: (table: string, constraint: {
|
|
@@ -1781,51 +1900,6 @@ declare const promptSelect: ({ message, options, active, inactive, }: {
|
|
|
1781
1900
|
inactive?: (s: string) => string;
|
|
1782
1901
|
}) => Promise<number>;
|
|
1783
1902
|
|
|
1784
|
-
interface OrmParam {
|
|
1785
|
-
$getAdapter(): AdapterBase;
|
|
1786
|
-
}
|
|
1787
|
-
type DbParam = OrmParam | AdapterBase;
|
|
1788
|
-
|
|
1789
|
-
declare const saveMigratedVersion: (db: SilentQueries, version: string, name: string, config: Pick<RakeDbConfig, 'migrationsTable'>) => Promise<void>;
|
|
1790
|
-
declare const createMigrationsSchemaAndTable: (db: DbParam, config: {
|
|
1791
|
-
migrationsTable: string;
|
|
1792
|
-
logger?: QueryLogger;
|
|
1793
|
-
}) => Promise<void>;
|
|
1794
|
-
|
|
1795
|
-
interface MigrateFnParams {
|
|
1796
|
-
ctx?: RakeDbCtx;
|
|
1797
|
-
count?: number;
|
|
1798
|
-
force?: boolean;
|
|
1799
|
-
}
|
|
1800
|
-
interface MigrateFn {
|
|
1801
|
-
(db: DbParam, config: RakeDbConfig, params?: MigrateFnParams): Promise<void>;
|
|
1802
|
-
}
|
|
1803
|
-
/**
|
|
1804
|
-
* Will run all pending yet migrations, sequentially in order,
|
|
1805
|
-
* will apply `change` functions top-to-bottom.
|
|
1806
|
-
*
|
|
1807
|
-
* @param options - options to construct db adapter with
|
|
1808
|
-
* @param config - specifies how to load migrations, callbacks, and logger
|
|
1809
|
-
* @param args - pass none or `all` to run all migrations, pass int for how many to migrate
|
|
1810
|
-
*/
|
|
1811
|
-
declare const migrate: MigrateFn;
|
|
1812
|
-
declare const migrateAndClose: MigrateFn;
|
|
1813
|
-
declare function runMigration(db: DbParam, migration: () => MaybePromise<unknown>): Promise<void>;
|
|
1814
|
-
declare function runMigration(db: DbParam, config: Pick<RakeDbConfig, 'transactionSearchPath'>, migration: () => MaybePromise<unknown>): Promise<void>;
|
|
1815
|
-
/**
|
|
1816
|
-
* Will roll back one latest applied migration,
|
|
1817
|
-
* will apply `change` functions bottom-to-top.
|
|
1818
|
-
*
|
|
1819
|
-
* Takes the same options as {@link migrate}.
|
|
1820
|
-
*/
|
|
1821
|
-
declare const rollback: MigrateFn;
|
|
1822
|
-
/**
|
|
1823
|
-
* Calls {@link rollback} and then {@link migrate}.
|
|
1824
|
-
*
|
|
1825
|
-
* Takes the same options as {@link migrate}.
|
|
1826
|
-
*/
|
|
1827
|
-
declare const redo: MigrateFn;
|
|
1828
|
-
|
|
1829
1903
|
declare const astToMigration: (currentSchema: string, config: RakeDbConfig, asts: RakeDbAst[]) => string | undefined;
|
|
1830
1904
|
|
|
1831
1905
|
interface StructureToAstCtx {
|
|
@@ -1845,7 +1919,7 @@ interface StructureToAstTableData {
|
|
|
1845
1919
|
declare const makeStructureToAstCtx: (config: Pick<RakeDbConfig, 'snakeCase' | 'schemaConfig'>, currentSchema: string) => StructureToAstCtx;
|
|
1846
1920
|
declare const structureToAst: (ctx: StructureToAstCtx, adapter: AdapterBase, config: Pick<RakeDbConfig, 'migrationsTable'>) => Promise<RakeDbAst[]>;
|
|
1847
1921
|
declare const makeDomainsMap: (ctx: StructureToAstCtx, data: IntrospectedStructure) => DbStructureDomainsMap;
|
|
1848
|
-
declare const instantiateDbColumn: (ctx: StructureToAstCtx, data: IntrospectedStructure, domains: DbStructureDomainsMap, dbColumn: DbStructure.Column) => Column<
|
|
1922
|
+
declare const instantiateDbColumn: (ctx: StructureToAstCtx, data: IntrospectedStructure, domains: DbStructureDomainsMap, dbColumn: DbStructure.Column) => Column<pqb_internal.ColumnTypeSchemaArg, unknown, any, any, unknown, unknown, any, unknown, any>;
|
|
1849
1923
|
declare const tableToAst: (ctx: StructureToAstCtx, data: IntrospectedStructure, table: DbStructure.Table, action: 'create' | 'drop', domains: DbStructureDomainsMap) => RakeDbAst.Table;
|
|
1850
1924
|
declare const getDbStructureTableData: (data: IntrospectedStructure, { name, schemaName }: DbStructure.Table) => StructureToAstTableData;
|
|
1851
1925
|
interface ColumnChecks {
|
|
@@ -1953,4 +2027,4 @@ declare const dropTable: (db: DbParam, sql: string) => Promise<'done' | 'already
|
|
|
1953
2027
|
declare class RakeDbError extends Error {
|
|
1954
2028
|
}
|
|
1955
2029
|
|
|
1956
|
-
export { type ChangeCallback, type DbMigration, DbStructure, type IntrospectedStructure, RakeDbAst, type
|
|
2030
|
+
export { type ChangeCallback$1 as ChangeCallback, type DbMigration, DbStructure, type IntrospectedStructure, type MigrateConfig, type MigrateFn, type MigrationChangeFn, RakeDbAst, type RakeDbChangeFnConfig, type RakeDbCliConfigInput, type RakeDbConfig, RakeDbError, type RakeDbFn, type SilentQueries, type StructureToAstCtx, type StructureToAstTableData, astToMigration, concatSchemaAndName, createDatabase, createMigrationChangeFn, createMigrationInterface, createMigrationsSchemaAndTable, createSchema, createTable, dbColumnToAst, dropDatabase, dropSchema, dropTable, encodeColumnDefault, getConstraintName, getDbStructureTableData, getDbTableColumnsChecks, getDbVersion, getExcludeName, getIndexName, getMigrationsSchemaAndTable, getSchemaAndTableFromName, incrementIntermediateCaller, instantiateDbColumn, introspectDbSchema, makeDomainsMap, makeFileVersion, makeStructureToAstCtx, migrate, migrateAndClose, promptSelect, rakeDbCliWithAdapter, rakeDbCommands, rakeDbConfigDefaults, redo, rollback, runMigration, saveMigratedVersion, setRakeDbCliRunFn, structureToAst, tableToAst, writeMigrationFile };
|