rake-db 2.27.20 → 2.27.22

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
@@ -275,7 +275,7 @@ declare const getSchemaAndTableFromName: (name: string) => [string | undefined,
275
275
  declare const concatSchemaAndName: ({ schema, name, }: {
276
276
  schema?: string;
277
277
  name: string;
278
- }) => string;
278
+ }, excludeCurrentSchema?: string) => string;
279
279
 
280
280
  interface MigrationItemHasLoad {
281
281
  path?: string;
package/dist/index.js CHANGED
@@ -3222,14 +3222,14 @@ const quoteCustomType = (s) => {
3222
3222
  const [schema, type] = getSchemaAndTableFromName(s);
3223
3223
  return schema ? '"' + schema + '".' + type : type;
3224
3224
  };
3225
- const quoteSchemaTable = (arg) => {
3226
- return pqb.singleQuote(concatSchemaAndName(arg));
3225
+ const quoteSchemaTable = (arg, excludeCurrentSchema) => {
3226
+ return pqb.singleQuote(concatSchemaAndName(arg, excludeCurrentSchema));
3227
3227
  };
3228
3228
  const concatSchemaAndName = ({
3229
3229
  schema,
3230
3230
  name
3231
- }) => {
3232
- return schema ? `${schema}.${name}` : name;
3231
+ }, excludeCurrentSchema) => {
3232
+ return schema && schema !== excludeCurrentSchema ? `${schema}.${name}` : name;
3233
3233
  };
3234
3234
  const makePopulateEnumQuery = (item) => {
3235
3235
  const [schema, name] = getSchemaAndTableFromName(item.enumName);
@@ -4319,7 +4319,7 @@ const instantiateDbColumn = (ctx, data, domains, dbColumn) => {
4319
4319
  if (enumType) {
4320
4320
  column = new pqb.EnumColumn(
4321
4321
  ctx.columnSchemaConfig,
4322
- typeId,
4322
+ typeSchema === ctx.currentSchema ? typeName : typeId,
4323
4323
  enumType.values,
4324
4324
  ctx.columnSchemaConfig.type
4325
4325
  );
@@ -5252,24 +5252,27 @@ const astEncoders = {
5252
5252
  pqb.addCode(code, ");");
5253
5253
  return code;
5254
5254
  },
5255
- enum(ast) {
5256
- return `await db.${ast.action === "create" ? "createEnum" : "dropEnum"}(${quoteSchemaTable(ast)}, [${ast.values.map(pqb.singleQuote).join(", ")}]);`;
5255
+ enum(ast, _, currentSchema) {
5256
+ return `await db.${ast.action === "create" ? "createEnum" : "dropEnum"}(${quoteSchemaTable(ast, currentSchema)}, [${ast.values.map(pqb.singleQuote).join(", ")}]);`;
5257
5257
  },
5258
- enumValues(ast) {
5258
+ enumValues(ast, _, currentSchema) {
5259
5259
  return `await db.${ast.action}EnumValues(${quoteSchemaTable(
5260
- ast
5260
+ ast,
5261
+ currentSchema
5261
5262
  )}, [${ast.values.map(pqb.singleQuote).join(", ")}]);`;
5262
5263
  },
5263
- renameEnumValues(ast, config) {
5264
+ renameEnumValues(ast, config, currentSchema) {
5264
5265
  return `await db.renameEnumValues(${quoteSchemaTable(
5265
- ast
5266
+ ast,
5267
+ currentSchema
5266
5268
  )}, { ${Object.entries(ast.values).map(
5267
5269
  ([from, to]) => `${pqb.quoteObjectKey(from, config.snakeCase)}: ${pqb.singleQuote(to)}`
5268
5270
  ).join(", ")} });`;
5269
5271
  },
5270
- changeEnumValues(ast) {
5272
+ changeEnumValues(ast, _, currentSchema) {
5271
5273
  return `await db.changeEnumValues(${quoteSchemaTable(
5272
- ast
5274
+ ast,
5275
+ currentSchema
5273
5276
  )}, [${ast.fromValues.map(pqb.singleQuote).join(", ")}], [${ast.toValues.map(pqb.singleQuote).join(", ")}]);`;
5274
5277
  },
5275
5278
  domain(ast, _, currentSchema) {