rake-db 2.20.3 → 2.20.5
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 +23 -12
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -931,7 +931,7 @@ declare class Migration<CT> {
|
|
|
931
931
|
*
|
|
932
932
|
* change(async (db) => {
|
|
933
933
|
* await db.createDomain('domainName', (t) =>
|
|
934
|
-
* t.integer().check(
|
|
934
|
+
* t.integer().check(t.sql`value = 42`),
|
|
935
935
|
* );
|
|
936
936
|
*
|
|
937
937
|
* // use `schemaName.domainName` format to specify a schema
|
|
@@ -941,7 +941,7 @@ declare class Migration<CT> {
|
|
|
941
941
|
* .nullable()
|
|
942
942
|
* .collate('C')
|
|
943
943
|
* .default('default text')
|
|
944
|
-
* .check(
|
|
944
|
+
* .check(t.sql`length(value) > 10`),
|
|
945
945
|
* );
|
|
946
946
|
* });
|
|
947
947
|
* ```
|
|
@@ -1050,7 +1050,7 @@ declare class Migration<CT> {
|
|
|
1050
1050
|
/**
|
|
1051
1051
|
* Create and drop database views.
|
|
1052
1052
|
*
|
|
1053
|
-
* Provide SQL as a string or via `
|
|
1053
|
+
* Provide SQL as a string or via `t.sql` that can accept variables.
|
|
1054
1054
|
*
|
|
1055
1055
|
* ```ts
|
|
1056
1056
|
* import { change } from '../dbScript';
|
|
@@ -1065,11 +1065,11 @@ declare class Migration<CT> {
|
|
|
1065
1065
|
* `,
|
|
1066
1066
|
* );
|
|
1067
1067
|
*
|
|
1068
|
-
* // view can accept
|
|
1068
|
+
* // view can accept t.sql with variables in such way:
|
|
1069
1069
|
* const value = 'some value';
|
|
1070
1070
|
* await db.createView(
|
|
1071
1071
|
* 'viewWithVariables',
|
|
1072
|
-
*
|
|
1072
|
+
* t.sql`
|
|
1073
1073
|
* SELECT * FROM a WHERE key = ${value}
|
|
1074
1074
|
* `,
|
|
1075
1075
|
* );
|
|
@@ -1277,7 +1277,7 @@ interface RakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT = DefaultColu
|
|
|
1277
1277
|
beforeRollback?: MigrationCallback;
|
|
1278
1278
|
afterRollback?: MigrationCallback;
|
|
1279
1279
|
}
|
|
1280
|
-
interface
|
|
1280
|
+
interface InputRakeDbConfigBase<SchemaConfig extends ColumnSchemaConfig, CT> extends QueryLogOptions {
|
|
1281
1281
|
columnTypes?: CT | ((t: DefaultColumnTypes<DefaultSchemaConfig>) => CT);
|
|
1282
1282
|
baseTable?: RakeDbBaseTable<CT>;
|
|
1283
1283
|
schemaConfig?: SchemaConfig;
|
|
@@ -1285,7 +1285,6 @@ interface InputRakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT> extends
|
|
|
1285
1285
|
dbScript?: string;
|
|
1286
1286
|
migrationsPath?: string;
|
|
1287
1287
|
migrationId?: RakeDbMigrationId;
|
|
1288
|
-
migrations?: ModuleExportsRecord;
|
|
1289
1288
|
recurrentPath?: string;
|
|
1290
1289
|
migrationsTable?: string;
|
|
1291
1290
|
snakeCase?: boolean;
|
|
@@ -1293,10 +1292,6 @@ interface InputRakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT> extends
|
|
|
1293
1292
|
commands?: Record<string, (options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT extends undefined ? DefaultColumnTypes<DefaultSchemaConfig> : CT>, args: string[]) => void | Promise<void>>;
|
|
1294
1293
|
noPrimaryKey?: NoPrimaryKeyOption;
|
|
1295
1294
|
forceDefaultExports?: boolean;
|
|
1296
|
-
/**
|
|
1297
|
-
* It may look odd, but it's required for `tsx` and other bundlers to have such `import` config specified explicitly.
|
|
1298
|
-
*/
|
|
1299
|
-
import(path: string): Promise<unknown>;
|
|
1300
1295
|
/**
|
|
1301
1296
|
* Is called once per db before migrating or rolling back a set of migrations.
|
|
1302
1297
|
*
|
|
@@ -1355,6 +1350,21 @@ interface InputRakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT> extends
|
|
|
1355
1350
|
*/
|
|
1356
1351
|
afterRollback?: MigrationCallback;
|
|
1357
1352
|
}
|
|
1353
|
+
type InputRakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT> = InputRakeDbConfigBase<SchemaConfig, CT> & ({
|
|
1354
|
+
/**
|
|
1355
|
+
* It may look odd, but it's required for `tsx` and other bundlers to have such `import` config specified explicitly.
|
|
1356
|
+
*/
|
|
1357
|
+
import(path: string): Promise<unknown>;
|
|
1358
|
+
} | {
|
|
1359
|
+
/**
|
|
1360
|
+
* To specify array of migrations explicitly, without loading them from files.
|
|
1361
|
+
*/
|
|
1362
|
+
migrations: ModuleExportsRecord;
|
|
1363
|
+
/**
|
|
1364
|
+
* It may look odd, but it's required for `tsx` and other bundlers to have such `import` config specified explicitly.
|
|
1365
|
+
*/
|
|
1366
|
+
import?(path: string): Promise<unknown>;
|
|
1367
|
+
});
|
|
1358
1368
|
type ChangeCallback$1 = (arg: {
|
|
1359
1369
|
db: Db;
|
|
1360
1370
|
up: boolean;
|
|
@@ -1395,6 +1405,7 @@ declare const migrationConfigDefaults: {
|
|
|
1395
1405
|
commands: {};
|
|
1396
1406
|
log: true;
|
|
1397
1407
|
logger: Console;
|
|
1408
|
+
import(): never;
|
|
1398
1409
|
};
|
|
1399
1410
|
declare const processRakeDbConfig: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT>(config: InputRakeDbConfig<SchemaConfig, CT>) => RakeDbConfig<SchemaConfig, CT>;
|
|
1400
1411
|
declare const getDatabaseAndUserFromOptions: (options: AdapterOptions) => {
|
|
@@ -1766,4 +1777,4 @@ declare const promptText: ({ message, default: def, password, min, }: {
|
|
|
1766
1777
|
min?: number;
|
|
1767
1778
|
}) => Promise<string>;
|
|
1768
1779
|
|
|
1769
|
-
export { AnyRakeDbConfig, ChangeCallback, ChangeTableCallback, ChangeTableOptions, ColumnComment, ColumnsShapeCallback, CommandFn, DbMigration, DbStructure, DbStructureDomainsMap, DropMode, InputRakeDbConfig, IntrospectedStructure, Migration, MigrationAdapter, MigrationColumnTypes, ModuleExportsRecord, NoMigrationsTableError, RAKE_DB_LOCK_KEY, RakeDbAppliedVersions, RakeDbAst, RakeDbBaseTable, RakeDbChangeFn, RakeDbConfig, RakeDbCtx, RakeDbFn, RakeDbFnReturns, RakeDbLazyFn, RakeDbMigrationId, RakeDbResult, SilentQueries, StructureToAstCtx, StructureToAstTableData, TableOptions, addColumnComment, addColumnIndex, addOrDropEnumValues, astToMigration, changeCache, changeEnumValues, clearChanges, colors, columnToSql, columnTypeToSql, commentsToQuery, concatSchemaAndName, constraintToSql, createDb, createMigrationInterface, dbColumnToAst, deleteMigratedVersion, dropDb, encodeColumnDefault, exhaustive, generateTimeStamp, getColumnName, getConstraintName, getCurrentChanges, getDatabaseAndUserFromOptions, getDbStructureTableData, getDbTableColumnsChecks, getFirstWordAndRest, getForeignKeyTable, getIndexName, getMigratedVersionsMap, getSchemaAndTableFromName, getTextAfterFrom, getTextAfterTo, identityToSql, indexesToQuery, instantiateDbColumn, introspectDbSchema, joinColumns, joinWords, makeDbStructureColumnsShape, makeDomainsMap, makeFileVersion, makePopulateEnumQuery, makeStructureToAstCtx, migrate, migrateOrRollback, migrationConfigDefaults, newMigration, pluralize, primaryKeyToSql, processRakeDbConfig, promptConfirm, promptSelect, promptText, pushChange, queryLock, quoteNameFromString, quoteSchemaTable, quoteTable, quoteWithSchema, rakeDb, rakeDbAliases, rakeDbCommands, redo, referencesToSql, renameType, resetDb, rollback, saveMigratedVersion, structureToAst, tableToAst, transaction, versionToString, writeMigrationFile };
|
|
1780
|
+
export { AnyRakeDbConfig, ChangeCallback, ChangeTableCallback, ChangeTableOptions, ColumnComment, ColumnsShapeCallback, CommandFn, DbMigration, DbStructure, DbStructureDomainsMap, DropMode, InputRakeDbConfig, InputRakeDbConfigBase, IntrospectedStructure, Migration, MigrationAdapter, MigrationColumnTypes, ModuleExportsRecord, NoMigrationsTableError, RAKE_DB_LOCK_KEY, RakeDbAppliedVersions, RakeDbAst, RakeDbBaseTable, RakeDbChangeFn, RakeDbConfig, RakeDbCtx, RakeDbFn, RakeDbFnReturns, RakeDbLazyFn, RakeDbMigrationId, RakeDbResult, SilentQueries, StructureToAstCtx, StructureToAstTableData, TableOptions, addColumnComment, addColumnIndex, addOrDropEnumValues, astToMigration, changeCache, changeEnumValues, clearChanges, colors, columnToSql, columnTypeToSql, commentsToQuery, concatSchemaAndName, constraintToSql, createDb, createMigrationInterface, dbColumnToAst, deleteMigratedVersion, dropDb, encodeColumnDefault, exhaustive, generateTimeStamp, getColumnName, getConstraintName, getCurrentChanges, getDatabaseAndUserFromOptions, getDbStructureTableData, getDbTableColumnsChecks, getFirstWordAndRest, getForeignKeyTable, getIndexName, getMigratedVersionsMap, getSchemaAndTableFromName, getTextAfterFrom, getTextAfterTo, identityToSql, indexesToQuery, instantiateDbColumn, introspectDbSchema, joinColumns, joinWords, makeDbStructureColumnsShape, makeDomainsMap, makeFileVersion, makePopulateEnumQuery, makeStructureToAstCtx, migrate, migrateOrRollback, migrationConfigDefaults, newMigration, pluralize, primaryKeyToSql, processRakeDbConfig, promptConfirm, promptSelect, promptText, pushChange, queryLock, quoteNameFromString, quoteSchemaTable, quoteTable, quoteWithSchema, rakeDb, rakeDbAliases, rakeDbCommands, redo, referencesToSql, renameType, resetDb, rollback, saveMigratedVersion, structureToAst, tableToAst, transaction, versionToString, writeMigrationFile };
|
package/dist/index.js
CHANGED
|
@@ -1919,7 +1919,7 @@ class Migration {
|
|
|
1919
1919
|
*
|
|
1920
1920
|
* change(async (db) => {
|
|
1921
1921
|
* await db.createDomain('domainName', (t) =>
|
|
1922
|
-
* t.integer().check(
|
|
1922
|
+
* t.integer().check(t.sql`value = 42`),
|
|
1923
1923
|
* );
|
|
1924
1924
|
*
|
|
1925
1925
|
* // use `schemaName.domainName` format to specify a schema
|
|
@@ -1929,7 +1929,7 @@ class Migration {
|
|
|
1929
1929
|
* .nullable()
|
|
1930
1930
|
* .collate('C')
|
|
1931
1931
|
* .default('default text')
|
|
1932
|
-
* .check(
|
|
1932
|
+
* .check(t.sql`length(value) > 10`),
|
|
1933
1933
|
* );
|
|
1934
1934
|
* });
|
|
1935
1935
|
* ```
|
|
@@ -3090,7 +3090,10 @@ const migrationConfigDefaults = {
|
|
|
3090
3090
|
snakeCase: false,
|
|
3091
3091
|
commands: {},
|
|
3092
3092
|
log: true,
|
|
3093
|
-
logger: console
|
|
3093
|
+
logger: console,
|
|
3094
|
+
import() {
|
|
3095
|
+
throw new Error("Please define the `import` setting in `rakeDb` config");
|
|
3096
|
+
}
|
|
3094
3097
|
};
|
|
3095
3098
|
const processRakeDbConfig = (config) => {
|
|
3096
3099
|
var _a, _b;
|