*/
/**
- * @typedef {Object} SchemaVersionObject
- * @property {Number} major
- * @property {Number} minor
- * @property {Number} patch
+ * @typedef {object} SchemaVersionObject
+ * @property {number} major major
+ * @property {number} minor minor
+ * @property {number} patch patch
*/
/**
* Split a dotted version string into parts.
- * @param {String} v
- * @returns {SchemaVersionObject}
+ * @param {string} v version string
+ * @returns {SchemaVersionObject} version object
*/
function schemaVersionStringToObject(v) {
const [ major, minor, patch ] = v.split('.', 3).map((x) => parseInt(x, 10));
/**
* Render a version object numerically.
- * @param {SchemaVersionObject} v
- * @returns {Number}
+ * Assumes no part will be greater than 1000.
+ * @param {SchemaVersionObject} v version object
+ * @returns {number} number
*/
function schemaVersionObjectToNumber(v) {
const vScale = 1000;
/**
* Convert dotted version string into number.
- * @param {String} v
- * @returns {Number}
+ * @param {string} v version string
+ * @returns {number} number
*/
function schemaVersionStringToNumber(v) {
return schemaVersionObjectToNumber(schemaVersionStringToObject(v));
/**
* Version string comparison, for sorting.
- * @param {String} a
- * @param {String} b
- * @returns {Number}
+ * @param {string} a version string
+ * @param {string} b version string
+ * @returns {number} cmp
*/
function schemaVersionStringCmp(a, b) {
return schemaVersionStringToNumber(a) - schemaVersionStringToNumber(b);
/**
* Check if an entry in a directory is a directory containing a migration file.
- * @param {String} schemaDir
- * @param {String} name
- * @returns {Boolean}
+ * @param {string} schemaDir schema dir
+ * @param {string} name name
+ * @param {string} migrationFile migration file
+ * @returns {boolean} is
*/
function isSchemaMigrationDirectory(schemaDir, name, migrationFile = 'apply.sql') {
// eslint-disable-next-line security/detect-non-literal-fs-filename
// eslint-disable-next-line security/detect-non-literal-fs-filename
applyStat = fs.statSync(path.join(schemaDir, name, migrationFile));
return applyStat.isFile();
- } catch (e) {
+ } catch (e) { // eslint-disable-line no-unused-vars
return false;
}
}
/**
* Return an array of schema migration directory names within engineDir,
* sorted in increasing order.
- * @param {String} engineDir
- * @returns {String[]}
+ * @param {string} engineDir path to implementation
+ * @returns {string[]} versions
*/
function allSchemaVersions(engineDir) {
const schemaDir = path.join(engineDir, 'sql', 'schema');
/**
* Return an array of schema migration directory names within engineDir,
* which are within supported range, and are greater than the current
- * @param {String} engineDir
- * @param {SchemaVersionObject} current
- * @param {Object} supported
- * @param {SchemaVersionObject} supported.min
- * @param {SchemaVersionObject} supported.max
- * @returns {String[]}
+ * @param {string} engineDir path to implementation
+ * @param {SchemaVersionObject} current version
+ * @param {object} supported range of supported versions
+ * @param {SchemaVersionObject} supported.min minimum version
+ * @param {SchemaVersionObject} supported.max maximum version
+ * @returns {string[]} applicable versions
*/
function unappliedSchemaVersions(engineDir, current, supported) {
const min = schemaVersionObjectToNumber(supported.min);
isSchemaMigrationDirectory,
allSchemaVersions,
unappliedSchemaVersions,
-};
\ No newline at end of file
+};