Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Trying to install DA via Drush on a site using a SQLite database results in the following:
~> drush --uri=http://spaces.test/ en domain
The following extensions will be enabled: domain
Do you really want to continue? (y/n): y
WD php: PDOException: SQLSTATE[HY000]: General error: 1 table "domain_export" has more than one primary key: [error]
CREATE TABLE {domain_export} (
domain_id INTEGER PRIMARY KEY AUTOINCREMENT,
machine_name VARCHAR(255) NOT NULL DEFAULT '',
PRIMARY KEY (machine_name)
);
; Array
(
)
in db_create_table() (line 2684 of /Users/garrett/Sites/spaces.test/www/includes/database/database.inc).
Since this is currently happening even in the 7.x-3.3 release but there don't appear to be any other issues about this, I'm betting this isn't a problem when MySQL is used… But at any rate, the relevant bit from hook_schema() looks like this:
$schema['domain_export'] = array(
'description' => 'Stores canonical machine names for domains.',
'fields' => array(
'domain_id' => array('type' => 'serial', 'not null' => TRUE, 'description' => 'Domain id. Automatic master key.'),
'machine_name' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', 'description' => 'The machine name for this domain.')),
'primary key' => array('machine_name'),
'indexes' => array(
'domain_id' => array('domain_id')
),
);
So yeah, since the serial field will already be the primary key, we can't make another one.
Possible patch attached.
Comment | File | Size | Author |
---|---|---|---|
domain_export_multiple_primary_keys.patch | 661 bytes | Garrett Albright |
Comments
Comment #1
agentrickardOdd that MySQL doesn't seem to mind. This looks sufficient to me but I'd love to have folks with more db experience weigh in.
Comment #2
nevergone CreditAttribution: nevergone commentedWhat would there be need for in order for the solution of the issue to go on?
Comment #3
agentrickardConfirmation that making this change doesn't:
* Break installation
* Break update
* Break the upgrade path
We would also need an update hook.
Comment #4
agentrickardFixed.
3cf8a71..cdee6f5 7.x-3.x -> 7.x-3.x
Notes:
* Does not affect < 7.x.3.
* Since this only affects installs, no update hook is provided.
Comment #5
nevergone CreditAttribution: nevergone commentedThanks! :)