Skip to content

Commit

Permalink
Run integration test with a migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
mikiher committed Sep 14, 2024
1 parent 5516480 commit 8e8159b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions server/migrations/v2.14.0-migration_example1.js
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 }

0 comments on commit 8e8159b

Please sign in to comment.