-1

I am appending three new tables in my custom module using hook_update, but it is throwing below error when I try to run update.php file

PDOException: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'schema_version' at row 206: UPDATE {system} SET schema_version=:db_update_placeholder_0 WHERE (name = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => 71000 [:db_condition_placeholder_0] => pemedia_library ) in drupal_set_installed_schema_version() (line 181 of H:\xampp\htdocs\brandenglish\trunk\includes\install.inc).

Here is my code

//my module install file
    <?php

    /**
     * @file
     * Install, update and uninstall functions for the pemedia_library module.
     * https://www.drupal.org/node/876250
     */
    /*
     * *Implementing hook schema
     */

    function pemedia_library_schema() {
        /*
         * Photographic page table 
         */
        $schema['pemedia_gallery_table'] = array(
            // Example (partial) specification for table "node".
            'description' => 'Table for storing information about image media.',
            'fields' => array(
                'imid' => array(
                    'type' => 'serial',
                    'not null' => TRUE,
                    'description' => 'Primary Key: Unique aggregator image ID.',
                ),
                'image_title' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Title of the media.',
                ),
                'low_res_path' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'CDN url path for low resulution images.',
                ),
                'medium_res_path' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'CDN url path for medium resulution images.',
                ),
                'high_res_path' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'CDN url path for high resulution images.',
                ),
                'description' => array(
                    'type' => 'text',
                    'not null' => TRUE,
                    'size' => 'big',
                    'description' => 'Description of the image',
                ),
                'bussiness_channel' => array(
                    'type' => 'varchar',
                    'length' => 60,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Type of bussiness channel.',
                ),
                'user_right' => array(
                    'type' => 'varchar',
                    'length' => 60,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Type of user right.',
                ),
                'geography' => array(
                    'type' => 'varchar',
                    'length' => 60,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Geographic location.',
                ),
                'expiry_date_timestamp' => array(
                    'type' => 'int',
                    'not null' => FALSE,
                    'description' => 'Expiry date of image items, as a Unix timestamp.',
                ),
                'usages_restriction' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'information about usages restriction.',
                ),
                'owner' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Information about the owner.',
                ),
                'copyright_information' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Copyright information about the image.',
                ),
                'other_information' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'other information about the image.',
                ),
                'status' => array(
                    'description' => 'status field for the images',
                    'type' => 'int',
                    'length' => 1,
                    'not null' => TRUE,
                    'default' => 1,
                ),
            ),
            'primary key' => array('imid'),
        );

        /*
         * Illustration page table 
         */

        $schema['pemedia_illustration_table'] = array(
            // Example (partial) specification for table "node".
            'description' => 'Table for storing information about custom media.',
            'fields' => array(
                'mid' => array(
                    'type' => 'serial',
                    'not null' => TRUE,
                    'description' => 'Primary Key: Unique aggregator custom media ID.',
                ),
                'media_title' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Title of the custom media.',
                ),
                'illustration_file_path_1' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'CDN url path for first illustration file.',
                ),
                'illustration_file_path_2' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'CDN url path for second illustration file.',
                ),
                'illustration_file_path_3' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'CDN url path for third illustration file..',
                ),
                'description' => array(
                    'type' => 'text',
                    'not null' => TRUE,
                    'size' => 'big',
                    'description' => 'Description of the custom media',
                ),
                'bussiness_channel' => array(
                    'type' => 'varchar',
                    'length' => 60,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Type of bussiness channel.',
                ),
                'user_right' => array(
                    'type' => 'varchar',
                    'length' => 60,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Type of user right.',
                ),
                'owner' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Information about the owner.',
                ),
                'file1_size' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'size of the file1.',
                ),
                'file2_size' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'size of the file2.',
                ),
                'file3_size' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'size of the file3.',
                ),
                'status' => array(
                    'description' => 'status field for the custom media',
                    'type' => 'int',
                    'length' => 1,
                    'not null' => TRUE,
                    'default' => 1,
                ),
            ),
            'primary key' => array('mid'),
        );

        /*
         * table schema for application page table 
         */
        $schema['pemedia_application_page_table'] = array(
            'description' => 'Table for storing information about static media asset of applicaton page .',
            'fields' => array(
                'appid' => array(
                    'type' => 'serial',
                    'not null' => TRUE,
                    'description' => 'Primary Key: Unique aggregator static media asset ID of application page .',
                ),
                'app_content_title' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Title of the static media asset of applicaton page',
                ),
                'app_content_media_type' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => 'application',
                    'description' => 'Media Type for static media asset of applicaton page.',
                ),
                'status' => array(
                    'description' => 'status field for static media asset of applicaton page',
                    'type' => 'int',
                    'length' => 1,
                    'not null' => TRUE,
                    'default' => 1,
                ),
            ),
            'primary key' => array('appid'),
        );
        /*
         * table schema for product logos page table 
         */
        $schema['pemedia_product_logos_page_table'] = array(
            'description' => 'Table for storing information static media asset of product logos page .',
            'fields' => array(
                'plogosid' => array(
                    'type' => 'serial',
                    'not null' => TRUE,
                    'description' => 'Primary Key: Unique aggregator ID for  static media asset of product logos page .',
                ),
                'plogs_content_title' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Title of the  static media asset of product logos page .',
                ),
                'plogs_media_type' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => 'product_logos',
                    'description' => 'Media Type for static media asset of product logos page .',
                ),
                'status' => array(
                    'description' => 'status field of static media asset of product logos page . ',
                    'type' => 'int',
                    'length' => 1,
                    'not null' => TRUE,
                    'default' => 1,
                ),
            ),
            'primary key' => array('plogosid'),
        );


        /*
         * Table for User content downloads
         */
        $schema['pemedia_user_content_table'] = array(
            'description' => 'Table for storing information about User content downlaods.',
            'fields' => array(
                'uid' => array(
                    'type' => 'serial',
                    'not null' => TRUE,
                    'description' => 'Primary Key: Unique aggregator ID for User content downlaods.',
                ),
                'content_id' => array(
                    'type' => 'int',
                    'size' => 'big',
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Content Id of contents downloaded by user.',
                ),
                'content_media_type' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Media Type of contents downloaded by user.',
                ),
                'status' => array(
                    'description' => 'status field of contents downloaded by user.',
                    'type' => 'int',
                    'length' => 1,
                    'not null' => TRUE,
                    'default' => 1,
                ),
            ),
            'primary key' => array('uid'),
        );
        return $schema;
    }

    /**
     * Create new database table for static contents {pemedia_application_page_table, pemedia_product_logos_page_table, pemedia_user_content_table}.
     */
    function pemedia_library_update_71001() {
        /*
         * Table for application page 
         */
        $table1 = array(
            'description' => 'Table for storing information about static media asset of applicaton page .',
            'fields' => array(
                'appid' => array(
                    'type' => 'serial',
                    'not null' => TRUE,
                    'description' => 'Primary Key: Unique aggregator static media asset ID of application page .',
                ),
                'app_content_title' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Title of the static media asset of applicaton page',
                ),
                'app_content_media_type' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => 'application',
                    'description' => 'Media Type for static media asset of applicaton page.',
                ),
                'status' => array(
                    'description' => 'status field for static media asset of applicaton page',
                    'type' => 'int',
                    'length' => 1,
                    'not null' => TRUE,
                    'default' => 1,
                ),
            ),
            'primary key' => array('appid'),
        );

        /*
         * Table for product logos page 
         */
        $table2 = array(
            'description' => 'Table for storing information static media asset of product logos page .',
            'fields' => array(
                'plogosid' => array(
                    'type' => 'serial',
                    'not null' => TRUE,
                    'description' => 'Primary Key: Unique aggregator ID for  static media asset of product logos page .',
                ),
                'plogs_content_title' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Title of the  static media asset of product logos page .',
                ),
                'plogs_media_type' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => 'product_logos',
                    'description' => 'Media Type for static media asset of product logos page .',
                ),
                'status' => array(
                    'description' => 'status field of static media asset of product logos page . ',
                    'type' => 'int',
                    'length' => 1,
                    'not null' => TRUE,
                    'default' => 1,
                ),
            ),
            'primary key' => array('plogosid'),
        );

        /*
         * Table for User content downloads
         */
        $table3 = array(
            'description' => 'Table for storing information about User content downlaods.',
            'fields' => array(
                'uid' => array(
                    'type' => 'serial',
                    'not null' => TRUE,
                    'description' => 'Primary Key: Unique aggregator ID for User content downlaods.',
                ),
                'content_id' => array(
                    'type' => 'int',
                    'size' => 'big',
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Content Id of contents downloaded by user.',
                ),
                'content_media_type' => array(
                    'type' => 'varchar',
                    'length' => 255,
                    'not null' => TRUE,
                    'default' => '',
                    'description' => 'Media Type of contents downloaded by user.',
                ),
                'status' => array(
                    'description' => 'status field of contents downloaded by user.',
                    'type' => 'int',
                    'length' => 1,
                    'not null' => TRUE,
                    'default' => 1,
                ),
            ),
            'primary key' => array('uid'),
        );

        db_create_table('pemedia_application_page_table', $table1);
        db_create_table('pemedia_product_logos_page_table', $table2);
        db_create_table('pemedia_user_content_table', $table3);
    }

Can some one help please. Thanks

1
  • 1
    Table versions usually have a 4 digit number. Try 7101 Commented Jan 29, 2015 at 12:33

1 Answer 1

1
  1. Change hook_update function name to pemedia_library_update_7001 (remove first occurrence of 1)
  2. If you want to add tables with hook_update place it in hook_schema, than try like in example below. That is much cleaner way.

    function yourModule_update_7001() {
      $schema = module_invoke('yourModule', 'schema');
      db_create_table('table_name_1', $schema['table_name_1']);
      db_create_table('table_name_2', $schema['table_name_2']);
      db_create_table('table_name_3', $schema['table_name_3']);
    }
2
  • I had already run one update with name 7001 thats why I changed it to 70001 .... with one table above format worked perfectly .. but when I tried for multiple table it failed
    – Hitesh
    Commented Jan 29, 2015 at 15:56
  • 1
    If you already have _7001 than name next ones _7002, _7003, etc. Your error is caused by too large update number. Field in DB can hold integers up to 32767.
    – zaporylie
    Commented Jan 30, 2015 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.