rake-db 2.30.9 → 2.31.1
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 +172 -98
- package/dist/index.js +987 -935
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +732 -680
- 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 +24 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { SearchWeight, RecordOptionalString, DefaultPrivileges, AdapterBase, TableData, ColumnsShape, NoPrimaryKeyOption, MaybeArray, Column, RawSqlBase, RecordString,
|
|
1
|
+
import * as pqb_internal from 'pqb/internal';
|
|
2
|
+
import { SearchWeight, RecordOptionalString, DefaultPrivileges, AdapterBase, TableData, ColumnsShape, NoPrimaryKeyOption, MaybeArray, Column, RawSqlBase, RecordString, EmptyObject, EnumColumn, DbResult, QueryLogObject, ColumnSchemaConfig, raw, TableDataFn, TableDataItem, DbDomainArg, DefaultColumnTypes, DefaultSchemaConfig, Db, QuerySchema, QueryLogger, QueryLogOptions, MaybePromise, ColumnsByType, DbStructureDomainsMap } from 'pqb/internal';
|
|
3
3
|
|
|
4
4
|
declare namespace DbStructure {
|
|
5
5
|
interface TableNameAndSchemaName {
|
|
@@ -429,7 +429,7 @@ declare namespace RakeDbAst {
|
|
|
429
429
|
grant?: DefaultPrivilegeObjectConfig;
|
|
430
430
|
revoke?: DefaultPrivilegeObjectConfig;
|
|
431
431
|
}
|
|
432
|
-
export {
|
|
432
|
+
export {};
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
declare function add(item: Column, options?: {
|
|
@@ -486,23 +486,23 @@ declare const tableChangeMethods: {
|
|
|
486
486
|
columns: Columns;
|
|
487
487
|
name: string extends Name ? never : Name;
|
|
488
488
|
};
|
|
489
|
-
unique<
|
|
489
|
+
unique<Columns extends [string | TableData.Index.ColumnOrExpressionOptions<string>, ...(string | TableData.Index.ColumnOrExpressionOptions<string>)[]], Name extends string>(columns: Columns, options?: TableData.Index.UniqueOptionsArg<Name> | undefined): {
|
|
490
490
|
tableDataItem: true;
|
|
491
|
-
columns:
|
|
492
|
-
name: string extends
|
|
491
|
+
columns: Columns extends (string | TableData.Index.ColumnOptionsForColumn<string>)[] ? { [I in keyof Columns]: "column" extends keyof Columns[I] ? Columns[I][keyof Columns[I] & "column"] : Columns[I]; } : never;
|
|
492
|
+
name: string extends Name ? never : Name;
|
|
493
493
|
};
|
|
494
|
-
index(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.OptionsArg
|
|
495
|
-
searchIndex(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.TsVectorArg
|
|
496
|
-
exclude(columns: TableData.Exclude.ColumnOrExpressionOptions<string>[], options?: TableData.Exclude.Options
|
|
494
|
+
index(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.OptionsArg): pqb_internal.NonUniqDataItem;
|
|
495
|
+
searchIndex(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.TsVectorArg): pqb_internal.NonUniqDataItem;
|
|
496
|
+
exclude(columns: TableData.Exclude.ColumnOrExpressionOptions<string>[], options?: TableData.Exclude.Options): pqb_internal.NonUniqDataItem;
|
|
497
497
|
foreignKey<Shape>(columns: [string, ...string[]], fnOrTable: () => new () => {
|
|
498
498
|
columns: {
|
|
499
499
|
shape: Shape;
|
|
500
500
|
};
|
|
501
|
-
}, foreignColumns: [keyof Shape, ...(keyof Shape)[]], options?: TableData.References.Options
|
|
502
|
-
foreignKey(columns: [string, ...string[]], fnOrTable: string, foreignColumns: [string, ...string[]], options?: TableData.References.Options
|
|
503
|
-
check(check: RawSqlBase, name?: string
|
|
504
|
-
sql:
|
|
505
|
-
enum(name: string): EnumColumn<
|
|
501
|
+
}, foreignColumns: [keyof Shape, ...(keyof Shape)[]], options?: TableData.References.Options): pqb_internal.NonUniqDataItem;
|
|
502
|
+
foreignKey(columns: [string, ...string[]], fnOrTable: string, foreignColumns: [string, ...string[]], options?: TableData.References.Options): pqb_internal.NonUniqDataItem;
|
|
503
|
+
check(check: RawSqlBase, name?: string): pqb_internal.NonUniqDataItem;
|
|
504
|
+
sql: pqb_internal.SqlFn;
|
|
505
|
+
enum(name: string): EnumColumn<pqb_internal.DefaultSchemaConfig, undefined, [string, ...string[]]>;
|
|
506
506
|
};
|
|
507
507
|
type TableChanger<CT> = MigrationColumnTypes<CT> & TableChangeMethods;
|
|
508
508
|
type TableChangeData = Record<string, RakeDbAst.ChangeTableItem.Column | RakeDbAst.ChangeTableItem.Rename | Change | SpecialChange | Column.Pick.Data>;
|
|
@@ -558,15 +558,22 @@ interface SilentQueries extends AdapterBase {
|
|
|
558
558
|
type DbMigration<CT> = DbResult<CT> & Migration<CT> & {
|
|
559
559
|
adapter: SilentQueries;
|
|
560
560
|
};
|
|
561
|
+
interface MigrationInterfaceResult {
|
|
562
|
+
adapter: SilentQueries;
|
|
563
|
+
getDb(columnTypes: unknown): DbMigration<DefaultColumnTypes<DefaultSchemaConfig>>;
|
|
564
|
+
}
|
|
561
565
|
/**
|
|
562
566
|
* Creates a new `db` instance that is an instance of `pqb` with mixed in migration methods from the `Migration` class.
|
|
563
567
|
* It overrides `query` and `array` db adapter methods to intercept SQL for the logging.
|
|
564
568
|
*
|
|
569
|
+
* A concrete `db` instance depends on column types, column types may vary between `change` calls,
|
|
570
|
+
* therefore it returns a function that accepts column types, caches db instance per given column types, and return the result.
|
|
571
|
+
*
|
|
565
572
|
* @param tx - database adapter that executes inside a transaction
|
|
566
573
|
* @param up - migrate or rollback
|
|
567
574
|
* @param config - config of `rakeDb`
|
|
568
575
|
*/
|
|
569
|
-
declare const createMigrationInterface: (tx: AdapterBase, up: boolean, config: Pick<RakeDbConfig,
|
|
576
|
+
declare const createMigrationInterface: (tx: AdapterBase, up: boolean, config: Pick<RakeDbConfig, "log" | "logger">) => MigrationInterfaceResult;
|
|
570
577
|
type MigrationAdapter = AdapterBase;
|
|
571
578
|
declare class Migration<CT = unknown> {
|
|
572
579
|
adapter: MigrationAdapter;
|
|
@@ -1498,6 +1505,131 @@ declare const concatSchemaAndName: ({ schema, name, }: {
|
|
|
1498
1505
|
name: string;
|
|
1499
1506
|
}, excludeCurrentSchema?: string) => string;
|
|
1500
1507
|
|
|
1508
|
+
interface RakeDbChangeFnConfig {
|
|
1509
|
+
columnTypes: unknown;
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Function to use in migrations to wrap database changes
|
|
1513
|
+
* Saves the given callback to an internal queue,
|
|
1514
|
+
* and also returns the callback in case you want to export it from migration.
|
|
1515
|
+
*/
|
|
1516
|
+
interface MigrationChangeFn<ColumnTypes> {
|
|
1517
|
+
(fn: ChangeCallback$1<ColumnTypes>): MigrationChange;
|
|
1518
|
+
}
|
|
1519
|
+
declare const createMigrationChangeFn: <ColumnTypes = DefaultColumnTypes<DefaultSchemaConfig>>(config: {
|
|
1520
|
+
columnTypes?: ColumnTypes;
|
|
1521
|
+
}) => MigrationChangeFn<ColumnTypes>;
|
|
1522
|
+
interface MigrationChange {
|
|
1523
|
+
fn: ChangeCallback$1<unknown>;
|
|
1524
|
+
config: RakeDbChangeFnConfig;
|
|
1525
|
+
}
|
|
1526
|
+
type ChangeCallback$1<ColumnTypes> = (db: DbMigration<ColumnTypes>, up: boolean) => Promise<void>;
|
|
1527
|
+
|
|
1528
|
+
interface OrmParam {
|
|
1529
|
+
$getAdapter(): AdapterBase;
|
|
1530
|
+
}
|
|
1531
|
+
type DbParam = OrmParam | AdapterBase;
|
|
1532
|
+
|
|
1533
|
+
declare const saveMigratedVersion: (db: SilentQueries, version: string, name: string, config: Pick<RakeDbConfig, "migrationsTable">) => Promise<void>;
|
|
1534
|
+
declare const createMigrationsSchemaAndTable: (db: DbParam, config: {
|
|
1535
|
+
migrationsTable: string;
|
|
1536
|
+
logger?: QueryLogger;
|
|
1537
|
+
}) => Promise<void>;
|
|
1538
|
+
|
|
1539
|
+
interface MigrateFnParams {
|
|
1540
|
+
ctx?: RakeDbCtx;
|
|
1541
|
+
count?: number;
|
|
1542
|
+
force?: boolean;
|
|
1543
|
+
}
|
|
1544
|
+
interface MigrateConfigBase extends QueryLogOptions {
|
|
1545
|
+
migrationId?: RakeDbMigrationId;
|
|
1546
|
+
renameMigrations?: RakeDbRenameMigrationsInput;
|
|
1547
|
+
migrationsTable?: string;
|
|
1548
|
+
transaction?: 'single' | 'per-migration';
|
|
1549
|
+
transactionSearchPath?: SearchPath;
|
|
1550
|
+
forceDefaultExports?: boolean;
|
|
1551
|
+
beforeChange?: ChangeCallback;
|
|
1552
|
+
afterChange?: ChangeCallback;
|
|
1553
|
+
afterChangeCommit?: ChangeCommitCallback;
|
|
1554
|
+
beforeMigrate?: MigrationCallback;
|
|
1555
|
+
afterMigrate?: MigrationCallback;
|
|
1556
|
+
beforeRollback?: MigrationCallback;
|
|
1557
|
+
afterRollback?: MigrationCallback;
|
|
1558
|
+
}
|
|
1559
|
+
interface MigrateConfigFileBased extends MigrateConfigBase {
|
|
1560
|
+
basePath?: string;
|
|
1561
|
+
migrationsPath: string;
|
|
1562
|
+
import(path: string): Promise<unknown>;
|
|
1563
|
+
}
|
|
1564
|
+
interface MigrateConfigMigrationsProvided extends MigrateConfigBase {
|
|
1565
|
+
migrations: ModuleExportsRecord;
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Minimal configuration required by public migration functions
|
|
1569
|
+
* (`migrate`, `rollback`, `redo`) and the functions they invoke.
|
|
1570
|
+
*
|
|
1571
|
+
* Pass `log: true` to enable logging to console,
|
|
1572
|
+
* `log: false` to disable it, or leave `log` undefined to preserve the existing `logger`.
|
|
1573
|
+
*
|
|
1574
|
+
* All properties of {@link RakeDbConfig} that are unrelated to running migrations
|
|
1575
|
+
* (e.g. `commands`, `recurrentPath`, `schemaConfig`) are intentionally excluded.
|
|
1576
|
+
*/
|
|
1577
|
+
type MigrateConfig = MigrateConfigFileBased | MigrateConfigMigrationsProvided;
|
|
1578
|
+
interface MigrateFn {
|
|
1579
|
+
(db: DbParam, config: MigrateConfig, params?: MigrateFnParams): Promise<void>;
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Will run all pending yet migrations, sequentially in order,
|
|
1583
|
+
* will apply `change` functions top-to-bottom.
|
|
1584
|
+
*
|
|
1585
|
+
* Supports `log?: boolean` option in config for programmatic use:
|
|
1586
|
+
* - `log: true` - enables logging to console
|
|
1587
|
+
* - `log: false` - disables logging
|
|
1588
|
+
* - `log: undefined` - preserves existing logger (for custom loggers)
|
|
1589
|
+
*
|
|
1590
|
+
* @param db - database adapter or transaction
|
|
1591
|
+
* @param config - specifies how to load migrations, callbacks, and logger
|
|
1592
|
+
* @param params - optional migration parameters (ctx, count, force)
|
|
1593
|
+
*/
|
|
1594
|
+
declare const migrate: MigrateFn;
|
|
1595
|
+
declare const migrateAndClose: MigrateFn;
|
|
1596
|
+
interface RunMigrationConfig extends QueryLogOptions {
|
|
1597
|
+
transactionSearchPath?: SearchPath;
|
|
1598
|
+
}
|
|
1599
|
+
declare function runMigration(db: DbParam, migration: () => MaybePromise<unknown>): Promise<void>;
|
|
1600
|
+
declare function runMigration(db: DbParam, config: RunMigrationConfig, migration: () => MaybePromise<unknown>): Promise<void>;
|
|
1601
|
+
/**
|
|
1602
|
+
* Will roll back one latest applied migration,
|
|
1603
|
+
* will apply `change` functions bottom-to-top.
|
|
1604
|
+
*
|
|
1605
|
+
* Supports `log?: boolean` option in config for programmatic use:
|
|
1606
|
+
* - `log: true` - enables logging to console
|
|
1607
|
+
* - `log: false` - disables logging
|
|
1608
|
+
* - `log: undefined` - preserves existing logger (for custom loggers)
|
|
1609
|
+
*
|
|
1610
|
+
* Takes the same options as {@link migrate}.
|
|
1611
|
+
*
|
|
1612
|
+
* @param db - database adapter or transaction
|
|
1613
|
+
* @param config - specifies how to load migrations, callbacks, and logger
|
|
1614
|
+
* @param params - optional rollback parameters (ctx, count, force)
|
|
1615
|
+
*/
|
|
1616
|
+
declare const rollback: MigrateFn;
|
|
1617
|
+
/**
|
|
1618
|
+
* Calls {@link rollback} and then {@link migrate}.
|
|
1619
|
+
*
|
|
1620
|
+
* Supports `log?: boolean` option in config for programmatic use:
|
|
1621
|
+
* - `log: true` - enables logging to console
|
|
1622
|
+
* - `log: false` - disables logging
|
|
1623
|
+
* - `log: undefined` - preserves existing logger (for custom loggers)
|
|
1624
|
+
*
|
|
1625
|
+
* Takes the same options as {@link migrate}.
|
|
1626
|
+
*
|
|
1627
|
+
* @param db - database adapter or transaction
|
|
1628
|
+
* @param config - specifies how to load migrations, callbacks, and logger
|
|
1629
|
+
* @param params - optional redo parameters (ctx, count, force)
|
|
1630
|
+
*/
|
|
1631
|
+
declare const redo: MigrateFn;
|
|
1632
|
+
|
|
1501
1633
|
interface MigrationItemHasLoad {
|
|
1502
1634
|
path?: string;
|
|
1503
1635
|
/**
|
|
@@ -1547,7 +1679,7 @@ interface RakeDbCliConfigInputBase<SchemaConfig extends ColumnSchemaConfig, CT =
|
|
|
1547
1679
|
* @param arg.redo - whether it's migrating down and then up for `redo` command
|
|
1548
1680
|
* @param arg.migrations - array of executed (up or down) migrations
|
|
1549
1681
|
*/
|
|
1550
|
-
beforeChange?: ChangeCallback
|
|
1682
|
+
beforeChange?: ChangeCallback;
|
|
1551
1683
|
/**
|
|
1552
1684
|
* Is called once per db after migrating or rolling back a set of migrations.
|
|
1553
1685
|
* Runs inside the same transaction as migrations,
|
|
@@ -1558,7 +1690,7 @@ interface RakeDbCliConfigInputBase<SchemaConfig extends ColumnSchemaConfig, CT =
|
|
|
1558
1690
|
* @param arg.redo - whether it's migrating down and then up for `redo` command
|
|
1559
1691
|
* @param arg.migrations - array of executed (up or down) migrations
|
|
1560
1692
|
*/
|
|
1561
|
-
afterChange?: ChangeCallback
|
|
1693
|
+
afterChange?: ChangeCallback;
|
|
1562
1694
|
/**
|
|
1563
1695
|
* Is called once per db after migrating or rolling back a set of migrations.
|
|
1564
1696
|
* Runs **after** committing migrations transaction.
|
|
@@ -1624,8 +1756,8 @@ interface RakeDbConfig<ColumnTypes = unknown> extends QueryLogOptions {
|
|
|
1624
1756
|
migrationsTable: string;
|
|
1625
1757
|
recurrentPath?: string;
|
|
1626
1758
|
columnTypes: ColumnTypes;
|
|
1627
|
-
beforeChange?: ChangeCallback
|
|
1628
|
-
afterChange?: ChangeCallback
|
|
1759
|
+
beforeChange?: ChangeCallback;
|
|
1760
|
+
afterChange?: ChangeCallback;
|
|
1629
1761
|
beforeMigrate?: MigrationCallback;
|
|
1630
1762
|
afterMigrate?: MigrationCallback;
|
|
1631
1763
|
beforeRollback?: MigrationCallback;
|
|
@@ -1648,18 +1780,18 @@ interface RakeDbConfig<ColumnTypes = unknown> extends QueryLogOptions {
|
|
|
1648
1780
|
baseTable?: RakeDbBaseTable<unknown>;
|
|
1649
1781
|
commands: RakeDbCommands;
|
|
1650
1782
|
}
|
|
1651
|
-
declare const
|
|
1783
|
+
declare const rakeDbConfigDefaults: {
|
|
1652
1784
|
schemaConfig: DefaultSchemaConfig;
|
|
1653
|
-
migrationsPath: string;
|
|
1654
|
-
migrationId: {
|
|
1655
|
-
serial: number;
|
|
1656
|
-
};
|
|
1657
|
-
migrationsTable: string;
|
|
1658
1785
|
snakeCase: boolean;
|
|
1659
1786
|
commands: {};
|
|
1660
1787
|
log: boolean;
|
|
1661
1788
|
logger: Console;
|
|
1662
1789
|
import(): never;
|
|
1790
|
+
migrationId: {
|
|
1791
|
+
serial: number;
|
|
1792
|
+
};
|
|
1793
|
+
migrationsTable: string;
|
|
1794
|
+
transaction: string;
|
|
1663
1795
|
};
|
|
1664
1796
|
interface RakeDbCommandFn {
|
|
1665
1797
|
(adapters: AdapterBase[], config: RakeDbConfig, args: string[]): MaybePromise<unknown>;
|
|
@@ -1673,7 +1805,7 @@ interface RakeDbCommand {
|
|
|
1673
1805
|
interface RakeDbCommands {
|
|
1674
1806
|
[K: string]: RakeDbCommand;
|
|
1675
1807
|
}
|
|
1676
|
-
interface ChangeCallback
|
|
1808
|
+
interface ChangeCallback {
|
|
1677
1809
|
(arg: {
|
|
1678
1810
|
db: DbResult<unknown>;
|
|
1679
1811
|
up: boolean;
|
|
@@ -1721,34 +1853,20 @@ interface RakeDbRenameMigrationsInput {
|
|
|
1721
1853
|
to: RakeDbMigrationId;
|
|
1722
1854
|
map: RakeDbRenameMigrationsMap;
|
|
1723
1855
|
}
|
|
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
1856
|
|
|
1741
1857
|
interface RakeDbCliResult<ColumnTypes, Options> {
|
|
1742
|
-
change:
|
|
1858
|
+
change: MigrationChangeFn<ColumnTypes>;
|
|
1743
1859
|
run(options: Options, args?: string[]): Promise<void>;
|
|
1744
1860
|
}
|
|
1745
1861
|
interface RakeDbFn<Options> {
|
|
1746
1862
|
<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[]):
|
|
1863
|
+
run<SchemaConfig extends ColumnSchemaConfig, ColumnTypes = DefaultColumnTypes<DefaultSchemaConfig>>(options: Options, config: RakeDbCliConfigInput<SchemaConfig, ColumnTypes> | RakeDbConfig<ColumnTypes>, args?: string[]): MigrationChangeFn<ColumnTypes>;
|
|
1748
1864
|
}
|
|
1749
1865
|
declare const rakeDbCliWithAdapter: RakeDbFn<MaybeArray<AdapterBase>>;
|
|
1750
1866
|
declare const setRakeDbCliRunFn: <T>(rakeDbCli: RakeDbFn<T>) => void;
|
|
1867
|
+
|
|
1751
1868
|
declare const rakeDbCommands: RakeDbCommands;
|
|
1869
|
+
declare const incrementIntermediateCaller: () => void;
|
|
1752
1870
|
|
|
1753
1871
|
declare const encodeColumnDefault: (def: unknown, values: unknown[], column?: Column.Pick.Data) => string | null;
|
|
1754
1872
|
declare const getConstraintName: (table: string, constraint: {
|
|
@@ -1781,51 +1899,6 @@ declare const promptSelect: ({ message, options, active, inactive, }: {
|
|
|
1781
1899
|
inactive?: (s: string) => string;
|
|
1782
1900
|
}) => Promise<number>;
|
|
1783
1901
|
|
|
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
1902
|
declare const astToMigration: (currentSchema: string, config: RakeDbConfig, asts: RakeDbAst[]) => string | undefined;
|
|
1830
1903
|
|
|
1831
1904
|
interface StructureToAstCtx {
|
|
@@ -1842,11 +1915,11 @@ interface StructureToAstTableData {
|
|
|
1842
1915
|
constraints: DbStructure.Constraint[];
|
|
1843
1916
|
roles?: DbStructure.Role[];
|
|
1844
1917
|
}
|
|
1845
|
-
declare const makeStructureToAstCtx: (config: Pick<RakeDbConfig,
|
|
1846
|
-
declare const structureToAst: (ctx: StructureToAstCtx, adapter: AdapterBase, config: Pick<RakeDbConfig,
|
|
1918
|
+
declare const makeStructureToAstCtx: (config: Pick<RakeDbConfig, "snakeCase" | "schemaConfig">, currentSchema: string) => StructureToAstCtx;
|
|
1919
|
+
declare const structureToAst: (ctx: StructureToAstCtx, adapter: AdapterBase, config: Pick<RakeDbConfig, "migrationsTable">) => Promise<RakeDbAst[]>;
|
|
1847
1920
|
declare const makeDomainsMap: (ctx: StructureToAstCtx, data: IntrospectedStructure) => DbStructureDomainsMap;
|
|
1848
|
-
declare const instantiateDbColumn: (ctx: StructureToAstCtx, data: IntrospectedStructure, domains: DbStructureDomainsMap, dbColumn: DbStructure.Column) => Column<
|
|
1849
|
-
declare const tableToAst: (ctx: StructureToAstCtx, data: IntrospectedStructure, table: DbStructure.Table, action:
|
|
1921
|
+
declare const instantiateDbColumn: (ctx: StructureToAstCtx, data: IntrospectedStructure, domains: DbStructureDomainsMap, dbColumn: DbStructure.Column) => Column<pqb_internal.ColumnTypeSchemaArg, unknown, any, any, unknown, unknown, any, unknown, any>;
|
|
1922
|
+
declare const tableToAst: (ctx: StructureToAstCtx, data: IntrospectedStructure, table: DbStructure.Table, action: "create" | "drop", domains: DbStructureDomainsMap) => RakeDbAst.Table;
|
|
1850
1923
|
declare const getDbStructureTableData: (data: IntrospectedStructure, { name, schemaName }: DbStructure.Table) => StructureToAstTableData;
|
|
1851
1924
|
interface ColumnChecks {
|
|
1852
1925
|
[K: string]: string[];
|
|
@@ -1912,7 +1985,7 @@ declare const dropDatabase: (db: DbParam, { database }: {
|
|
|
1912
1985
|
* const result: 'done' | 'already' = await createSchema(db, '"schema"');
|
|
1913
1986
|
* ```
|
|
1914
1987
|
*/
|
|
1915
|
-
declare const createSchema: (db: DbParam, sql: string) => Promise<
|
|
1988
|
+
declare const createSchema: (db: DbParam, sql: string) => Promise<"done" | "already">;
|
|
1916
1989
|
/**
|
|
1917
1990
|
* `dropSchema` uses a savepoint when it is called in a transaction to not break it if the schema does not exist.
|
|
1918
1991
|
*
|
|
@@ -1924,7 +1997,7 @@ declare const createSchema: (db: DbParam, sql: string) => Promise<'done' | 'alre
|
|
|
1924
1997
|
* const result: 'done' | 'already' = await dropSchema(db, '"schema"');
|
|
1925
1998
|
* ```
|
|
1926
1999
|
*/
|
|
1927
|
-
declare const dropSchema: (db: DbParam, sql: string) => Promise<
|
|
2000
|
+
declare const dropSchema: (db: DbParam, sql: string) => Promise<"done" | "already">;
|
|
1928
2001
|
/**
|
|
1929
2002
|
* `createTable` uses a savepoint when it is called in a transaction to not break it if the table already exists.
|
|
1930
2003
|
*
|
|
@@ -1936,7 +2009,7 @@ declare const dropSchema: (db: DbParam, sql: string) => Promise<'done' | 'alread
|
|
|
1936
2009
|
* const result: 'done' | 'already' = await createTable(db, '"table"');
|
|
1937
2010
|
* ```
|
|
1938
2011
|
*/
|
|
1939
|
-
declare const createTable: (db: DbParam, sql: string) => Promise<
|
|
2012
|
+
declare const createTable: (db: DbParam, sql: string) => Promise<"done" | "already">;
|
|
1940
2013
|
/**
|
|
1941
2014
|
* `dropTable` uses a savepoint when it is called in a transaction to not break it if the table does not exist.
|
|
1942
2015
|
*
|
|
@@ -1948,9 +2021,10 @@ declare const createTable: (db: DbParam, sql: string) => Promise<'done' | 'alrea
|
|
|
1948
2021
|
* const result: 'done' | 'already' = await dropTable(db, '"table"');
|
|
1949
2022
|
* ```
|
|
1950
2023
|
*/
|
|
1951
|
-
declare const dropTable: (db: DbParam, sql: string) => Promise<
|
|
2024
|
+
declare const dropTable: (db: DbParam, sql: string) => Promise<"done" | "already">;
|
|
1952
2025
|
|
|
1953
2026
|
declare class RakeDbError extends Error {
|
|
1954
2027
|
}
|
|
1955
2028
|
|
|
1956
|
-
export {
|
|
2029
|
+
export { DbStructure, RakeDbAst, RakeDbError, 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 };
|
|
2030
|
+
export type { ChangeCallback$1 as ChangeCallback, DbMigration, IntrospectedStructure, MigrateConfig, MigrateFn, MigrationChangeFn, RakeDbChangeFnConfig, RakeDbCliConfigInput, RakeDbCliResult, RakeDbConfig, RakeDbFn, SilentQueries, StructureToAstCtx, StructureToAstTableData };
|