mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-24 09:49:24 +02:00
Add db migration management infratructure
This commit is contained in:
parent
0344a63b48
commit
3f93b93d9e
13 changed files with 1385 additions and 172 deletions
42
test/server/migrations/v0.0.1-migration_example.js
Normal file
42
test/server/migrations/v0.0.1-migration_example.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
const { DataTypes } = require('sequelize')
|
||||
const Logger = require('../../../server/Logger')
|
||||
|
||||
/**
|
||||
* This is an example of an upward migration script.
|
||||
*
|
||||
* @param {import { QueryInterface } from "sequelize";} options.context.queryInterface - a suquelize QueryInterface object.
|
||||
* @returns {Promise<void>} - A promise that resolves when the migration is complete.
|
||||
*/
|
||||
async function up({ context: queryInterface }) {
|
||||
Logger.info('Running migration_example up...')
|
||||
Logger.info('Creating example_table...')
|
||||
await queryInterface.createTable('example_table', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
}
|
||||
})
|
||||
Logger.info('example_table created.')
|
||||
Logger.info('migration_example up complete.')
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an example of a downward migration script.
|
||||
*
|
||||
* @param {import { QueryInterface } from "sequelize";} options.context.queryInterface - a suquelize QueryInterface object.
|
||||
* @returns {Promise<void>} - A promise that resolves when the migration is complete.
|
||||
*/
|
||||
async function down({ context: queryInterface }) {
|
||||
Logger.info('Running migration_example down...')
|
||||
Logger.info('Dropping example_table...')
|
||||
await queryInterface.dropTable('example_table')
|
||||
Logger.info('example_table dropped.')
|
||||
Logger.info('migration_example down complete.')
|
||||
}
|
||||
|
||||
module.exports = { up, down }
|
Loading…
Add table
Add a link
Reference in a new issue