How to use the db-migrate.dataType 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 ripple / ripple-rest / db / migrations / 20140123173245-outgoing-transactions.js View on Github external
var dbm = require('db-migrate');
var type = dbm.dataType;

exports.up = function(db, callback) {
  db.createTable('outgoing_transactions', {

    /* Auto-generated */
    created_at: {type: 'timestamp'},
    updated_at: {type: 'timestamp'},

    /* Added initially */
    initial_hash: {type: 'text', primaryKey: true},
    submitted_at_ledger: {type: 'int'},
    src_address: {type: 'text'},
    tx_type: {type: 'text'},
    tx_state: {type: 'text'}, // Updated after submission

    /* Added after submission */
github ripple / ripple-rest / db / migrations / 20140116225343-notifications.js View on Github external
var dbm = require('db-migrate');
var type = dbm.dataType;

exports.up = function(db, callback) {
  db.createTable('notifications', {
    /* Auto-generated */
    createdAt: {type: 'timestamp'},
    updatedAt: {type: 'timestamp'},

    /* rippled fields */
    '"txHash"': {type: 'text', primaryKey: true},
    txResult: {type: 'text'},
    inLedger: {type: 'int'},

    /* ripple-simple fields */
    '"notificationAddress"': {type: 'text', primaryKey: true},
    txType: {type: 'text'},
    txDirection: {type: 'text'},
github ripple / ripple-rest / db / migrations / 20140307230601-client-resource-id_records.js View on Github external
var dbm = require('db-migrate');
var type = dbm.dataType;

exports.up = function(db, callback) {
  db.createTable('client_resource_id_records', {

    /* Auto-generated */
    id: {type: 'int'},
    created_at: {type: 'timestamp'},
    updated_at: {type: 'timestamp'},

    source_account: {type: 'text', primaryKey: true},
    type: {type: 'text', primaryKey: true},
    client_resource_id: {type: 'text', primaryKey: true},
    hash: {type: 'text'},
    ledger: {type: 'text'},
    state: {type: 'text'},
    result: {type: 'text'}
github mozilla / openbadges-badgekit / migrations / 20140416171703-add-badgecategories-to-badge.js View on Github external
var dbm = require('db-migrate');
var type = dbm.dataType;
var async = require('async');

exports.up = function(db, callback) {
  async.series([
    db.runSql.bind(db, "CREATE TABLE IF NOT EXISTS `badgeCategory` ("
                     + "  id BIGINT AUTO_INCREMENT PRIMARY KEY,"
                     + "  label VARCHAR(128) NOT NULL,"
                     + "  description VARCHAR(255)"
                     + ") ENGINE=InnoDB;"),
    db.runSql.bind(db, "CREATE TABLE IF NOT EXISTS `_badgeCategory` ("
                     + "  id BIGINT AUTO_INCREMENT PRIMARY KEY,"
                     + "  badgeId BIGINT NOT NULL,"
                     + "  categoryId BIGINT NOT NULL,"
                     + "  UNIQUE KEY `badge_and_category` (`badgeId`, `categoryId`),"
                     + "  UNIQUE KEY `category_and_badge` (`categoryId`, `badgeId`),"
                     + "  FOREIGN KEY (badgeId) REFERENCES `badge`(`id`) ON DELETE CASCADE,"
github mozilla / openbadges-badgekit / migrations / 20140220161432-timestamps.js View on Github external
var dbm = require('db-migrate');
var async = require('async');
var type = dbm.dataType;

exports.up = function(db, callback) {
  async.series([
    db.runSql.bind(db,        
      "ALTER TABLE `badge` "
      + "ADD `created` TIMESTAMP DEFAULT '2000-01-01 00:00:00',"
      + "ADD `lastUpdated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
    ),
    db.runSql.bind(db,        
      "ALTER TABLE `image` "
      + "ADD `lastUpdated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
      + "ADD `url` VARCHAR(255),"
      + "MODIFY `mimetype` VARCHAR(255) NULL,"
      + "MODIFY `data` LONGBLOB NULL"
    ),
    db.runSql.bind(db,
github mozilla / openbadges-badgekit / migrations / 20131209164645-initial.js View on Github external
var dbm = require('db-migrate');
var type = dbm.dataType;

exports.up = function(db, callback) {
  db.runSql("CREATE TABLE IF NOT EXISTS `badge` ("
            + "id               BIGINT AUTO_INCREMENT PRIMARY KEY,"
            + "name             VARCHAR(128) NOT NULL,"
            + "status           ENUM('draft', 'template', 'published', 'archived') NOT NULL"
            + ") ENGINE=InnoDB;", callback);
};

exports.down = function(db, callback) {
  db.runSql("DROP TABLE IF EXISTS `badge`;", callback);
};
github mozilla / openbadges-badgekit / migrations / 20140217193056-image-table.js View on Github external
var dbm = require('db-migrate');
var type = dbm.dataType;
var async = require('async');

exports.up = function(db, callback) {
  async.series([
    db.runSql.bind(db,        
      "CREATE TABLE IF NOT EXISTS `image` ("
      + "id               BIGINT AUTO_INCREMENT PRIMARY KEY,"
      + "mimetype         VARCHAR(255) NOT NULL,"
      + "data             LONGBLOB NOT NULL"
      + ") ENGINE=InnoDB"
    ),
    db.runSql.bind(db, 
      "ALTER TABLE `badge` "
      + "ADD `imageId` BIGINT,"
      + "ADD `studioShape` VARCHAR(255),"
      + "ADD `studioBackground` VARCHAR(255),"
github mozilla / openbadges-badgekit / migrations / 20140317215941-accounts.js View on Github external
var dbm = require('db-migrate');
var type = dbm.dataType;
var async = require('async');

exports.up = function(db, callback) {
  async.series([
    db.runSql.bind(db, 
      "ALTER TABLE `badge` "
      + "ADD `system` VARCHAR(255) NOT NULL DEFAULT 'badgekit',"
      + "ADD `issuer` VARCHAR(255) NULL,"
      + "ADD `program` VARCHAR(255) NULL"
    ),
    db.runSql.bind(db,        
      "CREATE TABLE IF NOT EXISTS `account` ("
      + "`id`               BIGINT AUTO_INCREMENT PRIMARY KEY,"
      + "`email`            VARCHAR(255) NOT NULL UNIQUE,"
      + "INDEX `email_idx`(`email`)"
      + ") ENGINE=InnoDB;"
github ericf / open-marriage / migrations / 20130203075859-add-guests-table.js View on Github external
var async = require('async'),
    dbm   = require('db-migrate'),
    type  = dbm.dataType;

exports.up = function (db, callback) {
    async.series([
        db.createTable.bind(db, 'guests', {
            columns: {
                id: {
                    autoIncrement: true,
                    primaryKey   : true,
                    type         : 'int'
                },

                invitation_id: 'int',

                title: {type: 'string', length: 8},
                name : {type: 'string', length: 64},
                email: {type: 'string', length: 128},
github mozilla / openbadges-badgekit / migrations / 20140122040123-initial-studio-fields.js View on Github external
var dbm = require('db-migrate');
var type = dbm.dataType;
var async = require('async');

exports.up = function(db, callback) {
  async.series([
    db.runSql.bind(db, 
      "ALTER TABLE `badge` "
      + "ADD `issuerUrl` TEXT,"
      + "ADD `earnerDescription` TEXT,"
      + "ADD `consumerDescription` TEXT,"
      + "ADD `tags` TEXT,"
      + "ADD `rubricUrl` TEXT,"
      + "ADD `timeValue` INT,"
      + "ADD `timeUnits` ENUM('minutes', 'hours', 'days', 'weeks'),"
      + "ADD `limit` INT,"
      + "ADD `multiClaimCode` TEXT,"
      + "ADD `unique` BOOL NOT NULL DEFAULT FALSE,"