How to use the db-migrate.createMigration function in db-migrate

To help you get started, we’ve selected a few db-migrate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wzrdtales / node-ultimate-migrate / index.js View on Github external
createMigrationDir( sqlDir, function( err )
    {
        if ( err )
        {
            log.error( 'Failed to create migration directory at ', sqlDir, err );
            process.exit( 1 );
        }

        var templateTypeDefaultSQL = Migration.TemplateType.DEFAULT_SQL;
        var migrationUpSQL = new Migration( argv.title + '-up.sql', sqlDir, new Date(), templateTypeDefaultSQL );

        index.createMigration( migrationUpSQL, function( err, migration )
        {
            assert.ifError( err );
            log.info( util.format( 'Created migration up sql file at %s', migration.path ) );
        } );

        var migrationDownSQL = new Migration( argv.title + '-down.sql', sqlDir, new Date(), templateTypeDefaultSQL );

        index.createMigration( migrationDownSQL, function( err, migration )
        {
            assert.ifError( err );
            log.info( util.format( 'Created migration down sql file at %s', migration.path ) );
        } );
    } );
}
github wzrdtales / node-ultimate-migrate / index.js View on Github external
log.error( 'Failed to create migration directory at ', sqlDir, err );
            process.exit( 1 );
        }

        var templateTypeDefaultSQL = Migration.TemplateType.DEFAULT_SQL;
        var migrationUpSQL = new Migration( argv.title + '-up.sql', sqlDir, new Date(), templateTypeDefaultSQL );

        index.createMigration( migrationUpSQL, function( err, migration )
        {
            assert.ifError( err );
            log.info( util.format( 'Created migration up sql file at %s', migration.path ) );
        } );

        var migrationDownSQL = new Migration( argv.title + '-down.sql', sqlDir, new Date(), templateTypeDefaultSQL );

        index.createMigration( migrationDownSQL, function( err, migration )
        {
            assert.ifError( err );
            log.info( util.format( 'Created migration down sql file at %s', migration.path ) );
        } );
    } );
}
github wzrdtales / node-ultimate-migrate / index.js View on Github external
}
        }
        var templateType = Migration.TemplateType.DEFAULT_JS;

        if( shouldCreateSqlFiles() )
        {
            templateType = Migration.TemplateType.SQL_FILE_LOADER;
        }
        else if( shouldCreateCoffeeFile() )
        {
            templateType = Migration.TemplateType.DEFAULT_COFFEE;
        }

        var migration = new Migration( argv.title + '.js', path, new Date(), templateType );

        index.createMigration( migration, function ( err, migration )
        {
            assert.ifError( err );
            log.info( util.format( 'Created migration at %s', migration.path ) );
        } );
    } );