You are here

function wysiwyg_update_7200 in Wysiwyg 7.2

Create the {wysiwyg_user} table.

File

./wysiwyg.install, line 159
Installation functions for Wysiwyg module.

Code

function wysiwyg_update_7200() {
  if (!db_table_exists('wysiwyg_user')) {
    db_create_table('wysiwyg_user', array(
      'description' => 'Stores user preferences for wysiwyg profiles.',
      'fields' => array(
        'uid' => array(
          'description' => 'The {users}.uid of the user.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'format' => array(
          'description' => 'The {filter_format}.format of the text format.',
          'type' => 'varchar',
          'length' => 255,
          'not null' => FALSE,
        ),
        'status' => array(
          'description' => 'Boolean indicating whether the format is enabled by default.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
          'size' => 'tiny',
        ),
      ),
      'indexes' => array(
        'uid' => array(
          'uid',
        ),
        'format' => array(
          'format',
        ),
      ),
      'foreign keys' => array(
        'uid' => array(
          'table' => 'users',
          'columns' => array(
            'uid' => 'uid',
          ),
        ),
        'format' => array(
          'table' => 'filter_format',
          'columns' => array(
            'format' => 'format',
          ),
        ),
      ),
    ));
  }
  else {
    db_drop_primary_key('wysiwyg_user');
    db_drop_index('wysiwyg_user', 'uid');
    db_change_field('wysiwyg_user', 'format', 'format', array(
      'description' => 'The {filter_format}.format of the text format.',
      'type' => 'varchar',
      'length' => 255,
      'not null' => FALSE,
    ), array(
      'indexes' => array(
        'uid' => array(
          'uid',
        ),
        'format' => array(
          'format',
        ),
      ),
      'foreign keys' => array(
        'uid' => array(
          'table' => 'users',
          'columns' => array(
            'uid' => 'uid',
          ),
        ),
        'format' => array(
          'table' => 'filter_format',
          'columns' => array(
            'format' => 'format',
          ),
        ),
      ),
    ));
  }
}