<commit_before>var fs = require('fs');
var path = require('path');
var config = require('./config');
var log = require('./log');
var Skeleton = require('./skeleton');

var filesRegEx = /\.js$/;
var coffeeSupported = false;
var coffeeModule = null;
try {
  coffeeModule = require('coffee-script');
  if (coffeeModule && coffeeModule.register) coffeeModule.register();
  coffeeSupported = true;
  filesRegEx = /\.(js|coffee)$/;
} catch (e) {}

var internals = {};

function writeMigrationRecord(db, migration, callback) {
  db._runSql('INSERT INTO ' + internals.migrationTable + ' (name, run_on) VALUES (?, ?)', [migration.name, new Date()], callback);
}

var Migration = Skeleton.extend({

    init: function() {
    if (arguments.length >= 3) {
      this.title = arguments[0];
      this.date = arguments[2];
      this.name = this.formatName(this.title, this.date);
      this.path = this.formatPath(arguments[1], this.name);
      this.templateType = arguments[3];
      this.internals = arguments[4];
    } else if (arguments.length == 2) {
      this.path = arguments[0];
      this.name = this.parseName(this.path);
      this.date = this.parseDate(this.name);
      this.title = this.parseTitle(this.name);
      this.internals = arguments[1];
    }

    this._super(this.internals);
  }
});

Migration.prototype.defaultCoffeeTemplate = function() {
  return [
    "'use strict';",
    "",
    "dbm = undefined",
    "type = undefined",
    "seed = undefined",
    "",
    "exports.setup = (options, seedLink) ->",
    "  dbm = options.dbmigrate;",
    "  type = dbm.dataType;",
    "  seed = seedLink;",
    "  return",
    "",
    "exports.up = (db, callback) ->",
    "",
    "",
    "exports.down = (db, callback) ->",
    "",
    "",
    ""
  ].join("\n");
};

Migration.prototype.defaultJsTemplate = function() {
  return [
    "'use strict';",
    "",
    "var dbm;",
    "var type;",
    "var seed;",
    "",
    "/**",
    "  * We receive the dbmigrate dependency from dbmigrate initially.",
    "  * This enables us to not have to rely on NODE_PATH.",
    "  */",
    "exports.setup = function(options, seedLink) {",
    "  dbm = options.dbmigrate;",
    "  type = dbm.dataType;",
    "  seed = seedLink;",
    "};",
    "",
    "exports.up = function(db, callback) {",
    "  callback();",
    "};",
    "",
    "exports.down = function(db, callback) {",
    "  callback();",
    "};",
    ""
  ].join("\n");
};

Migration.prototype.defaultSqlTemplate = function() {
  return "/* Replace with your SQL commands */";
};


Migration.prototype.sqlFileLoaderTemplate = function() {
  return [
    "'use strict';",
    "",
    "var dbm;",
    "var type;",
    "var seed;",
    "var fs = require('fs');",
    "var path = require('path');",
    "",
    "/**",
    "  * We receive the dbmigrate dependency from dbmigrate initially.",
    "  * This enables us to not have to rely on NODE_PATH.",
    "  */",
    "exports.setup = function(options, seedLink) {",
    "  dbm = options.dbmigrate;",
    "  type = dbm.dataType;",
    "  seed = seedLink;",
    "};",
    "",
    "exports.up = function(db, callback) {",
    "  var filePath = path.join(__dirname + '/sqls/"+this.name.replace('.js', '')+"-up.sql');",
    "  fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){",
    "    if (err) return callback(err);",
    "    console.log('received data: ' + data);",
    "",
    "    db.runSql(data, function(err) {",
    "      if (err) return callback(err);",
    "      callback();",
    "    });",
    "  });",
    "};",
    "",
    "exports.down = function(db, callback) {",
    "  var filePath = path.join(__dirname + '/sqls/"+this.name.replace('.js', '')+"-down.sql');",
    "  fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){",
    "    if (err) return callback(err);",
    "    console.log('received data: ' + data);",
    "",
    "    db.runSql(data, function(err) {",
    "      if (err) return callback(err);",
    "      callback();",
    "    });",
    "  });",
    "};",
    ""
  ].join("\n");
};

Migration.prototype.coffeeSqlFileLoaderTemplate = function() {
  return [
    "'use strict';",
    "",
    "dbm = undefined",
    "type = undefined",
    "fs = require 'fs'",
    "path = require 'path'",
    "",
    "#",
    "# We receive the dbmigrate dependency from dbmigrate initially.",
    "# This enables us to not have to rely on NODE_PATH.",
    "#",
    "exports.setup = (options) ->",
    "  dbm = options.dbmigrate",
    "  type = dbm.dataType",
    "",
    "",
    "exports.up = (db, callback) ->",
    "  filePath = path.join \"#{__dirname}/sqls/"+this.name.replace('.coffee', '')+"-up.sql\"",
    "  fs.readFile filePath, {encoding: 'utf-8'}, (err,data) ->",
    "    return callback err if err",
    "",
    "    db.runSql data, callback",
    "",
    "exports.down = (db, callback) ->",
    "  filePath = path.join \"#{__dirname}/sqls/"+this.name.replace('.coffee', '')+"-down.sql\"",

    "  fs.readFile filePath, {encoding: 'utf-8'}, (err,data) ->",
    "    return callback err if err",
    "",
    "    db.runSql data, callback",
    ""
  ].join("\n");
};
<commit_msg>add missing seedLink to coffee sql template<commit_after>var fs = require('fs');
var path = require('path');
var config = require('./config');
var log = require('./log');
var Skeleton = require('./skeleton');

