core/server/data/migrations/utils/tables.js
/**
 * Creates a migration which will drop an existing table and then re-add a new table based on provided spec
 * @param {string} name - table name
 * @param {Object} tableSpec - copy of table schema definition as defined in schema.js at the moment of writing the migration,
 * this parameter MUST be present, otherwise @daniellockyer will hunt you down
 *
 * @returns {Object} migration object returning config/up/down properties
 */
Creates a migration which will drop an existing table and then re-add a new table based on provided spec
@param {string} name - table name
@param {Object} tableSpec - copy of table schema definition as defined in schema.js at the moment of writing the migration,
this parameter MUST be present, otherwise @daniellockyer will hunt you down

@returns {Object} migration object returning config/up/down properties
Creates a migration which will drop an existing table and then re - add a new table based on provided spec @param { string } name - table name @param { Object } tableSpec - copy of table schema definition as defined in schema . js at the moment of writing the migration this parameter MUST be present otherwise @daniellockyer will hunt you down @returns { Object } migration object returning config / up / down properties
function recreateTable(name, tableSpec) {
    return createNonTransactionalMigration(
        async function up(connection) {
            const exists = await connection.schema.hasTable(name);
            if (!exists) {
                logging.warn(`Skipping dropping table: ${name} - table does not exist`);
            } else {
                logging.info(`Dropping table: ${name}`);
                await commands.deleteTable(name, connection);
                logging.info(`Re-adding table: ${name}`);
                await commands.createTable(name, connection, tableSpec);
            }
        },
        async function down() {
            logging.warn(`Ignoring rollback for table recreate: ${name}`);
            return Promise.resolve();
        }
    );
}
function recreateTable ( name , tableSpec ) { return createNonTransactionalMigration ( async function up ( connection ) { const exists = await connection . schema . hasTable ( name ) ; if ( ! exists ) { logging . warn ( ` ${ name } ` ) ; } else { logging . info ( ` ${ name } ` ) ; await commands . deleteTable ( name , connection ) ; logging . info ( ` ${ name } ` ) ; await commands . createTable ( name , connection , tableSpec ) ; } } , async function down ( ) { logging . warn ( ` ${ name } ` ) ; return Promise . resolve ( ) ; } ) ; }
Creates a migration which will drop an existing table and then re-add a new table based on provided spec
 @param {string} name - table name
 @param {Object} tableSpec - copy of table schema definition as defined in schema.js at the moment of writing the migration,
 this parameter MUST be present, otherwise @daniellockyer will hunt you down
Creates a migration which will drop an existing table and then re - add a new table based on provided spec @param { string } name - table name @param { Object } tableSpec - copy of table schema definition as defined in schema . js at the moment of writing the migration this parameter MUST be present otherwise @daniellockyer will hunt you down
// noop: we cannot go back to old table schema