0

I am doing Mantis database upgrade and I am getting the below error when running the create table command. Can someone please help me to see whats wrong with the mysql syntax?

This is the error msg:

Schema CreateTableSQL ( )   BAD
CREATE TABLE (
email_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
email VARCHAR(64) NOT NULL DEFAULT '',
subject VARCHAR(250) NOT NULL DEFAULT '', 
submitted DATETIME NOT NULL DEFAULT '1970-01-01 00:00:01',
metadata LONGTEXT NOT NULL,
body LONGTEXT NOT NULL,
PRIMARY KEY (email_id) )
ENGINE=MyISAM

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( email_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, email ' at line 1

This is a part of the create table code in schema.php

$upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_email_table'),"
email_id              I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
email                 C(64) NOTNULL DEFAULT \" '' \",
subject               C(250) NOTNULL DEFAULT \" '' \",
submitted     T NOTNULL DEFAULT '1970-01-01 00:00:01',
metadata              XL NOTNULL,
body                  XL NOTNULL
",Array('mysql' => 'ENGINE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
ktiwari
  • 21
  • 4
  • I hope someone with experience in mysql versions can help, the error is because of syntax error – ktiwari Nov 16 '17 at 05:24

2 Answers2

2

You have not provided the table a name:

CREATE TABLE  # name is missing here

    ( email_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT
    , email VARCHAR(64) NOT NULL DEFAULT ''
    , subject VARCHAR(250) NOT NULL DEFAULT ''
    , submitted DATETIME NOT NULL DEFAULT '1970-01-01 00:00:01'
    , metadata LONGTEXT NOT NULL
    , body LONGTEXT NOT NULL
    , PRIMARY KEY (email_id) 
)ENGINE=MyISAM
Paul Maxwell
  • 33,002
  • 3
  • 32
  • 51
  • the code provided above is from the error msg. The create table code is a part of schema.php of creating database tables for mantis, and a part of the code goes: – ktiwari Nov 15 '17 at 10:14
  • `Can someone please help me to see whats wrong with the mysql syntax?` That may be true, but you asked what the problem is: and the problem is exactly what you see above. I don't know why your code/system produced that error but now you know what the error is. *Don't shoot the messenger!* – Paul Maxwell Nov 15 '17 at 10:18
  • i edited my post to include the create table codes, the earlier code provided was from the error msg and not from the codes. – ktiwari Nov 15 '17 at 10:28
  • 1
    OK, but that does not alter the error analysis, nor does it alter the fact that what you (originally) asked has been answered. I am not a PHP expert so adding more into this question won;t assist. – Paul Maxwell Nov 15 '17 at 10:33
  • I did not write the code myself, it is a part of install code by the mantis upgrade script. It is an syntax error. My server is using mysql 5.5.43 and the script (i am not sure which mysql version) is not same as my server's mysql. WOuld you have any idea? As the error points out the syntax error on line 1, something declared there is not right. – ktiwari Nov 16 '17 at 05:26
  • compare it to other similar statements perhaps?. It seem that it wants to create a table called `mantis_email_table` but that string wasn't passed into MySQL. I cannot offer more than this. – Paul Maxwell Nov 16 '17 at 05:29
0

I found my solution. My server is running 5.5.43 mysql and the mantis install script was looking for 4.0.1 I commented out the create table commands for the 4 tables it was giving error for at the schema.php. I also commented out the check for the mysql ver 4.0.1. Bypassing these commands from the script enabled me to proceed with the installation.

ktiwari
  • 21
  • 4