Right after upgrading to 4.7.3, I installed fileshare node and an error was generated (see attached screen dump). Directories were created and the module registered itself in the database's system table, but the node_fileshare table was not created. The problem seemed to be in the install, so I deleted the module from the system table and modified the fileshare.install file, adding single quotes around the two occurences of the word 'FALSE'. For good measure, I also tossed a semicolon on the end of the SQL command. When I reinstalled, it worked.

before:

db_query("CREATE TABLE {node_fileshare}
    (
      vid INT(4) UNSIGNED DEFAULT '0' NOT NULL ,
      nid INT(4) UNSIGNED DEFAULT '0' NOT NULL ,
      _filepath VARCHAR(255) NOT NULL ,
      _thumbs BOOL DEFAULT FALSE NOT NULL ,
      _modify BOOL DEFAULT FALSE NOT NULL ,
      PRIMARY KEY (vid,nid)
      ) /*!40100 DEFAULT CHARACTER SET utf8 */"
    );

edited:

    db_query("CREATE TABLE {node_fileshare}
    (
      vid INT(4) UNSIGNED DEFAULT '0' NOT NULL ,
      nid INT(4) UNSIGNED DEFAULT '0' NOT NULL ,
      _filepath VARCHAR(255) NOT NULL ,
      _thumbs BOOL DEFAULT 'FALSE' NOT NULL ,
      _modify BOOL DEFAULT 'FALSE' NOT NULL ,
      PRIMARY KEY (vid,nid)
      ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
    );

Perhaps the single quotes don't matter for everyone, but they did on my installation. I can see from the edit history that they were present until a recent revision.

CommentFileSizeAuthor
snapshot2_1.png130.49 KBdhakajack

Comments

JamieR’s picture

Interesting. I'm a postgreSQL guy, so I've been relying on the code that phpMyAdmin auto generated. However, in looking into the documentation for MySQL, I found this about the BOOL (boolean) datatype:

http://mysql.org/doc/refman/5.0/en/other-vendor-data-types.html

Seems perhaps that I should be using TINYINT ? Can any of you MySQL guys confirm or deny this?
Thanks for the feedback!
Jamie.

bomarmonk’s picture

Hacajack's fix worked for me. I had the same problem installing the MySQL table until I used his edited install code. Now the module installs as expected.

JamieR’s picture

That's how I originally had the code - but others were having problems with it. No feedback about the tinyint datatype?

thewebtailor’s picture

Title: Installation failure » Installation failure - data types

MySQL automatically maps the 'BOOL' data type at table creation time, so although the script thinks it has created a BOOL type column, it hasn't.

You shouldn't need to worry about it - MySQL will do the necessary.

JamieR’s picture

Assigned: Unassigned » JamieR

Okay - looking at other modules' MySQL I've come up with this:

db_query("CREATE TABLE {node_fileshare} (
    vid int(4) unsigned NOT NULL default '0',
    nid int(4) unsigned NOT NULL default '0',
    _filepath varchar(255) NOT NULL default '',
    _thumbs tinyint(1) NOT NULL default '0',
    _modify tinyint(1) NOT NULL default '0',
    PRIMARY KEY (vid,nid)
  ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
);

If I don't' hear that this is wrong, I'm going to change the normal distribution to reflect this new code. Thanks fo the help!

Jamie.

JamieR’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)