protected function setUp()
 {
     parent::setUp();
     module_load_install('system');
     $schema = system_schema();
     db_create_table('key_value_expire', $schema['key_value_expire']);
 }
Example #2
0
 /**
  * Ensure that the table for an app exists.
  * @param $nid
  * The app nid.
  */
 private function ensureAppTable($nid)
 {
     if (!db_table_exists('app_' . $nid)) {
         db_create_table('app_' . $nid, $this->getAppTableSchema($nid));
     } else {
         $this->pruneAppTable($nid);
     }
 }
Example #3
0
/**
 * Setup website with assumption on blank state.
 */
function initialise_JumpStart()
{
    require_once 'include/database/database-basic.php';
    $conn = db_connect();
    // Create table for SFU
    db_create_table($conn, 'users_sfu', array("username varchar(32) UNIQUE NOT NULL", "fullname text NOT NULL", "password varchar(60) NOT NULL", "sex varchar(8) NOT NULL", "interest_1 text", "interest_2 text", "interest_3 text", "PRIMARY KEY (username)"));
    // Create table for UBC
    db_create_table($conn, 'users_ubc', array("username varchar(32) UNIQUE NOT NULL", "fullname text NOT NULL", "password varchar(60) NOT NULL", "sex varchar(8) NOT NULL", "interest_1 text", "interest_2 text", "interest_3 text", "PRIMARY KEY (username)"));
    // Users for activation
    db_create_table($conn, 'users_activate', array("username varchar(32) NOT NULL", "password varchar(60) NOT NULL", "table_name varchar(32) NOT NULL", "access_code varchar(12) NOT NULL", "PRIMARY KEY (username)"));
}
 protected function setUp()
 {
     parent::setUp();
     module_load_install('system');
     $schema = system_schema();
     db_create_table('key_value', $schema['key_value']);
     $this->container->register('database', 'Drupal\\Core\\Database\\Connection')->setFactoryClass('Drupal\\Core\\Database\\Database')->setFactoryMethod('getConnection')->addArgument('default');
     $this->container->register('keyvalue.database', 'Drupal\\Core\\KeyValueStore\\KeyValueDatabaseFactory')->addArgument(new Reference('serialization.phpserialize'))->addArgument(new Reference('database'));
     $this->container->register('serialization.phpserialize', 'Drupal\\Component\\Serialization\\PhpSerialize');
     $this->settingsSet('keyvalue_default', 'keyvalue.database');
 }
Example #5
0
/**
 * Create tables
 */
function setup_create_tables($conn = NULL)
{
    if ($conn == NULL) {
        $conn = db_connect();
    }
    db_create_table($conn, 'settings', array("vid int UNIQUE NOT NULL AUTO_INCREMENT", "type varchar(32) NOT NULL", "value varchar(64) NOT NULL", "PRIMARY KEY (vid)"));
    db_create_table($conn, 'users', array("uid int UNIQUE NOT NULL AUTO_INCREMENT", "username varchar(32) NOT NULL", "email varchar(32) NOT NULL", "password varchar(32) NOT NULL", "PRIMARY KEY (uid)"));
    db_create_table($conn, 'forms', array("fid int UNIQUE NOT NULL AUTO_INCREMENT", "status boolean DEFAULT '0' NOT NULL", "name varchar(32) NOT NULL", "date_created timestamp NOT NULL", "PRIMARY KEY (fid)"));
    db_create_table($conn, 'forms_qid', array("fid int UNIQUE NOT NULL AUTO_INCREMENT", "qid_1 int NOT NULL", "qid_2 int", "qid_3 int", "qid_4 int", "qid_5 int", "qid_6 int", "qid_7 int", "qid_8 int", "PRIMARY KEY (fid)"));
    db_create_table($conn, 'forms_questions', array("qid int UNIQUE NOT NULL AUTO_INCREMENT", "status boolean DEFAULT '0' NOT NULL", "type varchar(8) NOT NULL", "value varchar(256) NOT NULL", "PRIMARY KEY (qid)"));
}
 protected function setUp()
 {
     parent::setUp();
     // Install system tables to test the key/value storage without installing a
     // full Drupal environment.
     module_load_install('system');
     $schema = system_schema();
     db_create_table('semaphore', $schema['semaphore']);
     db_create_table('key_value_expire', $schema['key_value_expire']);
     // Create several objects for testing.
     for ($i = 0; $i <= 3; $i++) {
         $this->objects[$i] = $this->randomObject();
     }
 }
 /**
  * Tests that updates from schema versions prior to 8000 are prevented.
  */
 function testInvalidMigration()
 {
     // Mock a D7 system table so that the schema value of the system module
     // can be retrieved.
     db_create_table('system', $this->getSystemSchema());
     // Assert that the table exists.
     $this->assertTrue(db_table_exists('system'), 'The table exists.');
     // Insert a value for the system module.
     db_insert('system')->fields(array('name' => 'system', 'schema_version' => 7000))->execute();
     $system_schema = db_query('SELECT schema_version FROM {system} WHERE name = :system', array(':system' => 'system'))->fetchField();
     $this->drupalGet($this->update_url, array('external' => TRUE));
     $text = 'Your system schema version is ' . $system_schema . '. Updating directly from a schema version prior to 8000 is not supported. You must <a href="https://drupal.org/node/2179269">migrate your site to Drupal 8</a> first.';
     $this->assertRaw($text, 'Updates from schema versions prior to 8000 are prevented.');
 }
Example #8
0
 function createVolume($volume = '')
 {
     global $XPFS_DEFAULT_VOLUME;
     if ($volume == '') {
         $volume = $XPFS_DEFAULT_VOLUME;
     }
     if (db_count('xpfs_volumes', '`name`="' . addslashes($volume) . '"') > 0) {
         return false;
     }
     $name = $volume;
     $volume = 'xpfs_volume_' . $volume;
     if (!db_table_exists($volume)) {
         db_create_table($volume, array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'pid' => 'INT', 'name' => 'TEXT', 'data' => 'LONGBLOB', 'mtime' => 'INT DEFAULT 0', 'access' => 'INT DEFAULT 0', 'attr' => 'INT DEFAULT 0'));
         db_insert('xpfs_volumes', array('name' => '"' . addslashes($name) . '"'));
         db_insert($volume, array('name' => '"/"', 'pid' => 0));
         return true;
     }
     return false;
 }
Example #9
0
 function manage_check_tables()
 {
     db_create_table_safe('datatypes', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'class' => 'TEXT', 'refcount' => 'INT DEFAULT 0', 'settings' => 'TEXT DEFAULT ""'));
     db_create_table_safe('dataset', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'refcount' => 'INT DEFAULT 0'));
     db_create_table_safe('dataset_assoc', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'order' => 'INT', 'dataset' => 'INT', 'datatype' => 'INT', 'title' => 'TEXT', 'field' => 'TEXT', 'settings' => 'TEXT DEFAULT ""'));
     if (!db_table_exists('settings')) {
         db_create_table('settings', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'section' => 'TEXT', 'name' => 'TEXT', 'ident' => 'TEXT', 'class' => 'TEXT', 'used' => 'INT DEFAULT 0', 'settings' => 'TEXT DEFAULT ""'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Максимальная длина логина пользователя"', 'ident' => '"max_user_login_len"', 'class' => '"CSCNumber"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:2:"14";}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Максимальная длина имени пользователя"', 'ident' => '"max_user_name_len"', 'class' => '"CSCNumber"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:2:"32";}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Максимальная длина пароля пользователя"', 'ident' => '"max_user_passwd_len"', 'class' => '"CSCNumber"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:2:"16";}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Количество записей на странице &laquo;Пользователи и группы&raquo;"', 'ident' => '"user_count"', 'class' => '"CSCNumber"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:2:"15";}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Блокировать сайт"', 'ident' => '"site_lock"', 'class' => '"CSCCheckBox"', 'settings' => '"' . addslashes('a:1:{s:5:"value";b:0;}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Стартовый каталог"', 'ident' => '"start_root"', 'class' => '"CSCText"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:1:"/";}') . '"', 'used' => '1'));
     }
     db_create_table_safe('storage', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'path' => 'TEXT', 'refcount' => 'INT DEFAULT 0'));
     if (!db_table_exists('templates')) {
         db_create_table_safe('templates', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'text' => 'LONGTEXT', 'refcount' => 'INT DEFAULT 0', 'settings' => 'TEXT DEFAULT ""'));
     }
     manage_template_register_default();
 }
/**
 * Set up password and nonce storage.
 */
