Message module fails to install with SQLite (TABLE and INDEX both named "message_type")
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #1941448. -->
Reported by: [Anthony Fok](https://www.drupal.org/user/8684)
>>>
<p>My installation attempts of Commerce Kickstart 2.x or Commons 3.x distribution with the SQLite database backend have been utterly unsuccessful, failing with the mysterious error message:</p>
<blockquote><p>PDOException: SQLSTATE[HY000]: General error: 1 there is already a table named message_type:<br>
CREATE INDEX main.message_type ON message (type);</p></blockquote>
<p>I tried to investigate by using "drush qd --debug" and looking at commons-7.x-3.0/profiles/commons/commons.info, and determined that the installation failed at "message" module. I then tried a minimal Drupal 7.21 installation, and upon enabling the "message" module, the same error message appeared.</p>
<p>It appears that this bug is due to a limitation in SQLite where a table and an index cannot be given the same name in a database. According to <a href="http://www.sqlite.org/lang_createtable.html">http://www.sqlite.org/lang_createtable.html</a>:</p>
<blockquote><p>It is usually an error to attempt to create a new table in a database that already contains a table, index or view of the same name. However, if the "IF NOT EXISTS" clause is specified as part of the CREATE TABLE statement and a table or view of the same name already exists, the CREATE TABLE command simply has no effect (and no error message is returned). An error is still returned if the table cannot be created because of an existing index, even if the "IF NOT EXISTS" clause is specified.</p></blockquote>
<p>Other users have run into the same problem. For example, <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-3"><a href="https://www.drupal.org/project/commerce_kickstart/issues/1894006" title="Status: Closed (duplicate)">#1894006: Commerce Kickstart installation fails at Message module with SQLite (TABLE and INDEX both named "message_type")</a></span> (originally titled "drush qd command fails to build and start running commerce kickstart with PDOException error") was filed against Commerce Kickstart 2.x.</p>
<p>Many thanks in advance for your help, as I really look forward to using Commerce Kickstart 2.x and Commons 2.x with SQLite on some of my small servers where MySQL may not be available. :-)</p>
issue