<commit_before>var util = require('util');
var pg = require('pg');
var semver = require('semver');
var Base = require('./base');
var type = require('../data_type');
var log = require('../log');

var PgDriver = Base.extend({
    init: function(connection) {
        this._super();
        this.connection = connection;
        this.connection.connect();
    },

    startMigration: function(cb){
        this.runSql('BEGIN;', function() { cb()});
    },

    endMigration: function(cb){
        this.runSql('COMMIT;', function(){cb(null)});
    },

    createColumnDef: function(name, spec, options) {
        var type = spec.autoIncrement ? '' : this.mapDataType(spec.type);
        var len = spec.length ? util.format('(%s)', spec.length) : '';
        var constraint = this.createColumnConstraint(spec, options);
        return [name, type, len, constraint].join(' ');
    },

    mapDataType: function(str) {
        switch(str) {
          case type.STRING:
            return 'VARCHAR';
          case type.DATE_TIME:
            return 'TIMESTAMP';
          case type.BLOG:
            return 'BYTEA';
        }
        return this._super(str);
    },

    createMigrationsTable: function(callback) {
      var options = {
        columns: {
          'id': { type: type.INTEGER, notNull: true, primaryKey: true, autoIncrement: true },
          'name': { type: type.STRING, length: 255, notNull: true},
          'run_on': { type: type.DATE_TIME, notNull: true}
        },
        ifNotExists: false
      };

      this.runSql('select version() as version', function(err, result) {
        if (err) {
          return callback(err);
        }

        if (result.rows && result.rows.length > 0 && result.rows[0].version) {<commit_msg>Fix typo. Closes #76<commit_after>var util = require('util');
var pg = require('pg');
var semver = require('semver');
var Base = require('./base');
var type = require('../data_type');
var log = require('../log');

var PgDriver = Base.extend({
    init: function(connection) {
        this._super();
        this.connection = connection;
        this.connection.connect();
    },

    startMigration: function(cb){
        this.runSql('BEGIN;', function() { cb()});
    },

    endMigration: function(cb){
        this.runSql('COMMIT;', function(){cb(null)});
    },

    createColumnDef: function(name, spec, options) {
        var type = spec.autoIncrement ? '' : this.mapDataType(spec.type);
        var len = spec.length ? util.format('(%s)', spec.length) : '';
        var constraint = this.createColumnConstraint(spec, options);
        return [name, type, len, constraint].join(' ');
    },

    mapDataType: function(str) {
        switch(str) {
          case type.STRING:
            return 'VARCHAR';
          case type.DATE_TIME:
            return 'TIMESTAMP';
          case type.BLOB:
            return 'BYTEA';
        }
        return this._super(str);
    },

    createMigrationsTable: function(callback) {
      var options = {
        columns: {
          'id': { type: type.INTEGER, notNull: true, primaryKey: true, autoIncrement: true },
          'name': { type: type.STRING, length: 255, notNull: true},
          'run_on': { type: type.DATE_TIME, notNull: true}
        },
        ifNotExists: false
      };

      this.runSql('select version() as version', function(err, result) {
        if (err) {
          return callback(err);
        }

        if (result.rows && result.rows.length > 0 && result.rows[0].version) {
{'fraction_non_alphanumeric': 0.156312625250501, 'fraction_numerical': 0.0034354423131978244, 'mean_word_length': 2.3499520613614573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1497832', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1025, 'n_words': 239}