function _securesite_schema()
{
    global $db_url, $db_type;
    $schema['securesite_passwords'] = array('module' => 'securesite', 'name' => 'securesite_passwords', 'description' => 'Stores user passwords.', 'fields' => array('name' => array('type' => 'varchar', 'length' => 60, 'not null' => TRUE, 'default' => '', 'description' => "User's {users}.name."), 'realm' => array('type' => 'text', 'description' => "User's realm."), 'pass' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '', 'description' => "User's password (plain text).")), 'primary key' => array('name, realm'), 'indexes' => array('name' => array('name'), 'realm' => array('realm')));
    $schema['securesite_nonce'] = array('module' => 'securesite', 'name' => 'securesite_nonce', 'description' => 'Stores nonce values.', 'fields' => array('nonce' => array('type' => 'text', 'not null' => TRUE, 'default' => '', 'description' => 'Nonce value.'), 'qop' => array('type' => 'text', 'description' => 'Quality of protection.'), 'nc' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Number of times nonce has been used.'), 'opaque' => array('type' => 'text', 'description' => 'Opaque value.'), 'hash' => array('type' => 'text', 'description' => 'Hashed entity body to see if message was tampered with.'), 'time' => array('type' => 'int', 'description' => 'Last use timestamp.'), 'realm' => array('type' => 'text', 'description' => "Nonce realm.")), 'primary key' => array('nonce, realm'), 'indexes' => array('nonce' => array('nonce'), 'opaque' => array('opaque'), 'realm' => array('realm')));
    $ret = array();
    foreach ($schema as $name => $table) {
        $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
        $database = substr($url['path'], 1);
        switch ($db_type) {
            case 'mysql':
            case 'mysqli':
                $sql = "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '%s' AND table_name = '%s'";
                break;
            case 'pgsql':
                $sql = "SELECT COUNT(*) FROM information_schema.tables WHERE table_catalog = '%s' AND table_schema = 'public' AND table_name = '%s'";
                break;
        }
        if (db_result(db_query($sql, $database, $name)) == 0) {
            db_create_table($ret, $name, $table);
        }
    }
    return $ret;
}
/**
 * Create the batch table.
 *
 * This is part of the Drupal 5.x to 6.x migration.
 */
function update_create_batch_table()
{
    // If batch table exists, update is not necessary
    if (db_table_exists('batch')) {
        return;
    }
    $schema['batch'] = array('fields' => array('bid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'token' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE), 'timestamp' => array('type' => 'int', 'not null' => TRUE), 'batch' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')), 'primary key' => array('bid'), 'indexes' => array('token' => array('token')));
    $ret = array();
    db_create_table($ret, 'batch', $schema['batch']);
    return $ret;
}
<?php

/**
 * @file
 * Filled installation of Drupal 7.0, for test purposes.
 *
 * This file was generated by the dump-database-d7.sh tool, from an
 * installation of Drupal 7, filled with data using the generate-d7-content.sh
 * tool. It has the following modules installed:
 *  - userpoints
 */
