forked from advplyr/audiobookshelf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run integration test with a migration script
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const { DataTypes } = require('sequelize') | ||
const Logger = require('../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 } }) { | ||
logger.info('Running migration_example1 up...') | ||
logger.info('Creating example1_table...') | ||
await queryInterface.createTable('example1_table', { | ||
id: { | ||
type: DataTypes.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true | ||
}, | ||
name: { | ||
type: DataTypes.STRING, | ||
allowNull: false | ||
} | ||
}) | ||
logger.info('example1_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 } }) { | ||
logger.info('Running migration_example1 down...') | ||
logger.info('Dropping example1_table...') | ||
await queryInterface.dropTable('example1_table') | ||
logger.info('example1_table dropped.') | ||
logger.info('migration_example1 down complete.') | ||
} | ||
|
||
module.exports = { up, down } |