mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 03:43:34 +00:00 
			
		
		
		
	put add-schema in knex util file
This commit is contained in:
		
							parent
							
								
									edc34137c4
								
							
						
					
					
						commit
						6a530cbbfc
					
				@ -10,7 +10,7 @@ const {
 | 
			
		||||
  hasInverseOrderColumn,
 | 
			
		||||
} = require('../metadata/relations');
 | 
			
		||||
const { createQueryBuilder } = require('../query');
 | 
			
		||||
const { addSchema } = require('../utils/add-schema');
 | 
			
		||||
const { addSchema } = require('../utils/knex');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * If some relations currently exist for this oneToX relation, on the one side, this function removes them and update the inverse order if needed.
 | 
			
		||||
 | 
			
		||||
@ -1,10 +0,0 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
const addSchema = (tableName) => {
 | 
			
		||||
  const schemaName = strapi.db.connection.getSchemaName();
 | 
			
		||||
  return schemaName ? `${schemaName}.${tableName}` : tableName;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  addSchema,
 | 
			
		||||
};
 | 
			
		||||
@ -7,6 +7,16 @@ const isKnexQuery = (value) => {
 | 
			
		||||
  return value instanceof KnexBuilder || value instanceof KnexRaw;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Adds the name of the schema to the table name if the schema was defined by the user.
 | 
			
		||||
 * Users can set the db schema only for Postgres in strapi database config.
 | 
			
		||||
 */
 | 
			
		||||
const addSchema = (tableName) => {
 | 
			
		||||
  const schemaName = strapi.db.connection.getSchemaName();
 | 
			
		||||
  return schemaName ? `${schemaName}.${tableName}` : tableName;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  isKnexQuery,
 | 
			
		||||
  addSchema,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user