var filesRegEx = /\.js$/;
var coffeeSupported = false;
var coffeeModule = null;
try {
  coffeeModule = require('coffee-script');
  if (coffeeModule && coffeeModule.register) coffeeModule.register();
  coffeeSupported = true;
  filesRegEx = /\.(js|coffee)$/;
} catch (e) {}

var internals = {};

function writeMigrationRecord(db, migration, callback) {
  db._runSql('INSERT INTO ' + internals.migrationTable + ' (name, run_on) VALUES (?, ?)', [migration.name, new Date()], callback);
}

var Migration = Skeleton.extend({

    init: function() {
    if (arguments.length >= 3) {
      this.title = arguments[0];
      this.date = arguments[2];
      this.name = this.formatName(this.title, this.date);
      this.path = this.formatPath(arguments[1], this.name);
      this.templateType = arguments[3];
      this.internals = arguments[4];
    } else if (arguments.length == 2) {
      this.path = arguments[0];
      this.name = this.parseName(this.path);
      this.date = this.parseDate(this.name);
      this.title = this.parseTitle(this.name);
      this.internals = arguments[1];
    }

    this._super(this.internals);
  }
});

Migration.prototype.defaultCoffeeTemplate = function() {
  return [
    "'use strict';",
    "",
    "dbm = undefined",
    "type = undefined",
    "seed = undefined",
    "",
    "exports.setup = (options, seedLink) ->",
    "  dbm = options.dbmigrate;",
    "  type = dbm.dataType;",
    "  seed = seedLink;",
    "  return",
    "",
    "exports.up = (db, callback) ->",
    "",
    "",
    "exports.down = (db, callback) ->",
    "",
    "",
    ""
  ].join("\n");
};

Migration.prototype.defaultJsTemplate = function() {
  return [
    "'use strict';",
    "",
    "var dbm;",
    "var type;",
    "var seed;",
    "",
    "/**",
    "  * We receive the dbmigrate dependency from dbmigrate initially.",
    "  * This enables us to not have to rely on NODE_PATH.",
    "  */",
    "exports.setup = function(options, seedLink) {",
    "  dbm = options.dbmigrate;",
    "  type = dbm.dataType;",
    "  seed = seedLink;",
    "};",
    "",
    "exports.up = function(db, callback) {",
    "  callback();",
    "};",
    "",
    "exports.down = function(db, callback) {",
    "  callback();",
    "};",
    ""
  ].join("\n");
};

Migration.prototype.defaultSqlTemplate = function() {
  return "/* Replace with your SQL commands */";
};


Migration.prototype.sqlFileLoaderTemplate = function() {
  return [
    "'use strict';",
    "",
    "var dbm;",
    "var type;",
    "var seed;",
    "var fs = require('fs');",
    "var path = require('path');",
    "",
    "/**",
    "  * We receive the dbmigrate dependency from dbmigrate initially.",
    "  * This enables us to not have to rely on NODE_PATH.",
    "  */",
    "exports.setup = function(options, seedLink) {",
    "  dbm = options.dbmigrate;",
    "  type = dbm.dataType;",
    "  seed = seedLink;",
    "};",
    "",
    "exports.up = function(db, callback) {",
    "  var filePath = path.join(__dirname + '/sqls/"+this.name.replace('.js', '')+"-up.sql');",
    "  fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){",
    "    if (err) return callback(err);",
    "    console.log('received data: ' + data);",
    "",
    "    db.runSql(data, function(err) {",
    "      if (err) return callback(err);",
    "      callback();",
    "    });",
    "  });",
    "};",
    "",
    "exports.down = function(db, callback) {",
    "  var filePath = path.join(__dirname + '/sqls/"+this.name.replace('.js', '')+"-down.sql');",
    "  fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){",
    "    if (err) return callback(err);",
    "    console.log('received data: ' + data);",
    "",
    "    db.runSql(data, function(err) {",
    "      if (err) return callback(err);",
    "      callback();",
    "    });",
    "  });",
    "};",
    ""
  ].join("\n");
};

Migration.prototype.coffeeSqlFileLoaderTemplate = function() {
  return [
    "'use strict';",
    "",
    "dbm = undefined",
    "type = undefined",
    "seed = undefined",
    "fs = require 'fs'",
    "path = require 'path'",
    "",
    "#",
    "# We receive the dbmigrate dependency from dbmigrate initially.",
    "# This enables us to not have to rely on NODE_PATH.",
    "#",
    "exports.setup = (options, seedLink) ->",
    "  dbm = options.dbmigrate",
    "  type = dbm.dataType",
    "  seed = seedLink",
    "",
    "",
    "exports.up = (db, callback) ->",
    "  filePath = path.join \"#{__dirname}/sqls/"+this.name.replace('.coffee', '')+"-up.sql\"",
    "  fs.readFile filePath, {encoding: 'utf-8'}, (err,data) ->",
    "    return callback err if err",
    "",
    "    db.runSql data, callback",
    "",
    "exports.down = (db, callback) ->",
    "  filePath = path.join \"#{__dirname}/sqls/"+this.name.replace('.coffee', '')+"-down.sql\"",

    "  fs.readFile filePath, {encoding: 'utf-8'}, (err,data) ->",
    "    return callback err if err",
    "",
    "    db.runSql data, callback",
    ""
  ].join("\n");
};

{'fraction_non_alphanumeric': 0.2079590456872404, 'fraction_numerical': 0.00251134936733314, 'mean_word_length': 2.6432090077410275, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '2079901', 'n_tokens_mistral': 3545, 'n_tokens_neox': 3572, 'n_words': 711}