mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-22 00:07:52 +01:00
Update migrations jsdocs
This commit is contained in:
parent
6fb1202c1c
commit
7cbf9de8ca
@ -9,6 +9,10 @@ const Logger = require('../Logger')
|
|||||||
class MigrationManager {
|
class MigrationManager {
|
||||||
static MIGRATIONS_META_TABLE = 'migrationsMeta'
|
static MIGRATIONS_META_TABLE = 'migrationsMeta'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('../Database').sequelize} sequelize
|
||||||
|
* @param {string} [configPath]
|
||||||
|
*/
|
||||||
constructor(sequelize, configPath = global.configPath) {
|
constructor(sequelize, configPath = global.configPath) {
|
||||||
if (!sequelize || !(sequelize instanceof Sequelize)) throw new Error('Sequelize instance is required for MigrationManager.')
|
if (!sequelize || !(sequelize instanceof Sequelize)) throw new Error('Sequelize instance is required for MigrationManager.')
|
||||||
this.sequelize = sequelize
|
this.sequelize = sequelize
|
||||||
@ -23,6 +27,11 @@ class MigrationManager {
|
|||||||
this.umzug = null
|
this.umzug = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init version vars and copy migration files to config dir if necessary
|
||||||
|
*
|
||||||
|
* @param {string} serverVersion
|
||||||
|
*/
|
||||||
async init(serverVersion) {
|
async init(serverVersion) {
|
||||||
if (!(await fs.pathExists(this.configPath))) throw new Error(`Config path does not exist: ${this.configPath}`)
|
if (!(await fs.pathExists(this.configPath))) throw new Error(`Config path does not exist: ${this.configPath}`)
|
||||||
|
|
||||||
@ -212,6 +221,13 @@ class MigrationManager {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {{ name: string }[]} migrations
|
||||||
|
* @param {string[]} executedMigrations - names of executed migrations
|
||||||
|
* @param {string} direction - 'up' or 'down'
|
||||||
|
* @returns {string[]} - names of migrations to run
|
||||||
|
*/
|
||||||
findMigrationsToRun(migrations, executedMigrations, direction) {
|
findMigrationsToRun(migrations, executedMigrations, direction) {
|
||||||
const migrationsToRun = migrations
|
const migrationsToRun = migrations
|
||||||
.filter((migration) => {
|
.filter((migration) => {
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
const { DataTypes } = require('sequelize')
|
const { DataTypes } = require('sequelize')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef MigrationContext
|
||||||
|
* @property {import('sequelize').QueryInterface} queryInterface - a suquelize QueryInterface object.
|
||||||
|
* @property {import('../Logger')} logger - a Logger object.
|
||||||
|
*
|
||||||
|
* @typedef MigrationOptions
|
||||||
|
* @property {MigrationContext} context - an object containing the migration context.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an example of an upward migration script.
|
* This is an example of an upward migration script.
|
||||||
*
|
*
|
||||||
* @param {import { QueryInterface } from "sequelize";} options.context.queryInterface - a suquelize QueryInterface object.
|
* @param {MigrationOptions} options - an object containing the migration context.
|
||||||
* @param {import { Logger } from "../../../server/Logger";} options.context.logger - a Logger object.
|
|
||||||
* @returns {Promise<void>} - A promise that resolves when the migration is complete.
|
* @returns {Promise<void>} - A promise that resolves when the migration is complete.
|
||||||
*/
|
*/
|
||||||
async function up({ context: { queryInterface, logger } }) {
|
async function up({ context: { queryInterface, logger } }) {
|
||||||
@ -28,8 +36,7 @@ async function up({ context: { queryInterface, logger } }) {
|
|||||||
/**
|
/**
|
||||||
* This is an example of a downward migration script.
|
* This is an example of a downward migration script.
|
||||||
*
|
*
|
||||||
* @param {import { QueryInterface } from "sequelize";} options.context.queryInterface - a suquelize QueryInterface object.
|
* @param {MigrationOptions} options - an object containing the migration context.
|
||||||
* @param {import { Logger } from "../../../server/Logger";} options.context.logger - a Logger object.
|
|
||||||
* @returns {Promise<void>} - A promise that resolves when the migration is complete.
|
* @returns {Promise<void>} - A promise that resolves when the migration is complete.
|
||||||
*/
|
*/
|
||||||
async function down({ context: { queryInterface, logger } }) {
|
async function down({ context: { queryInterface, logger } }) {
|
||||||
|
Loading…
Reference in New Issue
Block a user