You are here

node_convert.install in Node Convert 6

Same filename and directory in other branches
  1. 7 node_convert.install

The node_convert install file.

Installs necesarry tables for correct node_convert functionality

File

node_convert.install
View source
<?php

/**
 * @file
 * The node_convert install file.
 *
 * Installs necesarry tables for correct node_convert functionality
 */
function node_convert_schema() {
  $schema['node_convert_templates'] = array(
    'fields' => array(
      'nctid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'type' => 'text',
        'size' => 'small',
      ),
      'source_type' => array(
        'type' => 'text',
        'size' => 'small',
        'not null' => FALSE,
      ),
      'destination_type' => array(
        'type' => 'text',
        'size' => 'small',
        'not null' => TRUE,
      ),
      'data' => array(
        'type' => 'text',
        'size' => 'medium',
      ),
    ),
    'primary key' => array(
      'nctid',
    ),
  );
  return $schema;
}
function node_convert_install() {

  // Create my tables.
  drupal_install_schema('node_convert');
}
function node_convert_uninstall() {

  // Drop my tables.
  drupal_uninstall_schema('node_convert');
  db_query("DELETE FROM {actions} WHERE callback = 'node_convert_convert_action'");
}

/* Forgot about creating the table for those updating.
 * Note: It's ok if it tells you that the table already exists. It's part of the plan.
 * Couldn't avoid the error, but it's ok, really.
 */
function node_convert_update_6000() {
  $schema['node_convert_templates'] = array(
    'fields' => array(
      'nctid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'type' => 'text',
        'size' => 'small',
      ),
      'source_type' => array(
        'type' => 'text',
        'size' => 'small',
        'not null' => FALSE,
      ),
      'destination_type' => array(
        'type' => 'text',
        'size' => 'small',
        'not null' => TRUE,
      ),
      'data' => array(
        'type' => 'text',
        'size' => 'medium',
      ),
    ),
    'primary key' => array(
      'nctid',
    ),
  );
  $ret = array();
  db_create_table($ret, 'node_convert_templates', $schema['node_convert_templates']);
  return $ret;
}

/* Changing ctid to nctid, to prevent errors appearing on PostgreSQL installation.
 * Note: It's ok if you get an field doesn't exist error. Couldn't avoid this error either.
 */
function node_convert_update_6001() {
  $ret = array();
  db_change_field($ret, 'node_convert_templates', 'ctid', 'nctid', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ));
  return $ret;
}