db_create_table('userpoints', array('fields' => array('pid' => array('type' => 'serial', 'not null' => TRUE), 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'points' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'max_points' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'last_update' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'tid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)), 'primary key' => array('pid'), 'indexes' => array('last_update' => array('last_update'), 'points' => array('points')), 'unique keys' => array('uid_tid' => array('uid', 'tid')), 'module' => 'userpoints', 'name' => 'userpoints'));
db_insert('userpoints')->fields(array('pid', 'uid', 'points', 'max_points', 'last_update', 'tid'))->values(array('pid' => '1', 'uid' => '1', 'points' => '4', 'max_points' => '5', 'last_update' => '1361395354', 'tid' => '0'))->values(array('pid' => '2', 'uid' => '1', 'points' => '-1', 'max_points' => '8', 'last_update' => '1361395411', 'tid' => '2'))->values(array('pid' => '3', 'uid' => '1', 'points' => '7', 'max_points' => '7', 'last_update' => '1361395402', 'tid' => '1'))->execute();
db_create_table('userpoints_total', array('fields' => array('uid' => array('type' => 'int', 'not null' => TRUE), 'points' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'max_points' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'last_update' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)), 'primary key' => array('uid'), 'indexes' => array('last_update' => array('last_update'), 'points' => array('points')), 'module' => 'userpoints', 'name' => 'userpoints_total'));
db_insert('userpoints_total')->fields(array('uid', 'points', 'max_points', 'last_update'))->values(array('uid' => '1', 'points' => '10', 'max_points' => '19', 'last_update' => '1361395411'))->execute();
db_create_table('userpoints_txn', array('fields' => array('txn_id' => array('type' => 'serial', 'not null' => TRUE), 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'approver_uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'points' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'time_stamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'changed' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'status' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0), 'description' => array('type' => 'text'), 'reference' => array('type' => 'varchar', 'length' => 128), 'expirydate' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'expired' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0), 'parent_txn_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'tid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'entity_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'entity_type' => array('type' => 'varchar', 'length' => 128), 'operation' => array('type' => 'varchar', 'length' => 48)), 'primary key' => array('txn_id'), 'indexes' => array('operation' => array('operation'), 'reference' => array('reference'), 'status_expired_expiry' => array('status', 'expired', 'expirydate'), 'changed' => array('changed'), 'uid' => array('uid'), 'approver_uid' => array('approver_uid'), 'points' => array('points')), 'module' => 'userpoints', 'name' => 'userpoints_txn'));
db_insert('userpoints_txn')->fields(array('txn_id', 'uid', 'approver_uid', 'points', 'time_stamp', 'changed', 'status', 'description', 'reference', 'expirydate', 'expired', 'parent_txn_id', 'tid', 'entity_id', 'entity_type', 'operation'))->values(array('txn_id' => '1', 'uid' => '1', 'approver_uid' => '1', 'points' => '5', 'time_stamp' => '1361395345', 'changed' => '1361395345', 'status' => '0', 'description' => '', 'reference' => '', 'expirydate' => '0', 'expired' => '0', 'parent_txn_id' => '0', 'tid' => '0', 'entity_id' => '0', 'entity_type' => NULL, 'operation' => 'admin'))->values(array('txn_id' => '2', 'uid' => '1', 'approver_uid' => '1', 'points' => '-1', 'time_stamp' => '1361395354', 'changed' => '1361395354', 'status' => '0', 'description' => '', 'reference' => '', 'expirydate' => '0', 'expired' => '0', 'parent_txn_id' => '0', 'tid' => '0', 'entity_id' => '0', 'entity_type' => NULL, 'operation' => 'admin'))->values(array('txn_id' => '3', 'uid' => '1', 'approver_uid' => '1', 'points' => '-3', 'time_stamp' => '1361395364', 'changed' => '1361395364', 'status' => '0', 'description' => '', 'reference' => '', 'expirydate' => '0', 'expired' => '0', 'parent_txn_id' => '0', 'tid' => '2', 'entity_id' => '0', 'entity_type' => NULL, 'operation' => 'admin'))->values(array('txn_id' => '4', 'uid' => '1', 'approver_uid' => '1', 'points' => '1', 'time_stamp' => '1361395371', 'changed' => '1361395371', 'status' => '0', 'description' => '', 'reference' => '', 'expirydate' => '0', 'expired' => '0', 'parent_txn_id' => '0', 'tid' => '2', 'entity_id' => '0', 'entity_type' => NULL, 'operation' => 'admin'))->values(array('txn_id' => '5', 'uid' => '1', 'approver_uid' => '1', 'points' => '5', 'time_stamp' => '1361395380', 'changed' => '1361395380', 'status' => '0', 'description' => '', 'reference' => '', 'expirydate' => '0', 'expired' => '0', 'parent_txn_id' => '0', 'tid' => '1', 'entity_id' => '0', 'entity_type' => NULL, 'operation' => 'admin'))->values(array('txn_id' => '6', 'uid' => '1', 'approver_uid' => '1', 'points' => '10', 'time_stamp' => '1361395390', 'changed' => '1361395390', 'status' => '0', 'description' => '', 'reference' => '', 'expirydate' => '0', 'expired' => '0', 'parent_txn_id' => '0', 'tid' => '2', 'entity_id' => '0', 'entity_type' => NULL, 'operation' => 'admin'))->values(array('txn_id' => '7', 'uid' => '1', 'approver_uid' => '1', 'points' => '2', 'time_stamp' => '1361395402', 'changed' => '1361395402', 'status' => '0', 'description' => '', 'reference' => '', 'expirydate' => '0', 'expired' => '0', 'parent_txn_id' => '0', 'tid' => '1', 'entity_id' => '0', 'entity_type' => NULL, 'operation' => 'admin'))->values(array('txn_id' => '8', 'uid' => '1', 'approver_uid' => '1', 'points' => '-9', 'time_stamp' => '1361395411', 'changed' => '1361395411', 'status' => '0', 'description' => '', 'reference' => '', 'expirydate' => '0', 'expired' => '0', 'parent_txn_id' => '0', 'tid' => '2', 'entity_id' => '0', 'entity_type' => NULL, 'operation' => 'admin'))->execute();
db_insert('system')->fields(array('name', 'filename', 'type', 'owner', 'bootstrap', 'weight', 'schema_version', 'status'))->values(array('name' => 'userpoints', 'filename' => drupal_get_path('module', 'userpoints') . '/userpoints.module', 'type' => 'module', 'owner' => '', 'bootstrap' => 0, 'weight' => 0, 'schema_version' => '7199', 'status' => 1))->values(array('name' => 'entity', 'filename' => drupal_get_path('module', 'entity') . '/entity.module', 'type' => 'module', 'owner' => '', 'bootstrap' => 0, 'weight' => 0, 'schema_version' => '7002', 'status' => 1))->execute();
Example #13
0
  * *****
  * *****                           Add all new fields above
  * *****
  * ************************************************************************************* */
 $createTables = true;
 if (isset($_GET['create']) || isset($_GET['update']) || isset($_GET['protect_files']) && db_connect($_zp_conf_vars)) {
     if (!isset($_GET['protect_files'])) {
         if ($taskDisplay[substr($task, 0, 8)] == 'create') {
             echo "<h3>" . gettext("About to create tables") . "...</h3>";
         } else {
             echo "<h3>" . gettext("About to update tables") . "...</h3>";
         }
         setupLog(gettext("Begin table creation"));
         foreach ($db_schema as $sql) {
             @set_time_limit(60);
             $result = db_create_table($sql);
             echo ' ';
             // keep alive
             if (!$result) {
                 $createTables = false;
                 setupLog(sprintf(gettext('Query %1$s Failed. Error: %2$s'), $sql, db_error()));
                 echo '<div class="error">';
                 echo sprintf(gettext('Table creation failure:<br />Query: %1$s<br />Error: %2$s'), $sql, db_error());
                 echo '</div>';
             } else {
                 setupLog(sprintf(gettext('Query ( %s ) Success.'), $sql));
             }
         }
         // always run the update queries to insure the tables are up to current level
         setupLog(gettext("Begin table updates"));
         foreach ($sql_statements as $sql) {
<?php

/**
 * @file
 * Test content for the trigger upgrade path.
 */
db_create_table('trigger_assignments', array('fields' => array('hook' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), 'op' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), 'aid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)), 'primary key' => array('hook', 'op', 'aid'), 'module' => 'trigger', 'name' => 'trigger_assignments'));
// Add several trigger configurations.
db_insert('trigger_assignments')->fields(array('hook', 'op', 'aid', 'weight'))->values(array('hook' => 'node', 'op' => 'presave', 'aid' => 'node_publish_action', 'weight' => '1'))->values(array('hook' => 'comment', 'op' => 'presave', 'aid' => 'comment_publish_action', 'weight' => '1'))->values(array('hook' => 'comment_delete', 'op' => 'presave', 'aid' => 'node_save_action', 'weight' => '1'))->values(array('hook' => 'nodeapi', 'op' => 'presave', 'aid' => 'node_make_sticky_action', 'weight' => '1'))->values(array('hook' => 'nodeapi', 'op' => 'somehow_nodeapi_got_a_very_long', 'aid' => 'node_save_action', 'weight' => '1'))->execute();
db_update('system')->fields(array('schema_version' => '6000', 'status' => '1'))->condition('filename', 'modules/trigger/trigger.module')->execute();
Example #15
0
function update_structure($verbose, $action)
{
    global $a, $db;
    $errors = false;
    logger('updating structure', LOGGER_DEBUG);
    // Get the current structure
    $database = array();
    $tables = q("show tables");
    foreach ($tables as $table) {
        $table = current($table);
        $database[$table] = table_structure($table);
    }
    // Get the definition
    $definition = db_definition();
    // Compare it
    foreach ($definition as $name => $structure) {
        $sql3 = "";
        if (!isset($database[$name])) {
            $r = db_create_table($name, $structure["fields"], $verbose, $action);
            if (false === $r) {
                $errors .= t('Errors encountered creating database tables.') . $name . EOL;
            }
        } else {
            // Drop the index if it isn't present in the definition
            foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
                if (!isset($structure["indexes"][$indexname])) {
                    $sql2 = db_drop_index($indexname);
                    if ($sql3 == "") {
                        $sql3 = "ALTER TABLE `" . $name . "` " . $sql2;
                    } else {
                        $sql3 .= ", " . $sql2;
                    }
                }
            }
            // Compare the field structure field by field
            foreach ($structure["fields"] as $fieldname => $parameters) {
                if (!isset($database[$name]["fields"][$fieldname])) {
                    $sql2 = db_add_table_field($fieldname, $parameters);
                    if ($sql3 == "") {
                        $sql3 = "ALTER TABLE `" . $name . "` " . $sql2;
                    } else {
                        $sql3 .= ", " . $sql2;
                    }
                } else {
                    // Compare the field definition
                    $current_field_definition = implode(",", $database[$name]["fields"][$fieldname]);
                    $new_field_definition = implode(",", $parameters);
                    if ($current_field_definition != $new_field_definition) {
                        $sql2 = db_modify_table_field($fieldname, $parameters);
                        if ($sql3 == "") {
                            $sql3 = "ALTER TABLE `" . $name . "` " . $sql2;
                        } else {
                            $sql3 .= ", " . $sql2;
                        }
                    }
                }
            }
        }
        // Create the index
        foreach ($structure["indexes"] as $indexname => $fieldnames) {
            if (!isset($database[$name]["indexes"][$indexname])) {
                $sql2 = db_create_index($indexname, $fieldnames);
                if ($sql2 != "") {
                    if ($sql3 == "") {
                        $sql3 = "ALTER TABLE `" . $name . "` " . $sql2;
                    } else {
                        $sql3 .= ", " . $sql2;
                    }
                }
            }
        }
        if ($sql3 != "") {
            $sql3 .= ";";
            if ($verbose) {
                echo $sql3 . "\n";
            }
            if ($action) {
                $r = @$db->q($sql3);
                if (false === $r) {
                    $errors .= t('Errors encountered performing database changes.') . $sql3 . EOL;
                }
            }
        }
    }
    return $errors;
}
<?php

/**
 * Database additions for forum tests.
 */
db_create_table('forum', array('fields' => array('nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)), 'indexes' => array('nid' => array('nid'), 'tid' => array('tid')), 'primary key' => array('vid'), 'module' => 'forum', 'name' => 'forum'));
db_insert('forum')->fields(array('nid', 'vid', 'tid'))->values(array('nid' => '51', 'vid' => '61', 'tid' => '81'))->execute();
db_insert('node')->fields(array('nid', 'vid', 'type', 'language', 'title', 'uid', 'status', 'created', 'changed', 'comment', 'promote', 'moderate', 'sticky', 'tnid', 'translate'))->values(array('nid' => '51', 'vid' => '61', 'type' => 'forum', 'language' => '', 'title' => 'Apples', 'uid' => '1', 'status' => '1', 'created' => '1298363952', 'changed' => '1298363952', 'comment' => '2', 'promote' => '0', 'moderate' => '0', 'sticky' => '0', 'tnid' => '0', 'translate' => '0'))->execute();
db_insert('node_revisions')->fields(array('nid', 'vid', 'uid', 'title', 'body', 'teaser', 'log', 'timestamp', 'format'))->values(array('nid' => '51', 'vid' => '61', 'uid' => '1', 'title' => 'Apples', 'body' => 'A fruit.', 'teaser' => 'A fruit.', 'log' => '', 'timestamp' => '1298363952', 'format' => '1'))->execute();
db_insert('node_comment_statistics')->fields(array('nid', 'last_comment_timestamp', 'last_comment_name', 'last_comment_uid', 'comment_count'))->values(array('nid' => '51', 'last_comment_timestamp' => '1298363952', 'last_comment_name' => NULL, 'last_comment_uid' => '1', 'comment_count' => '0'))->execute();
db_insert('node_type')->fields(array('type', 'name', 'module', 'description', 'help', 'has_title', 'title_label', 'has_body', 'body_label', 'min_word_count', 'custom', 'modified', 'locked', 'orig_type'))->values(array('type' => 'forum', 'name' => 'Forum topic', 'module' => 'forum', 'description' => 'A <em>forum topic</em> is the initial post to a new discussion thread within a forum.', 'help' => '', 'has_title' => '1', 'title_label' => 'Subject', 'has_body' => '1', 'body_label' => 'Body', 'min_word_count' => '0', 'custom' => '0', 'modified' => '0', 'locked' => '1', 'orig_type' => 'forum'))->execute();
db_update('system')->fields(array('schema_version' => '6000', 'status' => '1'))->condition('filename', 'modules/forum/forum.module')->execute();
db_insert('term_data')->fields(array('tid', 'vid', 'name', 'description', 'weight'))->values(array('tid' => '81', 'vid' => '101', 'name' => 'Fruits', 'description' => 'Fruits.', 'weight' => '0'))->execute();
db_insert('term_hierarchy')->fields(array('tid', 'parent'))->values(array('tid' => '81', 'parent' => '0'))->execute();
db_insert('term_node')->fields(array('nid', 'vid', 'tid'))->values(array('nid' => '51', 'vid' => '61', 'tid' => '81'))->execute();
db_insert('variable')->fields(array('name', 'value'))->values(array('name' => 'forum_nav_vocabulary', 'value' => 's:3:"101";'))->values(array('name' => 'forum_containers', 'value' => 'a:1:{i:0;s:3:"101";}'))->execute();
db_insert('vocabulary')->fields(array('vid', 'name', 'description', 'help', 'relations', 'hierarchy', 'multiple', 'required', 'tags', 'module', 'weight'))->values(array('vid' => '101', 'name' => 'Upgrade test for forums', 'description' => 'Vocabulary used for Forums. The name is changed from the default "Forums" so that the upgrade path may be tested.', 'help' => '', 'relations' => '1', 'hierarchy' => '1', 'multiple' => '0', 'required' => '0', 'tags' => '0', 'module' => 'forum', 'weight' => '-10'))->execute();
db_insert('vocabulary_node_types')->fields(array('vid', 'type'))->values(array('vid' => '101', 'type' => 'forum'))->execute();
// Provide all users with the ability to create forum topics.
$results = db_select('permission', 'p')->fields('p')->execute();
foreach ($results as $result) {
    $permissions = $result->perm . ', create forum topics';
    db_update('permission')->fields(array('perm' => $permissions))->condition('rid', $result->rid)->execute();
}
Example #17
0
db_insert('simplenews_mail_spool')->fields(array('msid', 'mail', 'nid', 'vid', 'tid', 'status', 'error', 'timestamp'))->values(array('msid' => '1', 'mail' => '*****@*****.**', 'nid' => '1', 'vid' => '1', 'tid' => '2', 'status' => '1', 'error' => '1', 'timestamp' => '1322835116'))->values(array('msid' => '2', 'mail' => '*****@*****.**', 'nid' => '1', 'vid' => '1', 'tid' => '2', 'status' => '1', 'error' => '1', 'timestamp' => '1322835116'))->values(array('msid' => '3', 'mail' => '*****@*****.**', 'nid' => '1', 'vid' => '1', 'tid' => '2', 'status' => '1', 'error' => '1', 'timestamp' => '1322835116'))->execute();
db_create_table('simplenews_newsletters', array('fields' => array('nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'vid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'tid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 's_status' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0), 's_format' => array('type' => 'varchar', 'length' => 8, 'not null' => TRUE, 'default' => ''), 'priority' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0), 'receipt' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)), 'primary key' => array('nid'), 'module' => 'simplenews', 'name' => 'simplenews_newsletters'));
db_insert('simplenews_newsletters')->fields(array('nid', 'vid', 'tid', 's_status', 's_format', 'priority', 'receipt'))->values(array('nid' => '1', 'vid' => '1', 'tid' => '2', 's_status' => '1', 's_format' => 'plain', 'priority' => '0', 'receipt' => '0'))->execute();
db_create_table('simplenews_snid_tid', array('fields' => array('snid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'tid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)), 'primary key' => array('snid', 'tid'), 'module' => 'simplenews', 'name' => 'simplenews_snid_tid'));
db_insert('simplenews_snid_tid')->fields(array('snid', 'tid'))->values(array('snid' => '1', 'tid' => '2'))->values(array('snid' => '2', 'tid' => '2'))->values(array('snid' => '3', 'tid' => '2'))->execute();
db_create_table('simplenews_subscriptions', array('fields' => array('snid' => array('type' => 'serial', 'not null' => TRUE), 'activated' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0), 'mail' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''), 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'language' => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => '')), 'indexes' => array('mail' => array('mail'), 'uid' => array('uid')), 'primary key' => array('snid'), 'module' => 'simplenews', 'name' => 'simplenews_subscriptions'));
db_insert('simplenews_subscriptions')->fields(array('snid', 'activated', 'mail', 'uid', 'language'))->values(array('snid' => '1', 'activated' => '1', 'mail' => '*****@*****.**', 'uid' => '0', 'language' => ''))->values(array('snid' => '2', 'activated' => '1', 'mail' => '*****@*****.**', 'uid' => '0', 'language' => ''))->values(array('snid' => '3', 'activated' => '1', 'mail' => '*****@*****.**', 'uid' => '0', 'language' => ''))->execute();
db_create_table('system', array('fields' => array('filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'type' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'owner' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'status' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'throttle' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'bootstrap' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'schema_version' => array('type' => 'int', 'not null' => TRUE, 'default' => -1, 'size' => 'small'), 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'info' => array('type' => 'text', 'not null' => FALSE)), 'primary key' => array('filename'), 'indexes' => array('modules' => array(array('type', 12), 'status', 'weight', 'filename'), 'bootstrap' => array(array('type', 12), 'status', 'bootstrap', 'weight', 'filename'), 'type_name' => array(array('type', 12), 'name')), 'module' => 'system', 'name' => 'system'));
db_insert('system')->fields(array('filename', 'name', 'type', 'owner', 'status', 'throttle', 'bootstrap', 'schema_version', 'weight', 'info'))->values(array('filename' => 'themes/pushbutton/pushbutton.info', 'name' => 'pushbutton', 'type' => 'theme', 'owner' => 'themes/engines/phptemplate/phptemplate.engine', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:13:{s:4:"name";s:10:"Pushbutton";s:11:"description";s:52:"Tabled, multi-column theme in blue and orange tones.";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:6:"engine";s:11:"phptemplate";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:7:"regions";a:5:{s:4:"left";s:12:"Left sidebar";s:5:"right";s:13:"Right sidebar";s:7:"content";s:7:"Content";s:6:"header";s:6:"Header";s:6:"footer";s:6:"Footer";}s:8:"features";a:10:{i:0;s:20:"comment_user_picture";i:1;s:7:"favicon";i:2;s:7:"mission";i:3;s:4:"logo";i:4;s:4:"name";i:5;s:17:"node_user_picture";i:6;s:6:"search";i:7;s:6:"slogan";i:8;s:13:"primary_links";i:9;s:15:"secondary_links";}s:11:"stylesheets";a:1:{s:3:"all";a:1:{s:9:"style.css";s:27:"themes/pushbutton/style.css";}}s:7:"scripts";a:1:{s:9:"script.js";s:27:"themes/pushbutton/script.js";}s:10:"screenshot";s:32:"themes/pushbutton/screenshot.png";s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'themes/chameleon/marvin/marvin.info', 'name' => 'marvin', 'type' => 'theme', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:13:{s:4:"name";s:6:"Marvin";s:11:"description";s:31:"Boxy tabled theme in all grays.";s:7:"regions";a:2:{s:4:"left";s:12:"Left sidebar";s:5:"right";s:13:"Right sidebar";}s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:10:"base theme";s:9:"chameleon";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:8:"features";a:10:{i:0;s:20:"comment_user_picture";i:1;s:7:"favicon";i:2;s:7:"mission";i:3;s:4:"logo";i:4;s:4:"name";i:5;s:17:"node_user_picture";i:6;s:6:"search";i:7;s:6:"slogan";i:8;s:13:"primary_links";i:9;s:15:"secondary_links";}s:11:"stylesheets";a:1:{s:3:"all";a:1:{s:9:"style.css";s:33:"themes/chameleon/marvin/style.css";}}s:7:"scripts";a:1:{s:9:"script.js";s:33:"themes/chameleon/marvin/script.js";}s:10:"screenshot";s:38:"themes/chameleon/marvin/screenshot.png";s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'themes/chameleon/chameleon.info', 'name' => 'chameleon', 'type' => 'theme', 'owner' => 'themes/chameleon/chameleon.theme', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:12:{s:4:"name";s:9:"Chameleon";s:11:"description";s:42:"Minimalist tabled theme with light colors.";s:7:"regions";a:2:{s:4:"left";s:12:"Left sidebar";s:5:"right";s:13:"Right sidebar";}s:8:"features";a:4:{i:0;s:4:"logo";i:1;s:7:"favicon";i:2;s:4:"name";i:3;s:6:"slogan";}s:11:"stylesheets";a:1:{s:3:"all";a:2:{s:9:"style.css";s:26:"themes/chameleon/style.css";s:10:"common.css";s:27:"themes/chameleon/common.css";}}s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:7:"scripts";a:1:{s:9:"script.js";s:26:"themes/chameleon/script.js";}s:10:"screenshot";s:31:"themes/chameleon/screenshot.png";s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'themes/bluemarine/bluemarine.info', 'name' => 'bluemarine', 'type' => 'theme', 'owner' => 'themes/engines/phptemplate/phptemplate.engine', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:13:{s:4:"name";s:10:"Bluemarine";s:11:"description";s:66:"Table-based multi-column theme with a marine and ash color scheme.";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:6:"engine";s:11:"phptemplate";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:7:"regions";a:5:{s:4:"left";s:12:"Left sidebar";s:5:"right";s:13:"Right sidebar";s:7:"content";s:7:"Content";s:6:"header";s:6:"Header";s:6:"footer";s:6:"Footer";}s:8:"features";a:10:{i:0;s:20:"comment_user_picture";i:1;s:7:"favicon";i:2;s:7:"mission";i:3;s:4:"logo";i:4;s:4:"name";i:5;s:17:"node_user_picture";i:6;s:6:"search";i:7;s:6:"slogan";i:8;s:13:"primary_links";i:9;s:15:"secondary_links";}s:11:"stylesheets";a:1:{s:3:"all";a:1:{s:9:"style.css";s:27:"themes/bluemarine/style.css";}}s:7:"scripts";a:1:{s:9:"script.js";s:27:"themes/bluemarine/script.js";}s:10:"screenshot";s:32:"themes/bluemarine/screenshot.png";s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'themes/garland/minnelli/minnelli.info', 'name' => 'minnelli', 'type' => 'theme', 'owner' => 'themes/engines/phptemplate/phptemplate.engine', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:14:{s:4:"name";s:8:"Minnelli";s:11:"description";s:56:"Tableless, recolorable, multi-column, fixed width theme.";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:10:"base theme";s:7:"garland";s:11:"stylesheets";a:1:{s:3:"all";a:1:{s:12:"minnelli.css";s:36:"themes/garland/minnelli/minnelli.css";}}s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:7:"regions";a:5:{s:4:"left";s:12:"Left sidebar";s:5:"right";s:13:"Right sidebar";s:7:"content";s:7:"Content";s:6:"header";s:6:"Header";s:6:"footer";s:6:"Footer";}s:8:"features";a:10:{i:0;s:20:"comment_user_picture";i:1;s:7:"favicon";i:2;s:7:"mission";i:3;s:4:"logo";i:4;s:4:"name";i:5;s:17:"node_user_picture";i:6;s:6:"search";i:7;s:6:"slogan";i:8;s:13:"primary_links";i:9;s:15:"secondary_links";}s:7:"scripts";a:1:{s:9:"script.js";s:33:"themes/garland/minnelli/script.js";}s:10:"screenshot";s:38:"themes/garland/minnelli/screenshot.png";s:3:"php";s:5:"4.3.5";s:6:"engine";s:11:"phptemplate";}'))->values(array('filename' => 'themes/garland/garland.info', 'name' => 'garland', 'type' => 'theme', 'owner' => 'themes/engines/phptemplate/phptemplate.engine', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:13:{s:4:"name";s:7:"Garland";s:11:"description";s:66:"Tableless, recolorable, multi-column, fluid width theme (default).";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:6:"engine";s:11:"phptemplate";s:11:"stylesheets";a:2:{s:3:"all";a:1:{s:9:"style.css";s:24:"themes/garland/style.css";}s:5:"print";a:1:{s:9:"print.css";s:24:"themes/garland/print.css";}}s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:7:"regions";a:5:{s:4:"left";s:12:"Left sidebar";s:5:"right";s:13:"Right sidebar";s:7:"content";s:7:"Content";s:6:"header";s:6:"Header";s:6:"footer";s:6:"Footer";}s:8:"features";a:10:{i:0;s:20:"comment_user_picture";i:1;s:7:"favicon";i:2;s:7:"mission";i:3;s:4:"logo";i:4;s:4:"name";i:5;s:17:"node_user_picture";i:6;s:6:"search";i:7;s:6:"slogan";i:8;s:13:"primary_links";i:9;s:15:"secondary_links";}s:7:"scripts";a:1:{s:9:"script.js";s:24:"themes/garland/script.js";}s:10:"screenshot";s:29:"themes/garland/screenshot.png";s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/system/system.module', 'name' => 'system', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '6055', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:6:"System";s:11:"description";s:54:"Handles general site configuration for administrators.";s:7:"package";s:15:"Core - required";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/aggregator/aggregator.module', 'name' => 'aggregator', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:10:"Aggregator";s:11:"description";s:57:"Aggregates syndicated content (RSS, RDF, and Atom feeds).";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/block/block.module', 'name' => 'block', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '0', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:5:"Block";s:11:"description";s:62:"Controls the boxes that are displayed around the main content.";s:7:"package";s:15:"Core - required";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/blog/blog.module', 'name' => 'blog', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:4:"Blog";s:11:"description";s:69:"Enables keeping easily and regularly updated user web pages or blogs.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/blogapi/blogapi.module', 'name' => 'blogapi', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:8:"Blog API";s:11:"description";s:79:"Allows users to post content using applications that support XML-RPC blog APIs.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/book/book.module', 'name' => 'book', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:4:"Book";s:11:"description";s:63:"Allows users to structure site pages in a hierarchy or outline.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/color/color.module', 'name' => 'color', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '6001', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:5:"Color";s:11:"description";s:61:"Allows the user to change the color scheme of certain themes.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/comment/comment.module', 'name' => 'comment', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '6003', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:7:"Comment";s:11:"description";s:57:"Allows users to comment on and discuss published content.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/contact/contact.module', 'name' => 'contact', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:7:"Contact";s:11:"description";s:61:"Enables the use of both personal and site-wide contact forms.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/dblog/dblog.module', 'name' => 'dblog', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '6000', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:16:"Database logging";s:11:"description";s:47:"Logs and records system events to the database.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/filter/filter.module', 'name' => 'filter', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '0', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:6:"Filter";s:11:"description";s:60:"Handles the filtering of content in preparation for display.";s:7:"package";s:15:"Core - required";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/forum/forum.module', 'name' => 'forum', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:5:"Forum";s:11:"description";s:50:"Enables threaded discussions about general topics.";s:12:"dependencies";a:2:{i:0;s:8:"taxonomy";i:1;s:7:"comment";}s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/help/help.module', 'name' => 'help', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '0', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:4:"Help";s:11:"description";s:35:"Manages the display of online help.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/locale/locale.module', 'name' => 'locale', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:6:"Locale";s:11:"description";s:119:"Adds language handling functionality and enables the translation of the user interface to languages other than English.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/menu/menu.module', 'name' => 'menu', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '0', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:4:"Menu";s:11:"description";s:60:"Allows administrators to customize the site navigation menu.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/node/node.module', 'name' => 'node', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '0', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:4:"Node";s:11:"description";s:66:"Allows content to be submitted to the site and displayed on pages.";s:7:"package";s:15:"Core - required";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/openid/openid.module', 'name' => 'openid', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:6:"OpenID";s:11:"description";s:48:"Allows users to log into your site using OpenID.";s:7:"version";s:4:"6.22";s:7:"package";s:15:"Core - optional";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/path/path.module', 'name' => 'path', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:4:"Path";s:11:"description";s:28:"Allows users to rename URLs.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/php/php.module', 'name' => 'php', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:10:"PHP filter";s:11:"description";s:50:"Allows embedded PHP code/snippets to be evaluated.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/ping/ping.module', 'name' => 'ping', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:4:"Ping";s:11:"description";s:51:"Alerts other sites when your site has been updated.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/poll/poll.module', 'name' => 'poll', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:4:"Poll";s:11:"description";s:95:"Allows your site to capture votes on different topics in the form of multiple choice questions.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/profile/profile.module', 'name' => 'profile', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:7:"Profile";s:11:"description";s:36:"Supports configurable user profiles.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/search/search.module', 'name' => 'search', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:6:"Search";s:11:"description";s:36:"Enables site-wide keyword searching.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'sites/all/modules/simplenews/simplenews.module', 'name' => 'simplenews', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '6201', 'weight' => '0', 'info' => 'a:8:{s:4:"name";s:10:"Simplenews";s:11:"description";s:47:"Send newsletters to subscribed email addresses.";s:12:"dependencies";a:1:{i:0;s:8:"taxonomy";}s:7:"package";s:4:"Mail";s:4:"core";s:3:"6.x";s:10:"dependents";a:0:{}s:7:"version";N;s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'sites/all/modules/simplenews/simplenews_action/simplenews_action.module', 'name' => 'simplenews_action', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '0', 'weight' => '0', 'info' => 'a:8:{s:4:"name";s:17:"Simplenews action";s:11:"description";s:31:"Provide actions for Simplenews.";s:12:"dependencies";a:2:{i:0;s:10:"simplenews";i:1;s:7:"trigger";}s:7:"package";s:4:"Mail";s:4:"core";s:3:"6.x";s:10:"dependents";a:0:{}s:7:"version";N;s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/statistics/statistics.module', 'name' => 'statistics', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:10:"Statistics";s:11:"description";s:37:"Logs access statistics for your site.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/syslog/syslog.module', 'name' => 'syslog', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:6:"Syslog";s:11:"description";s:41:"Logs and records system events to syslog.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/taxonomy/taxonomy.module', 'name' => 'taxonomy', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '0', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:8:"Taxonomy";s:11:"description";s:38:"Enables the categorization of content.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/throttle/throttle.module', 'name' => 'throttle', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:8:"Throttle";s:11:"description";s:66:"Handles the auto-throttling mechanism, to control site congestion.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/tracker/tracker.module', 'name' => 'tracker', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:7:"Tracker";s:11:"description";s:43:"Enables tracking of recent posts for users.";s:12:"dependencies";a:1:{i:0;s:7:"comment";}s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/translation/translation.module', 'name' => 'translation', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:19:"Content translation";s:11:"description";s:57:"Allows content to be translated into different languages.";s:12:"dependencies";a:1:{i:0;s:6:"locale";}s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/trigger/trigger.module', 'name' => 'trigger', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '0', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:7:"Trigger";s:11:"description";s:90:"Enables actions to be fired on certain system events, such as when new content is created.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/update/update.module', 'name' => 'update', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '6000', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:13:"Update status";s:11:"description";s:88:"Checks the status of available updates for Drupal and your installed modules and themes.";s:7:"version";s:4:"6.22";s:7:"package";s:15:"Core - optional";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/upload/upload.module', 'name' => 'upload', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '-1', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:6:"Upload";s:11:"description";s:51:"Allows users to upload and attach files to content.";s:7:"package";s:15:"Core - optional";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'modules/user/user.module', 'name' => 'user', 'type' => 'module', 'owner' => '', 'status' => '1', 'throttle' => '0', 'bootstrap' => '0', 'schema_version' => '0', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:4:"User";s:11:"description";s:47:"Manages the user registration and login system.";s:7:"package";s:15:"Core - required";s:7:"version";s:4:"6.22";s:4:"core";s:3:"6.x";s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1306357015";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->values(array('filename' => 'sites/all/modules/admin_menu/admin_menu.module', 'name' => 'admin_menu', 'type' => 'module', 'owner' => '', 'status' => '0', 'throttle' => '0', 'bootstrap' => '1', 'schema_version' => '6001', 'weight' => '0', 'info' => 'a:10:{s:4:"name";s:19:"Administration menu";s:11:"description";s:123:"Provides a dropdown menu to most administrative tasks and other common destinations (to users with the proper permissions).";s:7:"package";s:14:"Administration";s:4:"core";s:3:"6.x";s:7:"version";s:7:"6.x-1.8";s:7:"project";s:10:"admin_menu";s:9:"datestamp";s:10:"1308238014";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}'))->execute();
db_create_table('term_data', array('fields' => array('tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'description' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'), 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')), 'primary key' => array('tid'), 'indexes' => array('taxonomy_tree' => array('vid', 'weight', 'name'), 'vid_name' => array('vid', 'name')), 'module' => 'taxonomy', 'name' => 'term_data'));
db_insert('term_data')->fields(array('tid', 'vid', 'name', 'description', 'weight'))->values(array('tid' => '1', 'vid' => '1', 'name' => 'Drupal 6 newsletter', 'description' => '', 'weight' => '0'))->values(array('tid' => '2', 'vid' => '1', 'name' => 'Test newsletter', 'description' => '', 'weight' => '0'))->execute();
db_create_table('term_hierarchy', array('fields' => array('tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'parent' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)), 'indexes' => array('parent' => array('parent')), 'primary key' => array('tid', 'parent'), 'module' => 'taxonomy', 'name' => 'term_hierarchy'));
db_insert('term_hierarchy')->fields(array('tid', 'parent'))->values(array('tid' => '1', 'parent' => '0'))->values(array('tid' => '2', 'parent' => '0'))->execute();
db_create_table('term_node', array('fields' => array('nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)), 'indexes' => array('vid' => array('vid'), 'nid' => array('nid')), 'primary key' => array('tid', 'vid'), 'module' => 'taxonomy', 'name' => 'term_node'));
db_insert('term_node')->fields(array('nid', 'vid', 'tid'))->values(array('nid' => '1', 'vid' => '1', 'tid' => '2'))->execute();
db_create_table('term_relation', array('fields' => array('trid' => array('type' => 'serial', 'not null' => TRUE), 'tid1' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'tid2' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)), 'unique keys' => array('tid1_tid2' => array('tid1', 'tid2')), 'indexes' => array('tid2' => array('tid2')), 'primary key' => array('trid'), 'module' => 'taxonomy', 'name' => 'term_relation'));
db_create_table('term_synonym', array('fields' => array('tsid' => array('type' => 'serial', 'not null' => TRUE), 'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')), 'indexes' => array('tid' => array('tid'), 'name_tid' => array('name', 'tid')), 'primary key' => array('tsid'), 'module' => 'taxonomy', 'name' => 'term_synonym'));
db_create_table('trigger_assignments', array('fields' => array('hook' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), 'op' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), 'aid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)), 'primary key' => array('hook', 'op', 'aid'), 'module' => 'trigger', 'name' => 'trigger_assignments'));
db_create_table('url_alias', array('fields' => array('pid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'src' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'dst' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'language' => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => '')), 'unique keys' => array('dst_language_pid' => array('dst', 'language', 'pid')), 'primary key' => array('pid'), 'indexes' => array('src_language_pid' => array('src', 'language', 'pid')), 'module' => 'system', 'name' => 'url_alias'));
db_create_table('users', array('fields' => array('uid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'name' => array('type' => 'varchar', 'length' => 60, 'not null' => TRUE, 'default' => ''), 'pass' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), 'mail' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'default' => ''), 'mode' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'sort' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'size' => 'tiny'), 'threshold' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'size' => 'tiny'), 'theme' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'signature' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'signature_format' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0), 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'access' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'login' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'status' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'timezone' => array('type' => 'varchar', 'length' => 8, 'not null' => FALSE), 'language' => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''), 'picture' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'init' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'default' => ''), 'data' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')), 'indexes' => array('access' => array('access'), 'created' => array('created'), 'mail' => array('mail')), 'unique keys' => array('name' => array('name')), 'primary key' => array('uid'), 'module' => 'user', 'name' => 'users'));
db_insert('users')->fields(array('uid', 'name', 'pass', 'mail', 'mode', 'sort', 'threshold', 'theme', 'signature', 'signature_format', 'created', 'access', 'login', 'status', 'timezone', 'language', 'picture', 'init', 'data'))->values(array('uid' => 1, 'name' => '', 'pass' => '', 'mail' => '', 'mode' => '0', 'sort' => '0', 'threshold' => '0', 'theme' => '', 'signature' => '', 'signature_format' => '0', 'created' => '0', 'access' => '0', 'login' => '0', 'status' => '0', 'timezone' => NULL, 'language' => '', 'picture' => '', 'init' => '', 'data' => NULL))->values(array('uid' => 2, 'name' => 'Administrator', 'pass' => '86204017212352c8dd43f938ec53c87d', 'mail' => '*****@*****.**', 'mode' => '0', 'sort' => '0', 'threshold' => '0', 'theme' => '', 'signature' => '', 'signature_format' => '0', 'created' => '1322833849', 'access' => '1322835128', 'login' => '1322833877', 'status' => '1', 'timezone' => NULL, 'language' => '', 'picture' => '', 'init' => '*****@*****.**', 'data' => 'a:0:{}'))->execute();
db_query('UPDATE {users} SET uid = uid - 1');
db_create_table('users_roles', array('fields' => array('uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'rid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)), 'primary key' => array('uid', 'rid'), 'indexes' => array('rid' => array('rid')), 'module' => 'user', 'name' => 'users_roles'));
db_create_table('variable', array('fields' => array('name' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'value' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big')), 'primary key' => array('name'), 'module' => 'system', 'name' => 'variable'));
db_insert('variable')->fields(array('name', 'value'))->values(array('name' => 'theme_default', 'value' => 's:7:"garland";'))->values(array('name' => 'filter_html_1', 'value' => 'i:1;'))->values(array('name' => 'node_options_forum', 'value' => 'a:1:{i:0;s:6:"status";}'))->values(array('name' => 'drupal_private_key', 'value' => 's:64:"255570a82109130cdedfa669b145f6d9c7fa1a26b222d221b0afe71083b8621f";'))->values(array('name' => 'menu_masks', 'value' => 'a:17:{i:0;i:62;i:1;i:61;i:2;i:59;i:3;i:31;i:4;i:30;i:5;i:29;i:6;i:24;i:7;i:21;i:8;i:15;i:9;i:14;i:10;i:11;i:11;i:7;i:12;i:6;i:13;i:5;i:14;i:3;i:15;i:2;i:16;i:1;}'))->values(array('name' => 'install_task', 'value' => 's:4:"done";'))->values(array('name' => 'menu_expanded', 'value' => 'a:0:{}'))->values(array('name' => 'site_name', 'value' => 's:8:"Drupal 6";'))->values(array('name' => 'site_mail', 'value' => 's:16:"*****@*****.**";'))->values(array('name' => 'date_default_timezone', 'value' => 's:4:"3600";'))->values(array('name' => 'user_email_verification', 'value' => 'b:1;'))->values(array('name' => 'clean_url', 'value' => 's:1:"1";'))->values(array('name' => 'install_time', 'value' => 'i:1322833877;'))->values(array('name' => 'node_options_page', 'value' => 'a:1:{i:0;s:6:"status";}'))->values(array('name' => 'comment_page', 'value' => 'i:0;'))->values(array('name' => 'theme_settings', 'value' => 'a:1:{s:21:"toggle_node_info_page";b:0;}'))->values(array('name' => 'drupal_http_request_fails', 'value' => 'b:0;'))->values(array('name' => 'css_js_query_string', 'value' => 's:20:"d0000000000000000000";'))->values(array('name' => 'install_profile', 'value' => 's:7:"default";'))->values(array('name' => 'update_last_check', 'value' => 'i:1322835116;'))->values(array('name' => 'file_directory_temp', 'value' => 's:4:"/tmp";'))->values(array('name' => 'javascript_parsed', 'value' => 'a:0:{}'))->values(array('name' => 'simplenews_content_types', 'value' => 'a:1:{s:10:"simplenews";s:10:"simplenews";}'))->values(array('name' => 'simplenews_vid', 'value' => 's:1:"1";'))->values(array('name' => 'simplenews_from_name_2', 'value' => 's:8:"Drupal 6";'))->values(array('name' => 'simplenews_from_address_2', 'value' => 's:16:"*****@*****.**";'))->values(array('name' => 'simplenews_hyperlinks_2', 'value' => 's:1:"1";'))->values(array('name' => 'simplenews_private_key', 'value' => 's:32:"4591b01a09701f4f2f16862b7d1cd205";'))->values(array('name' => 'cron_last', 'value' => 'i:1322835116;'))->execute();
db_create_table('vocabulary', array('fields' => array('vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'description' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'), 'help' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'relations' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'hierarchy' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'multiple' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'required' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'tags' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'module' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')), 'primary key' => array('vid'), 'indexes' => array('list' => array('weight', 'name')), 'module' => 'taxonomy', 'name' => 'vocabulary'));
db_insert('vocabulary')->fields(array('vid', 'name', 'description', 'help', 'relations', 'hierarchy', 'multiple', 'required', 'tags', 'module', 'weight'))->values(array('vid' => '1', 'name' => 'Newsletter', 'description' => NULL, 'help' => '', 'relations' => '0', 'hierarchy' => '0', 'multiple' => '0', 'required' => '1', 'tags' => '0', 'module' => 'simplenews', 'weight' => '0'))->execute();
db_create_table('vocabulary_node_types', array('fields' => array('vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'type' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '')), 'primary key' => array('type', 'vid'), 'indexes' => array('vid' => array('vid')), 'module' => 'taxonomy', 'name' => 'vocabulary_node_types'));
db_insert('vocabulary_node_types')->fields(array('vid', 'type'))->values(array('vid' => '1', 'type' => 'simplenews'))->execute();
db_create_table('watchdog', array('fields' => array('wid' => array('type' => 'serial', 'not null' => TRUE), 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'type' => array('type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => ''), 'message' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), 'variables' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), 'severity' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'link' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'location' => array('type' => 'text', 'not null' => TRUE), 'referer' => array('type' => 'text', 'not null' => FALSE), 'hostname' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)), 'primary key' => array('wid'), 'indexes' => array('type' => array('type')), 'module' => 'dblog', 'name' => 'watchdog'));
Example #18
0
/**
 * Perform Drupal 6.x to 7.x updates that are required for update.php
 * to function properly.
 *
 * This function runs when update.php is run the first time for 7.x,
 * even before updates are selected or performed. It is important
 * that if updates are not ultimately performed that no changes are
 * made which make it impossible to continue using the prior version.
 */
function update_fix_d7_requirements()
{
    $ret = array();
    // Rewrite the settings.php file if necessary.
    // @see update_prepare_d7_bootstrap().
    global $update_rewrite_settings, $db_url;
    if (!empty($update_rewrite_settings)) {
        $databases = update_parse_db_url($db_url);
        file_put_contents(conf_path() . '/settings.php', "\n" . '$databases = ' . var_export($databases, TRUE) . ';', FILE_APPEND);
    }
    if (drupal_get_installed_schema_version('system') < 7000 && !variable_get('update_d7_requirements', FALSE)) {
        // Add the cache_path table.
        $schema['cache_path'] = drupal_get_schema_unprocessed('system', 'cache');
        $schema['cache_path']['description'] = 'Cache table used for path alias lookups.';
        db_create_table($ret, 'cache_path', $schema['cache_path']);
        variable_set('update_d7_requirements', TRUE);
        // Add column for locale context.
        if (db_table_exists('locales_source')) {
            db_add_field($ret, 'locales_source', 'context', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'The context this string applies to.'));
        }
    }
    return $ret;
}
Example #19
0
/**
 * Act on creation of a new field.
 *
 * This hook is invoked from field_create_field() to ask the field storage
 * module to save field information and prepare for storing field instances.
 * If there is a problem, the field storage module should throw an exception.
 *
 * @param $field
 *   The field structure being created.
 */
function hook_field_storage_create_field($field)
{
    $schema = _field_sql_storage_schema($field);
    foreach ($schema as $name => $table) {
        db_create_table($name, $table);
    }
    drupal_get_schema(NULL, TRUE);
}
 /**
  * Clone an existing table structure and data.
  *
  * @param $name
  *   Table name.
  * @param $source
  *   Source table name.
  * @param $schema
  *   A Schema API definition array.
  */
 protected function cloneTable($name, $source, $schema)
 {
     db_create_table($name, $schema);
     $target = Database::getConnection()->prefixTables('{' . $name . '}');
     if (!in_array($name, $this->excludeTables)) {
         db_query('INSERT INTO ' . $target . ' SELECT * FROM ' . $source);
     }
 }
<?php

/**
 * Database additions for locale tests.
 */
db_create_table('languages', array('fields' => array('language' => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''), 'name' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''), 'native' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''), 'direction' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'enabled' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'plurals' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'formula' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'domain' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'prefix' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'javascript' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '')), 'primary key' => array('language'), 'indexes' => array('list' => array('weight', 'name')), 'module' => 'locale', 'name' => 'languages'));
db_insert('languages')->fields(array('language', 'name', 'native', 'direction', 'enabled', 'plurals', 'formula', 'domain', 'prefix', 'weight', 'javascript'))->values(array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => '0', 'enabled' => '1', 'plurals' => '0', 'formula' => '', 'domain' => 'http://en.example.com', 'prefix' => 'en', 'weight' => '0', 'javascript' => ''))->values(array('language' => 'fr', 'name' => 'French', 'native' => 'Français', 'direction' => '0', 'enabled' => '1', 'plurals' => '2', 'formula' => '($n>1)', 'domain' => '', 'prefix' => 'fr', 'weight' => '-3', 'javascript' => '51e92dcfe1491f4595b9df7f3b287753'))->execute();
db_create_table('locales_source', array('fields' => array('lid' => array('type' => 'serial', 'not null' => TRUE), 'location' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'textgroup' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'), 'source' => array('type' => 'text', 'mysql_type' => 'blob', 'not null' => TRUE), 'version' => array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => 'none')), 'primary key' => array('lid'), 'indexes' => array('source' => array(array('source', 30))), 'module' => 'locale', 'name' => 'locales_source'));
db_create_table('locales_target', array('fields' => array('lid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'translation' => array('type' => 'text', 'mysql_type' => 'blob', 'not null' => TRUE), 'language' => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''), 'plid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'plural' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)), 'primary key' => array('language', 'lid', 'plural'), 'indexes' => array('lid' => array('lid'), 'plid' => array('plid'), 'plural' => array('plural')), 'module' => 'locale', 'name' => 'locales_target'));
// Enable the locale module.
db_update('system')->fields(array('status' => 1, 'schema_version' => '6006'))->condition('type', 'module')->condition('name', 'locale')->execute();
// Set the default language.
db_insert('variable')->fields(array('name', 'value'))->values(array('name' => 'language_default', 'value' => 'O:8:"stdClass":11:{s:8:"language";s:2:"fr";s:4:"name";s:6:"French";s:6:"native";s:9:"Français";s:9:"direction";s:1:"0";s:7:"enabled";i:1;s:7:"plurals";s:1:"2";s:7:"formula";s:6:"($n>1)";s:6:"domain";s:0:"";s:6:"prefix";s:0:"";s:6:"weight";s:2:"-3";s:10:"javascript";s:32:"51e92dcfe1491f4595b9df7f3b287753";}'))->values(array('name' => 'language_count', 'value' => 'i:2;'))->values(array('name' => 'language_negotiation', 'value' => 'i:0;'))->execute();
// Add the language switcher block in the left region.
db_insert('blocks')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'custom', 'throttle', 'visibility', 'pages', 'title', 'cache'))->values(array('module' => 'locale', 'delta' => '0', 'theme' => 'garland', 'status' => '1', 'weight' => '0', 'region' => 'left', 'custom' => '0', 'throttle' => '0', 'visibility' => '0', 'pages' => '', 'title' => '', 'cache' => '-1'))->execute();
Example #22
0
 /**
  * Executes a DDL statement.
  */
 protected function executeDDLStatement()
 {
     static $count = 0;
     $table = array('fields' => array('id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE)), 'primary key' => array('id'));
     db_create_table('database_test_' . ++$count, $table);
 }
Example #23
0
File: update.php Project: c4rl/6
/**
 * Perform Drupal 5.x to 6.x updates that are required for update.php
 * to function properly.
 *
 * This function runs when update.php is run the first time for 6.x,
 * even before updates are selected or performed.  It is important
 * that if updates are not ultimately performed that no changes are
 * made which make it impossible to continue using the prior version.
 * Just adding columns is safe.  However, renaming the
 * system.description column to owner is not.  Therefore, we add the
 * system.owner column and leave it to system_update_6008() to copy
 * the data from description and remove description. The same for
 * renaming locales_target.locale to locales_target.language, which
 * will be finished by locale_update_6002().
 */
function update_fix_d6_requirements()
{
    $ret = array();
    if (drupal_get_installed_schema_version('system') < 6000 && !variable_get('update_d6_requirements', FALSE)) {
        $spec = array('type' => 'int', 'size' => 'small', 'default' => 0, 'not null' => TRUE);
        db_add_field($ret, 'cache', 'serialized', $spec);
        db_add_field($ret, 'cache_filter', 'serialized', $spec);
        db_add_field($ret, 'cache_page', 'serialized', $spec);
        db_add_field($ret, 'cache_menu', 'serialized', $spec);
        db_add_field($ret, 'system', 'info', array('type' => 'text'));
        db_add_field($ret, 'system', 'owner', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
        if (db_table_exists('locales_target')) {
            db_add_field($ret, 'locales_target', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
        }
        if (db_table_exists('locales_source')) {
            db_add_field($ret, 'locales_source', 'textgroup', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'));
            db_add_field($ret, 'locales_source', 'version', array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => 'none'));
        }
        variable_set('update_d6_requirements', TRUE);
        // Create the cache_block table. See system_update_6027() for more details.
        $schema['cache_block'] = array('fields' => array('cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'), 'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'headers' => array('type' => 'text', 'not null' => FALSE), 'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)), 'indexes' => array('expire' => array('expire')), 'primary key' => array('cid'));
        db_create_table($ret, 'cache_block', $schema['cache_block']);
        // Create the semaphore table now -- the menu system after 6.15 depends on
        // this table, and menu code runs in updates prior to the table being
        // created in its original update function, system_update_6054().
        $schema['semaphore'] = array('fields' => array('name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'value' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'expire' => array('type' => 'float', 'size' => 'big', 'not null' => TRUE)), 'indexes' => array('expire' => array('expire')), 'primary key' => array('name'));
        db_create_table($ret, 'semaphore', $schema['semaphore']);
    }
    return $ret;
}
Example #24
0
/**
 * Update the storage information for a field.
 *
 * This is invoked on the field's storage module from field_update_field(),
 * before the new field information is saved to the database. The field storage
 * module should update its storage tables to agree with the new field
 * information. If there is a problem, the field storage module should throw an
 * exception.
 *
 * @param $field
 *   The updated field structure to be saved.
 * @param $prior_field
 *   The previously-saved field structure.
 * @param $has_data
 *   TRUE if the field has data in storage currently.
 */
function hook_field_storage_update_field($field, $prior_field, $has_data)
{
    if (!$has_data) {
        // There is no data. Re-create the tables completely.
        $prior_schema = _field_sql_storage_schema($prior_field);
        foreach ($prior_schema as $name => $table) {
            db_drop_table($name, $table);
        }
        $schema = _field_sql_storage_schema($field);
        foreach ($schema as $name => $table) {
            db_create_table($name, $table);
        }
    } else {
        // There is data. See field_sql_storage_field_storage_update_field() for
        // an example of what to do to modify the schema in place, preserving the
        // old data as much as possible.
    }
    drupal_get_schema(NULL, TRUE);
}
 /**
  * Asserts that a field can be changed from one spec to another.
  *
  * @param $old_spec
  *   The beginning field specification.
  * @param $new_spec
  *   The ending field specification.
  */
 protected function assertFieldChange($old_spec, $new_spec)
 {
     $table_name = 'test_table_' . $this->counter++;
     $table_spec = array('fields' => array('serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'test_field' => $old_spec), 'primary key' => array('serial_column'));
     db_create_table($table_name, $table_spec);
     $this->pass(format_string('Table %table created.', array('%table' => $table_name)));
     // Check the characteristics of the field.
     $this->assertFieldCharacteristics($table_name, 'test_field', $old_spec);
     // Remove inserted rows.
     db_truncate($table_name)->execute();
     // Change the field.
     db_change_field($table_name, 'test_field', 'test_field', $new_spec);
     // Check the field was changed.
     $this->assertFieldCharacteristics($table_name, 'test_field', $new_spec);
     // Clean-up.
     db_drop_table($table_name);
 }
Example #26
0
 function security_initialize()
 {
     if (config_get('check-database')) {
         if (!db_table_exists('user')) {
             db_create_table('user', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'login' => 'TEXT', 'password' => 'TEXT', 'access' => 'INT', 'email' => 'TEXT', 'authorized' => 'BOOL', 'timestamp' => 'INT DEFAULT 0', 'last_act' => 'INT DEFAULT 0', 'settings' => 'TEXT DEFAULT ""'));
             db_insert('user', array('name' => '"root"', 'login' => '"root"', 'password' => 'MD5("root#RANDOM_SEED#assword")', 'access' => '7', 'authorized' => '1', 'settings' => '""', 'email' => '"postmaster@localhost"'));
         }
         db_create_table_safe('group', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'default' => 'INT', 'refcount' => 'INT DEFAULT 0', 'settings' => 'TEXT DEFAULT ""'));
         db_create_table_safe('usergroup', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'user_id' => 'INT', 'group_id' => 'INT'));
     }
 }
<?php

/**
 * @file
 * Installs database tables using the uc_addresses 6.x-1.x style.
 */
db_create_table('uc_addresses', array('fields' => array('aid' => array('description' => t('The address ID'), 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'first_name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'last_name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'phone' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'company' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'street1' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'street2' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'city' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'zone' => array('type' => 'int', 'size' => 'medium', 'not null' => TRUE, 'default' => 0), 'postal_code' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'country' => array('type' => 'int', 'size' => 'medium', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'address_name' => array('type' => 'varchar', 'length' => 20, 'not null' => FALSE), 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'modified' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)), 'indexes' => array('aid_uid_idx' => array('aid', 'uid')), 'primary key' => array('aid')));
db_create_table('uc_addresses_defaults', array('fields' => array('aid' => array('type' => 'int', 'unsigned' => 1, 'not null' => TRUE), 'uid' => array('type' => 'int', 'unsigned' => 1, 'not null' => TRUE)), 'primary key' => array('aid', 'uid')));
// Insert two addresses in the uc_addresses table and mark one as default.
$addresses6 = array();
for ($i = 1; $i <= 2; $i++) {
    $addresses6[$i] = array('aid' => $i, 'uid' => 1, 'first_name' => self::randomName(), 'last_name' => self::randomName(), 'phone' => self::randomString(), 'company' => self::randomString(), 'street1' => self::randomString(), 'street2' => self::randomString(), 'city' => self::randomString(), 'postal_code' => mt_rand(10000, 99999), 'country' => 840, 'address_name' => '', 'created' => REQUEST_TIME, 'modified' => REQUEST_TIME);
    db_insert('uc_addresses')->fields(array_keys($addresses6[$i]))->values(array_values($addresses6[$i]))->execute();
}
// Mark the second address as default.
$record = array('aid' => 2, 'uid' => 1);
db_insert('uc_addresses_defaults')->fields(array_keys($record))->values(array_values($record))->execute();
// Tell Drupal an older version of uc_addresses was already installed.
$record = array('filename' => drupal_get_path('module', 'uc_addresses') . '/uc_addresses.info', 'name' => 'uc_addresses', 'type' => 'module', 'owner' => '', 'status' => 0, 'throttle' => '0', 'bootstrap' => 0, 'schema_version' => 6001, 'weight' => 0, 'info' => 'a:10:{s:4:"name";s:18:"Ubercart Addresses";s:11:"description";s:87:"Allows users to manage a set of addresses that can be referenced when placing an order.";s:12:"dependencies";a:2:{i:0;s:8:"uc_order";i:1;s:8:"uc_store";}s:7:"package";s:16:"Ubercart - extra";s:4:"core";s:3:"6.x";s:7:"version";s:7:"6.x-1.0";s:7:"project";s:12:"uc_addresses";s:9:"datestamp";s:10:"1278806418";s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}');
db_delete('system')->condition('type', 'module')->condition('name', 'uc_addresses')->execute();
db_insert('system')->fields(array_keys($record))->values(array_values($record))->execute();
Example #28
0
 function content_create_support_table($id, $dataset_id, $fields = array(), $uid = -1)
 {
     $tname = 'content_support_' . $id . '_' . $dataset_id . ($uid != -1 ? "_{$uid}" : '');
     if (db_count('content_support_tables', "`content_id`={$id} AND `dataset_id`={$dataset_id} AND `unique`={$uid}") > 0) {
         return $tname;
     }
     $f = array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'timestamp' => 'INT', 'user_id' => 'INT', 'ip' => 'TEXT');
     foreach ($fields as $k => $v) {
         $f[$k] = $v;
     }
     db_create_table($tname, $f);
     db_insert('content_support_tables', array('content_id' => $id, 'dataset_id' => $dataset_id, 'unique' => $uid));
     return $tname;
 }
Example #29
0
 /**
  * Asserts that a field can be changed from one spec to another.
  *
  * @param $old_spec
  *   The beginning field specification.
  * @param $new_spec
  *   The ending field specification.
  */
 protected function assertFieldChange($old_spec, $new_spec, $test_data = NULL)
 {
     $table_name = 'test_table_' . $this->counter++;
     $table_spec = array('fields' => array('serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'test_field' => $old_spec), 'primary key' => array('serial_column'));
     db_create_table($table_name, $table_spec);
     $this->pass(format_string('Table %table created.', array('%table' => $table_name)));
     // Check the characteristics of the field.
     $this->assertFieldCharacteristics($table_name, 'test_field', $old_spec);
     // Remove inserted rows.
     db_truncate($table_name)->execute();
     if ($test_data) {
         $id = db_insert($table_name)->fields(['test_field'], [$test_data])->execute();
     }
     // Change the field.
     db_change_field($table_name, 'test_field', 'test_field', $new_spec);
     if ($test_data) {
         $field_value = db_select($table_name)->fields($table_name, ['test_field'])->condition('serial_column', $id)->execute()->fetchField();
         $this->assertIdentical($field_value, $test_data);
     }
     // Check the field was changed.
     $this->assertFieldCharacteristics($table_name, 'test_field', $new_spec);
     // Clean-up.
     db_drop_table($table_name);
 }
Example #30
0
function dida_setup_data_test()
{
    global $error, $database;
    if (db_connect('default')) {
        $table = array('description' => '测试', 'fields' => array('id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => false, 'default' => 0, 'description' => '测试'), 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => '测试')), 'indexes' => array('tid' => array('tid')), 'primary key' => array('id'));
        if (db_is_table('dida_test')) {
            if (!db_drop_table('dida_test')) {
                $error[] = '没有数据库表删除权限';
            }
        }
        // 测试表
        if (db_create_table('dida_test', $table)) {
            if (db_exec('INSERT INTO {dida_test} (tid, name) VALUES (:tid, :name)', array(':tid' => 10, ':name' => 'test'))) {
                if (db_query('SELECT * FROM {dida_test}')) {
                    if (db_exec('UPDATE {dida_test} SET name = :name WHERE tid = :tid', array(':tid' => 10, ':name' => 'newtest'))) {
                        if (db_exec('DELETE FROM {dida_test} WHERE tid = 10')) {
                            if (!db_drop_table('dida_test')) {
                                $error[] = '没有数据库表删除权限';
                            } else {
                                if (db_is_table('system')) {
                                    $error[] = '系统配置表已经存在,该数据库中是否已经存在一个程序,建议使用全新数据库,或设置表前缀';
                                }
                            }
                        } else {
                            $error[] = '没有数据删除权限';
                        }
                    } else {
                        $error[] = '没有数据更新权限';
                    }
                } else {
                    $error[] = '没有数据查询权限';
                }
            } else {
                $error[] = '没有表写入权限';
            }
        } else {
            $error[] = '没有表创建权限';
        }
    } else {
        $error[] = '连接数据库失败,请检查配置,或<a href="install.php?setup=1&clear=1">重新开始安装</a>';
    }
    if (empty($error)) {
        dd_goto(f('install.php?setup=4'));
    }
}