Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when creating a new table with dbDelta #346

Frossard opened this issue Apr 17, 2019 · 0 comments


Copy link

commented Apr 17, 2019

Hello guys,

When im creating a new table with dbDelta all my attributes from table with word text have been changed to NVARCHAR(MAX).
This is my code to create the new table:

global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE " . $wpdb->prefix . "lti_logs (
        id bigint(20) NOT NULL AUTO_INCREMENT,
        aula_id bigint(20) NOT NULL,
        disciplina varchar(200),
        posicao mediumint(9),
        oauth_version varchar(20),
        oauth_nonce varchar(200),
        oauth_timestamp varchar(20),
        oauth_consumer_key varchar(50),
        user_id mediumint(9),
        lis_person_sourcedid varchar(50),
        roles varchar(200),
        context_id mediumint(9),
        context_label varchar(200),
        context_title varchar(200),
        resource_link_title varchar(200),
        resource_link_description text,
        resource_link_id mediumint(9),
        context_type varchar(50),
        lis_course_section_sourcedid varchar(50),
        lis_result_sourcedid text,
        lis_outcome_service_url varchar(200),
        lis_person_name_given varchar(200),
        lis_person_name_family varchar(200),
        lis_person_name_full varchar(400),
        ext_user_username varchar(100),
        lis_person_contact_email_primary varchar(300),
        launch_presentation_locale varchar(20),
        ext_lms varchar(50),
        tool_consumer_info_product_family_code varchar(50),
        tool_consumer_info_version varchar(50),
        oauth_callback varchar(50),
        lti_version varchar(50),
        lti_message_type varchar(50),
        tool_consumer_instance_guid varchar(200),
        tool_consumer_instance_name varchar(200),
        tool_consumer_instance_description varchar(200),
        launch_presentation_document_target varchar(50),
        launch_presentation_return_url varchar(250),
        oauth_signature_method varchar(50),
        oauth_signature varchar(200),
        PRIMARY KEY (id)
    ) $charset_collate;";

 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
 dbDelta( $sql );

And i'm having below error:

WordPress database error: [[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]The definition of the column 'conNVARCHAR' must have a data type. Code - 173]

CREATE TABLE wp_lti_logs (
id bigint NOT NULL IDENTITY(1,1),
aula_id bigint NOT NULL,
disciplina NVARCHAR(200),
posicao int,
oauth_version NVARCHAR(20),
oauth_nonce NVARCHAR(200),
oauth_timestamp NVARCHAR(20),
oauth_consumer_key NVARCHAR(50),
user_id int,
lis_person_sourcedid NVARCHAR(50),
roles NVARCHAR(200),
conNVARCHAR(MAX)_id int,
resource_link_title NVARCHAR(200),
resource_link_description NVARCHAR(MAX),
resource_link_id int,
lis_course_section_sourcedid NVARCHAR(50),
lis_result_sourcedid NVARCHAR(MAX),
lis_outcome_service_url NVARCHAR(200),
lis_person_name_given NVARCHAR(200),
lis_person_name_family NVARCHAR(200),
lis_person_name_full NVARCHAR(400),
ext_user_username NVARCHAR(100),
lis_person_contact_email_primary NVARCHAR(300),
launch_presentation_locale NVARCHAR(20),
ext_lms NVARCHAR(50),
tool_consumer_info_product_family_code NVARCHAR(50),
tool_consumer_info_version NVARCHAR(50),
oauth_callback NVARCHAR(50),
lti_version NVARCHAR(50),
lti_message_type NVARCHAR(50),
tool_consumer_instance_guid NVARCHAR(200),
tool_consumer_instance_name NVARCHAR(200),
tool_consumer_instance_description NVARCHAR(200),
launch_presentation_document_target NVARCHAR(50),
launch_presentation_return_url NVARCHAR(250),
oauth_signature_method NVARCHAR(50),
oauth_signature NVARCHAR(200),
CONSTRAINT [wp_lti_logs_id]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.