rake-db 2.29.7 → 2.29.9
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 +9 -4
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as pqb from 'pqb';
|
|
2
|
-
import { TableData, ColumnsShape, NoPrimaryKeyOption, MaybeArray, Column, RawSqlBase, RecordString, EnumColumn, EmptyObject, AdapterBase, DbResult, DefaultColumnTypes, DefaultSchemaConfig, QueryLogObject, TableDataFn, TableDataItem, DbDomainArg, ColumnSchemaConfig, raw, Db, MaybePromise, QueryLogOptions, QuerySchema, SearchWeight, ColumnsByType, DbStructureDomainsMap } from 'pqb';
|
|
2
|
+
import { TableData, ColumnsShape, NoPrimaryKeyOption, MaybeArray, Column, RawSqlBase, RecordString, EnumColumn, EmptyObject, AdapterBase, DbResult, DefaultColumnTypes, DefaultSchemaConfig, QueryLogObject, TableDataFn, TableDataItem, DbDomainArg, ColumnSchemaConfig, raw, Db, MaybePromise, QueryLogOptions, QuerySchema, QueryLogger, SearchWeight, ColumnsByType, DbStructureDomainsMap } from 'pqb';
|
|
3
3
|
|
|
4
4
|
type RakeDbAst = RakeDbAst.Table | RakeDbAst.ChangeTable | RakeDbAst.RenameType | RakeDbAst.Schema | RakeDbAst.RenameSchema | RakeDbAst.Extension | RakeDbAst.Enum | RakeDbAst.EnumValues | RakeDbAst.RenameEnumValues | RakeDbAst.ChangeEnumValues | RakeDbAst.Domain | RakeDbAst.Collation | RakeDbAst.Constraint | RakeDbAst.RenameTableItem | RakeDbAst.View;
|
|
5
5
|
declare namespace RakeDbAst {
|
|
@@ -1511,13 +1511,18 @@ declare const promptSelect: ({ message, options, active, inactive, }: {
|
|
|
1511
1511
|
inactive?: (s: string) => string;
|
|
1512
1512
|
}) => Promise<number>;
|
|
1513
1513
|
|
|
1514
|
-
declare const saveMigratedVersion: (db: SilentQueries, version: string, name: string, config: Pick<RakeDbConfig, 'migrationsTable'>) => Promise<void>;
|
|
1515
|
-
|
|
1516
1514
|
interface OrmParam {
|
|
1517
1515
|
$getAdapter(): AdapterBase;
|
|
1518
1516
|
}
|
|
1519
1517
|
type DbParam = OrmParam | AdapterBase;
|
|
1520
1518
|
|
|
1519
|
+
declare const saveMigratedVersion: (db: SilentQueries, version: string, name: string, config: Pick<RakeDbConfig, 'migrationsTable'>) => Promise<void>;
|
|
1520
|
+
declare const createMigrationsSchemaAndTable: (db: DbParam, config: {
|
|
1521
|
+
schema?: QuerySchema;
|
|
1522
|
+
migrationsTable: string;
|
|
1523
|
+
logger?: QueryLogger;
|
|
1524
|
+
}) => Promise<void>;
|
|
1525
|
+
|
|
1521
1526
|
interface MigrateFnParams {
|
|
1522
1527
|
ctx?: RakeDbCtx;
|
|
1523
1528
|
count?: number;
|
|
@@ -1841,4 +1846,4 @@ declare const dropTable: (db: DbParam, sql: string) => Promise<'done' | 'already
|
|
|
1841
1846
|
declare class RakeDbError extends Error {
|
|
1842
1847
|
}
|
|
1843
1848
|
|
|
1844
|
-
export { type ChangeCallback, type DbMigration, DbStructure, type IntrospectedStructure, RakeDbAst, type RakeDbChangeFn, type RakeDbCliConfigInput, type RakeDbConfig, RakeDbError, type RakeDbFn, type SilentQueries, type StructureToAstCtx, type StructureToAstTableData, astToMigration, concatSchemaAndName, createDatabase, createMigrationInterface, createSchema, createTable, dbColumnToAst, dropDatabase, dropSchema, dropTable, encodeColumnDefault, getConstraintName, getDbStructureTableData, getDbTableColumnsChecks, getExcludeName, getIndexName, getMigrationsSchemaAndTable, getSchemaAndTableFromName, incrementIntermediateCaller, instantiateDbColumn, introspectDbSchema, makeDomainsMap, makeFileVersion, makeRakeDbConfig, makeStructureToAstCtx, migrate, migrateAndClose, migrationConfigDefaults, promptSelect, rakeDbCliWithAdapter, rakeDbCommands, redo, rollback, runMigration, saveMigratedVersion, setRakeDbCliRunFn, structureToAst, tableToAst, writeMigrationFile };
|
|
1849
|
+
export { type ChangeCallback, type DbMigration, DbStructure, type IntrospectedStructure, RakeDbAst, type RakeDbChangeFn, type RakeDbCliConfigInput, type RakeDbConfig, RakeDbError, type RakeDbFn, type SilentQueries, type StructureToAstCtx, type StructureToAstTableData, astToMigration, concatSchemaAndName, createDatabase, createMigrationInterface, createMigrationsSchemaAndTable, createSchema, createTable, dbColumnToAst, dropDatabase, dropSchema, dropTable, encodeColumnDefault, getConstraintName, getDbStructureTableData, getDbTableColumnsChecks, getExcludeName, getIndexName, getMigrationsSchemaAndTable, getSchemaAndTableFromName, incrementIntermediateCaller, instantiateDbColumn, introspectDbSchema, makeDomainsMap, makeFileVersion, makeRakeDbConfig, makeStructureToAstCtx, migrate, migrateAndClose, migrationConfigDefaults, promptSelect, rakeDbCliWithAdapter, rakeDbCommands, redo, rollback, runMigration, saveMigratedVersion, setRakeDbCliRunFn, structureToAst, tableToAst, writeMigrationFile };
|
package/dist/index.js
CHANGED
|
@@ -408,7 +408,7 @@ const columnToSql = (config, name, item, values, hasMultiplePrimaryKeys, snakeCa
|
|
|
408
408
|
const encodeColumnDefault = (def, values, column) => {
|
|
409
409
|
if (def !== void 0 && def !== null && typeof def !== "function") {
|
|
410
410
|
if (pqb.isRawSQL(def)) {
|
|
411
|
-
return def.toSQL({ values })
|
|
411
|
+
return `(${def.toSQL({ values })})`;
|
|
412
412
|
} else {
|
|
413
413
|
return pqb.escapeForMigration(
|
|
414
414
|
column instanceof pqb.ArrayColumn && Array.isArray(def) ? "{" + (column.data.item.data.encode ? def.map((x) => column.data.item.data.encode(x)) : def).join(",") + "}" : column?.data.encode ? column.data.encode(def) : def
|
|
@@ -3245,16 +3245,16 @@ const saveMigratedVersion = async (db, version, name, config) => {
|
|
|
3245
3245
|
[version, name]
|
|
3246
3246
|
);
|
|
3247
3247
|
};
|
|
3248
|
-
const createMigrationsSchemaAndTable = async (
|
|
3248
|
+
const createMigrationsSchemaAndTable = async (db, config) => {
|
|
3249
3249
|
const { schema, table } = getMigrationsSchemaAndTable(config);
|
|
3250
3250
|
if (schema) {
|
|
3251
|
-
const res2 = await createSchema$1(
|
|
3251
|
+
const res2 = await createSchema$1(db, schema);
|
|
3252
3252
|
if (res2 === "done") {
|
|
3253
3253
|
config.logger?.log(`Created schema "${schema}"`);
|
|
3254
3254
|
}
|
|
3255
3255
|
}
|
|
3256
3256
|
const res = await createTable$1(
|
|
3257
|
-
|
|
3257
|
+
db,
|
|
3258
3258
|
`${schema ? `"${schema}"."${table}"` : `"${table}"`} (version TEXT NOT NULL, name TEXT NOT NULL)`
|
|
3259
3259
|
);
|
|
3260
3260
|
if (res === "done") {
|
|
@@ -6081,6 +6081,7 @@ exports.astToMigration = astToMigration;
|
|
|
6081
6081
|
exports.concatSchemaAndName = concatSchemaAndName;
|
|
6082
6082
|
exports.createDatabase = createDatabase;
|
|
6083
6083
|
exports.createMigrationInterface = createMigrationInterface;
|
|
6084
|
+
exports.createMigrationsSchemaAndTable = createMigrationsSchemaAndTable;
|
|
6084
6085
|
exports.createSchema = createSchema$1;
|
|
6085
6086
|
exports.createTable = createTable$1;
|
|
6086
6087
|
exports.dbColumnToAst = dbColumnToAst;
|