Skip to content
Snippets Groups Projects
Select Git revision
  • d579f513623cf3ccd7fd1df1336f77667c3c4581
  • 11.x default protected
  • 11.2.x protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

database_test.install

Blame
  • Nathaniel Catchpole's avatar
    Issue #1314214 by stefan.r, phayes, ergophobe, YesCT, damienwhaley, kbasarab,...
    catch authored
    Issue #1314214 by stefan.r, phayes, ergophobe, YesCT, damienwhaley, kbasarab, Tor Arne Thune, basic, pfrenssen, yannickoo, simolokid, fietserwin, bzrudi71: MySQL driver does not support full UTF-8 (emojis, asian symbols, mathematical symbols)
    d579f513
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    database_test.install 7.12 KiB
    <?php
    
    /**
     * @file
     * Install, update and uninstall functions for the database_test module.
     */
    
    /**
     * Implements hook_schema().
     *
     * The database tests use the database API which depends on schema
     * information for certain operations on certain databases.
     * Therefore, the schema must actually be declared in a normal module
     * like any other, not directly in the test file.
     */
    function database_test_schema() {
      $schema['test'] = array(
        'description' => 'Basic test table for the database unit tests.',
        'fields' => array(
          'id' => array(
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE,
          ),
          'name' => array(
            'description' => "A person's name",
            'type' => 'varchar_ascii',
            'length' => 255,
            'not null' => TRUE,
            'default' => '',
            'binary' => TRUE,
          ),
          'age' => array(
            'description' => "The person's age",
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0,
          ),
          'job' => array(
            'description' => "The person's job",
            'type' => 'varchar',
            'length' => 255,
            'not null' => TRUE,
            'default' => 'Undefined',
          ),
        ),
        'primary key' => array('id'),
        'unique keys' => array(
          'name' => array('name')
        ),
        'indexes' => array(
          'ages' => array('age'),
        ),
      );
    
      // This is an alternate version of the same table that is structured the same
      // but has a non-serial Primary Key.
      $schema['test_people'] = array(
        'description' => 'A duplicate version of the test table, used for additional tests.',
        'fields' => array(
          'name' => array(
            'description' => "A person's name",
            'type' => 'varchar',
            'length' => 255,
            'not null' => TRUE,
            'default' => '',
          ),
          'age' => array(
            'description' => "The person's age",
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0,
          ),
          'job' => array(
            'description' => "The person's job",
            'type' => 'varchar_ascii',
            'length' => 255,
            'not null' => TRUE,
            'default' => '',
          ),
        ),
        'primary key' => array('job'),
        'indexes' => array(
          'ages' => array('age'),
        ),
      );
    
      $schema['test_people_copy'] = array(
        'description' => 'A duplicate version of the test_people table, used for additional tests.',
        'fields' => array(
          'name' => array(
            'description' => "A person's name",
            'type' => 'varchar',
            'length' => 255,
            'not null' => TRUE,
            'default' => '',
          ),
          'age' => array(
            'description' => "The person's age",
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0,
          ),
          'job' => array(
            'description' => "The person's job",
            'type' => 'varchar_ascii',
            'length' => 255,
            'not null' => TRUE,
            'default' => '',
          ),
        ),
        'primary key' => array('job'),
        'indexes' => array(
          'ages' => array('age'),
        ),
      );
    
      $schema['test_one_blob'] = array(
        'description' => 'A simple table including a BLOB field for testing BLOB behavior.',
        'fields' => array(
          'id' => array(
            'description' => 'Simple unique ID.',
            'type' => 'serial',
            'not null' => TRUE,
          ),
          'blob1' => array(
            'description' => 'A BLOB field.',
            'type' => 'blob',
          ),
        ),
        'primary key' => array('id'),
        );
    
      $schema['test_two_blobs'] = array(
        'description' => 'A simple test table with two BLOB fields.',
        'fields' => array(
          'id' => array(
            'description' => 'Simple unique ID.',
            'type' => 'serial',
            'not null' => TRUE,
          ),
          'blob1' => array(
            'description' => 'A dummy BLOB field.',
            'type' => 'blob',
          ),
          'blob2' => array(
            'description' => 'A second BLOB field.',
            'type' => 'blob'
          ),
        ),
        'primary key' => array('id'),
        );
    
      $schema['test_task'] = array(
        'description' => 'A task list for people in the test table.',
        'fields' => array(
          'tid' => array(
            'description' => 'Task ID, primary key.',
            'type' => 'serial',
            'not null' => TRUE,
          ),
          'pid' => array(
            'description' => 'The {test_people}.pid, foreign key for the test table.',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0,
          ),
          'task' => array(
            'description' => 'The task to be completed.',
            'type' => 'varchar',
            'length' => 255,
            'not null' => TRUE,
            'default' => '',
          ),
          'priority' => array(
            'description' => 'The priority of the task.',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0,
          ),
        ),
        'primary key' => array('tid'),
      );
    
      $schema['test_null'] = array(
        'description' => 'Basic test table for NULL value handling.',
        'fields' => array(
          'id' => array(
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE,
          ),
          'name' => array(
            'description' => "A person's name.",
            'type' => 'varchar_ascii',
            'length' => 255,
            'not null' => FALSE,
            'default' => '',
          ),
          'age' => array(
            'description' => "The person's age.",
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => FALSE,
            'default' => 0),
        ),
        'primary key' => array('id'),
        'unique keys' => array(
          'name' => array('name')
        ),
        'indexes' => array(
          'ages' => array('age'),
        ),
      );
    
      $schema['test_serialized'] = array(
        'description' => 'Basic test table for NULL value handling.',
        'fields' => array(
          'id' => array(
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE,
          ),
          'name' => array(
            'description' => "A person's name.",
            'type' => 'varchar_ascii',
            'length' => 255,
            'not null' => FALSE,
            'default' => '',
          ),
          'info' => array(
            'description' => "The person's data in serialized form.",
            'type' => 'blob',
            'serialize' => TRUE,
          ),
        ),
        'primary key' => array('id'),
        'unique keys' => array(
          'name' => array('name')
        ),
      );
    
      $schema['test_composite_primary'] = array(
        'description' => 'Basic test table with a composite primary key',
        'fields' => array(
          'name' => array(
            'description' => "A person's name",
            'type' => 'varchar',
            'length' => 50,
            'not null' => TRUE,
            'default' => '',
            'binary' => TRUE,
          ),
          'age' => array(
            'description' => "The person's age",
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0,
          ),
          'job' => array(
            'description' => "The person's job",
            'type' => 'varchar',
            'length' => 255,
            'not null' => TRUE,
            'default' => 'Undefined',
          ),
        ),
        'primary key' => array('name', 'age'),
      );
    
      return $schema;
    }