You are here

node_import.install in Node import 5

Same filename and directory in other branches
  1. 6 node_import.install

File

node_import.install
View source
<?php

/* Installation of node_import */
function node_import_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret = db_query("CREATE TABLE {node_import_mappings} ( " . "type VARCHAR(16) NOT NULL DEFAULT '', " . "csv_headers TEXT NOT NULL, " . "mapping TEXT NOT NULL, " . "KEY type (type) " . ") /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $ret = db_query("CREATE TABLE {node_import_mappings} ( " . "\"type\" VARCHAR(16) NOT NULL DEFAULT '', " . "csv_headers TEXT NOT NULL, " . "mapping TEXT NOT NULL, " . "KEY \"type\" (\"type\") " . ");");
      break;
  }
  if ($ret) {
    drupal_set_message(t('The node_import database tables have been created. You can import a CSV file with <a href="@node_import-url">the node import wizard</a>.', array(
      '@node_import-url' => url('admin/content/node_import'),
    )));
  }
  else {
    drupal_set_message(t('The creation of node_import database tables has failed. Check the README.txt file in the modules/node_import directory on instructions to create the table manually.'), 'error');
  }
}

/* Uninstalling of node_import */
function node_import_uninstall() {
  db_query("DROP TABLE {node_import_mappings}");
}

/* 46 -> 47: new table */
function node_import_update_1() {
  $items = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $items[] = update_sql("CREATE TABLE {node_import_mappings} ( " . "type VARCHAR(16) NOT NULL DEFAULT '', " . "csv_headers TEXT NOT NULL, " . "mapping TEXT NOT NULL, " . "KEY type (type) " . ") /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $items[] = update_sql("CREATE TABLE {node_import_mappings} ( " . "\"type\" VARCHAR(16) NOT NULL DEFAULT '', " . "csv_headers TEXT NOT NULL, " . "mapping TEXT NOT NULL, " . "KEY \"type\" (\"type\") " . ");");
      break;
  }
  return $items;
}