<commit_before>var injector    = require( 'injector' )
  , utils       = require( 'utils' )
  , async       = require( 'async' )
  , config      = require( 'config' )
  , path        = require( 'path' )
  , ormUtils    = require( path.resolve( path.join( __dirname, '..', 'lib', 'utils.js' ) ) )
  , env         = utils.bootstrapEnv()
  , moduleLdr   = env.moduleLoader;

// Rebase once our modules have loaded
moduleLdr.on( 'modulesLoaded', function() {
    var sequelize = injector.getInstance( 'sequelize' );

    console.log('Forcing Database to be created! (Note: All your data will disapear!)');
    async.waterfall(
        [
            function createDatabase( callback ) {
                var query = 'CREATE DATABASE ' + ( config[ 'clever-orm' ].db.options.dialect === 'mysql' ? 'IF NOT EXISTS ' : '' ) + config[ 'clever-orm' ].db.database;

                sequelize.query( query, { raw: true } )
                    .success( function() {
                        callback( null );
                    })
                    .error( callback );
            },

            function rebaseDatabase( callback ) {
                sequelize
                    .sync( { force: true } )
                    .success( function() {
                        callback( null );
                    })
                    .error( callback );
            }
        ],
        function shutdown( err ) {
            if ( err === null ) {
                console.log( 'Database is rebased' );
                process.exit( 0 );
            } else {
                console.error('Error ' + env.config['clever-orm'].db.options.dialect, err);
                process.exit( 1 );
            }
        }
    );<commit_msg>fix(rebase): Updated to run dialect specific sql file inside schema folder (ie. mysql.sql)<commit_after>var injector    = require( 'injector' )
  , util        = require( 'util' )
  , utils       = require( 'utils' )
  , async       = require( 'async' )
  , config      = require( 'config' )
  , path        = require( 'path' )
  , fs          = require( 'fs' )
  , ormUtils    = require( path.resolve( path.join( __dirname, '..', 'lib', 'utils.js' ) ) )
  , env         = utils.bootstrapEnv()
  , moduleLdr   = env.moduleLoader;

console.log( 'Using configuration:' );
console.log( util.inspect( config[ 'clever-orm' ].modelAssociations ) );

// Rebase once our modules have loaded
moduleLdr.on( 'modulesLoaded', function() {
    var sequelize = injector.getInstance( 'sequelize' );

    console.log('Forcing Database to be created! (Note: All your data will disapear!)');
    async.waterfall(
        [
            function createDatabase( callback ) {
                var query = 'CREATE DATABASE ' + ( config[ 'clever-orm' ].db.options.dialect === 'mysql' ? 'IF NOT EXISTS ' : '' ) + config[ 'clever-orm' ].db.database;

                sequelize.query( query, { raw: true } )
                    .success( function() {
                        callback( null );
                    })
                    .error( callback );
            },

            function rebaseDatabase( callback ) {
                sequelize
                    .sync( { force: true } )
                    .success( function() {
                        callback( null );
                    })
                    .error( callback );
            },

            function runDialectSqlFile( callback ) {
                var dialectSqlFile = path.resolve( path.join( __dirname, '..', '..', '..', 'schema', config[ 'clever-orm' ].db.options.dialect + '.sql' ) );
                
                if ( fs.existsSync( dialectSqlFile ) ) {
                    fs.readFile( dialectSqlFile, function( err, sql ) {
                        if ( err || !sql ) {
                            console.log( 'No specific dialect SQL found continuing...' );
                            return callback();
                        }

                        console.log( 'Running dialect specific SQL' );
                        sequelize.query( sql.toString(), null, { raw: true } ).success(function() {
                            callback( null );
                        })
                        .error( callback );
                    });
                } else {
                    callback( null );
                }
            }
        ],
        function shutdown( err ) {
            if ( err === null ) {
                console.log( 'Database is rebased' );
                process.exit( 0 );
            } else {
                console.error('Error ' + env.config['clever-orm'].db.options.dialect, err);
                process.exit( 1 );
            }
        }
    );
{'fraction_non_alphanumeric': 0.1301457975986278, 'fraction_numerical': 0.0008576329331046312, 'mean_word_length': 1.3442211055276383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '598443', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1206, 'n_words': 297}