rake-db 2.22.36 → 2.22.38

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 CHANGED
@@ -1240,6 +1240,10 @@ declare const quoteWithSchema: ({ schema, name, }: {
1240
1240
  declare const quoteTable: (schema: string | undefined, table: string) => string;
1241
1241
  declare const getSchemaAndTableFromName: (name: string) => [string | undefined, string];
1242
1242
  declare const quoteNameFromString: (string: string) => string;
1243
+ /**
1244
+ * Do not quote the type itself because it can be an expression like `geography(point)` for postgis.
1245
+ */
1246
+ declare const quoteCustomType: (s: string) => string;
1243
1247
  declare const quoteSchemaTable: (arg: {
1244
1248
  schema?: string;
1245
1249
  name: string;
@@ -1813,4 +1817,4 @@ declare const promptText: ({ message, default: def, password, min, }: {
1813
1817
  min?: number;
1814
1818
  }) => Promise<string>;
1815
1819
 
1816
- 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, RakeDbRenameMigrations, RakeDbRenameMigrationsInput, RakeDbRenameMigrationsMap, 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, interpolateSqlValues, 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 };
1820
+ 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, RakeDbRenameMigrations, RakeDbRenameMigrationsInput, RakeDbRenameMigrationsMap, 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, interpolateSqlValues, introspectDbSchema, joinColumns, joinWords, makeDbStructureColumnsShape, makeDomainsMap, makeFileVersion, makePopulateEnumQuery, makeStructureToAstCtx, migrate, migrateOrRollback, migrationConfigDefaults, newMigration, pluralize, primaryKeyToSql, processRakeDbConfig, promptConfirm, promptSelect, promptText, pushChange, queryLock, quoteCustomType, quoteNameFromString, quoteSchemaTable, quoteTable, quoteWithSchema, rakeDb, rakeDbAliases, rakeDbCommands, redo, referencesToSql, renameType, resetDb, rollback, saveMigratedVersion, structureToAst, tableToAst, transaction, versionToString, writeMigrationFile };
package/dist/index.js CHANGED
@@ -54,6 +54,10 @@ const getSchemaAndTableFromName = (name) => {
54
54
  const quoteNameFromString = (string) => {
55
55
  return quoteTable(...getSchemaAndTableFromName(string));
56
56
  };
57
+ const quoteCustomType = (s) => {
58
+ const [schema, type] = getSchemaAndTableFromName(s);
59
+ return schema ? '"' + schema + '".' + type : type;
60
+ };
57
61
  const quoteSchemaTable = (arg) => {
58
62
  return orchidCore.singleQuote(concatSchemaAndName(arg));
59
63
  };
@@ -114,7 +118,7 @@ var __spreadValues$9 = (a, b) => {
114
118
  var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
115
119
  const versionToString = (config, version) => config.migrationId === "timestamp" ? `${version}` : `${version}`.padStart(config.migrationId.serial, "0");
116
120
  const columnTypeToSql = (item) => {
117
- return item.data.isOfCustomType ? quoteNameFromString(item.toSQL()) : item.toSQL();
121
+ return item.data.isOfCustomType ? item instanceof pqb.DomainColumn ? quoteNameFromString(item.dataType) : quoteCustomType(item.toSQL()) : item.toSQL();
118
122
  };
119
123
  const getColumnName = (item, key, snakeCase) => {
120
124
  return item.data.name || (snakeCase ? orchidCore.toSnakeCase(key) : key);
@@ -1136,7 +1140,7 @@ const handleTableItemChange = (key, item, ast, alterTable, renameItems, values,
1136
1140
  let changeType = false;
1137
1141
  if (to.type && (from.type !== to.type || from.collate !== to.collate)) {
1138
1142
  changeType = true;
1139
- const type = !to.column || to.column.data.isOfCustomType ? quoteNameFromString(to.type) : to.type;
1143
+ const type = !to.column || to.column.data.isOfCustomType ? to.column && to.column instanceof pqb.DomainColumn ? quoteNameFromString(to.type) : quoteCustomType(to.type) : to.type;
1140
1144
  alterTable.push(
1141
1145
  `ALTER COLUMN "${name}" TYPE ${type}${to.collate ? ` COLLATE ${quoteNameFromString(to.collate)}` : ""}${((_a = item.using) == null ? void 0 : _a.usingUp) ? ` USING ${item.using.usingUp.toSQL({ values })}` : to.column instanceof pqb.EnumColumn ? ` USING "${name}"::text::${type}` : ""}`
1142
1146
  );
@@ -5966,6 +5970,7 @@ exports.promptSelect = promptSelect;
5966
5970
  exports.promptText = promptText;
5967
5971
  exports.pushChange = pushChange;
5968
5972
  exports.queryLock = queryLock;
5973
+ exports.quoteCustomType = quoteCustomType;
5969
5974
  exports.quoteNameFromString = quoteNameFromString;
5970
5975
  exports.quoteSchemaTable = quoteSchemaTable;
5971
5976
  exports.quoteTable = quoteTable;