Skip to content

Commit

Permalink
Clean up config template in favor of Github issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleavely committed Apr 26, 2020
1 parent c563d08 commit 89e8cf8
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 56 deletions.
66 changes: 37 additions & 29 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,50 @@ exports.getConfig = async () => {
}

const defaultConfig = {
// The folder to store migration scripts in.
/**
* @name migrationsDirectory
*
* The folder to store migration scripts in,
* relative to your configuration file.
*/
migrationsDirectory: './migrations',

// Persists the current migration state. The `state` argument
// will always be an object. Store it as JSON to redis, disk, etc.
// OPTIONAL: If undefined, Exodus falls back to exodus.state.json
// storeState: async (state, context) => {},

// This method is responsible for fetching the
// current migration state, persisted by `storeState`.
// OPTIONAL: If undefined, Exodus falls back to exodus.state.json
// fetchState: async (context) => {},

// Invoked at the beginning of a run, this method
// should return an object with any details you want passed
// through to all migrations. This can be database connections,
// logging interfaces, etc.
/**
* @name context
*
* Invoked at the beginning of a run, this method can return
* an object with any details you want passed through to all
* migrations, such as database connections, loggers, etc.
*
* @return {object}
*/
context: async () => {
return {}
},

// Provide a function that returns a string to use
// as the source for a new migration file.
migrationTemplate: async () => {
return fs.readFile(path.resolve(__dirname, './templates/migration.js'), 'utf8')
},
/**
* @name storeState
*
* Called to persist current migration state. Use this to store
* the `state` argument in Redis, to disk, your database etc.
* If undefined, Exodus falls back to exodus.state.json
*
* @param state The state object to be stored.
* @param context The object you returned in `context`
*/
// storeState: async (state, context) => {},

// Invoked at the very beginning of a run before
// any locks are acquired or state is read. Use this to
// establish any connections needed by `fetchState`,
// `storeState`, `lock`, `unlock`.
initialize: async () => {},
/**
* @name initialize
*
* This method is responsible for fetching the current
* migration state, persisted by `storeState`.
* If undefined, Exodus falls back to exodus.state.json
*
* @param context The object you returned in `context`
* @return {object}
*/
// fetchState: async (context) => {},

// Callback executed right before all queued migrations are executed.
beforeAll: async (pendingMigrations) => {},
Expand All @@ -92,8 +104,4 @@ const defaultConfig = {
// Callback executed right after all queued migrations are executed.
afterAll: async (pendingMigrations) => {},

// Invoked at the very tail end of a run once locks
// are released and state has been stored. Use this to tear
// down any connections established in `initialize`.
terminate: async () => {},
}
92 changes: 65 additions & 27 deletions src/templates/config.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,81 @@
module.exports = exports = {
// The folder to store migration scripts in.
/**
* @name migrationsDirectory
*
* The folder to store migration scripts in,
* relative to your configuration file.
*/
// migrationsDirectory: './migrations',

// Persists the current migration state. The `state` argument
// will always be an object. Store it as JSON to redis, disk, etc.
// OPTIONAL: If undefined, Exodus falls back to exodus.state.json
/**
* @name context
*
* Invoked at the beginning of a run, this method can return
* an object with any details you want passed through to all
* migrations, such as database connections, loggers, etc.
*
* @return {object}
*/
// context: async () => { return {} },

/**
* @name storeState
*
* Called to persist current migration state. Use this to store
* the `state` argument in Redis, to disk, your database etc.
* If undefined, Exodus falls back to exodus.state.json
*
* @param state The state object to be stored.
* @param context The object you returned in `context`
*/
// storeState: async (state, context) => {},

// This method is responsible for fetching the
// current migration state, persisted by `storeState`.
// OPTIONAL: If undefined, Exodus falls back to exodus.state.json
/**
* @name fetchState
*
* This method is responsible for fetching the current
* migration state, persisted by `storeState`.
* If undefined, Exodus falls back to exodus.state.json
*
* @param context The object you returned in `context`
* @return {object}
*/
// fetchState: async (context) => {},

// // OPTIONAL. Invoked at the beginning of a run, this method
// // should return an object with any details you want passed
// // through to all migrations. This can be database connections,
// // logging interfaces, etc.
// context: async () => {
// return {}
// },

// // OPTIONAL. Provide a function that returns a string to use
// // as the source for a new migration file.
// migrationTemplate: async () => {
// return require('fs').readFileSync('path/to/template.js', 'utf8',)
// },

// // OPTIONAL. Callback executed right before all
// // queued migrations are executed.
/**
* @name beforeAll
*
* Executed right before any of the queued migrations are run.
*
* @param {migrationJob[]}
*/
// beforeAll: async (pendingMigrations) => {},

// // OPTIONAL. Callback executed before each migration.
/**
* @name beforeEach
*
* Executed before each migration.
*
* @param {migrationJob}
*/
// beforeEach: async (migrationJob) => {},

// // OPTIONAL. Callback executed after each migration.
/**
* @name afterEach
*
* Executed after each migration.
*
* @param {migrationJob}
*/
// afterEach: async (migrationJob) => {},

// // OPTIONAL. Callback executed right after all
// // queued migrations are executed.
/**
* @name afterAll
*
* Executed after the final pending migration was run.
*
* @param {migrationJob[]}
*/
// afterAll: async (pendingMigrations) => {},

}

0 comments on commit 89e8cf8

Please sign in to comment.