mirror of
https://github.com/swc-project/swc.git
synced 2024-12-30 09:03:37 +03:00
31 lines
836 B
TypeScript
31 lines
836 B
TypeScript
// Loaded from https://raw.githubusercontent.com/denjucks/dex/master/lib/migrate/table-resolver.js
|
|
|
|
|
|
//Get schema-aware table name
|
|
export function getTableName(tableName, schemaName) {
|
|
return schemaName ? `${schemaName}.${tableName}` : tableName;
|
|
}
|
|
|
|
//Get schema-aware query builder for a given table and schema name
|
|
export function getTable(trxOrKnex, tableName, schemaName) {
|
|
return schemaName
|
|
? trxOrKnex(tableName).withSchema(schemaName)
|
|
: trxOrKnex(tableName);
|
|
}
|
|
export function getLockTableName(tableName) {
|
|
return tableName + '_lock';
|
|
}
|
|
|
|
export function getLockTableNameWithSchema(tableName, schemaName) {
|
|
return schemaName
|
|
? schemaName + '.' + getLockTableName(tableName)
|
|
: getLockTableName(tableName);
|
|
}
|
|
|
|
export default {
|
|
getLockTableName,
|
|
getLockTableNameWithSchema,
|
|
getTable,
|
|
getTableName,
|
|
};
|