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.
WD php: PDOException: SQLSTATE[HY000]: General error: 1 table "eck_entity_type" has more than one primary key: CREATE TABLE [error]
{eck_entity_type} (
id INTEGER PRIMARY KEY AUTOINCREMENT CHECK (id>= 0),
name VARCHAR(128) NOT NULL,
label VARCHAR(128) NOT NULL,
properties TEXT NOT NULL,
PRIMARY KEY (name)
);
; Array
(
)
in db_create_table() (line 2688 of /home/wjaspers/public_html/eck.localhost/includes/database/database.inc).
PDOException: SQLSTATE[HY000]: General error: 1 table "eck_entity_type" has more than one primary key: CREATE TABLE {eck_entity_type} (
id INTEGER PRIMARY KEY AUTOINCREMENT CHECK (id>= 0),
name VARCHAR(128) NOT NULL,
label VARCHAR(128) NOT NULL,
properties TEXT NOT NULL,
PRIMARY KEY (name)
);
; Array
(
)
in db_create_table() (line 2688 of /home/wjaspers/public_html/eck.localhost/includes/database/database.inc).
Using SQLite in a development environment.
Comment | File | Size | Author |
---|---|---|---|
#6 | 0001-eck-issue-1681636-Installation-SQL-error-Duplicate-P.patch | 2.06 KB | geek-merlin |
#3 | 1681636.3.eck-installation-error.patch | 1.52 KB | wjaspers |
Comments
Comment #1
wjaspers CreditAttribution: wjaspers commentedFor reference: http://api.drupal.org/api/drupal/includes%21database%21schema.inc/group/...
The cause is on
line 92
ofeck.install
ineck_schema()
.Comment #2
wjaspers CreditAttribution: wjaspers commentedInline comments discovered in
eck.install
:'primary key' => array('id'/*, 'machine_name'*/), //sad.. taken this out until I figure out how to make it work
Reading the inline comments in-code, I'd suggest the following:
Patch with recommendations to follow.
Comment #3
wjaspers CreditAttribution: wjaspers commentedHere's my patch:
This means we'll ALLOW two bundles to have the same machine name, BUT
ONLY if these bundles are attached to DIFFERENT entities.
EDIT: I didn't change the fact that you are using a 'serial' ID for each, because I don't know where in the ECK module it would affect access/behavior.
Comment #4
wjaspers CreditAttribution: wjaspers commentedEDIT:
Retested --dev (without the aforementioned patch) on 7-16-2012@23:31PM GMT against MySQL:
Result: Installation ok.
Retested against SQLite --dev (without the aforementioned patch): Failed.
Result:
PDOException: SQLSTATE[HY000]: General error: 1 table "eck_entity_type" has more than one primary key: CREATE TABLE {eck_entity_type} ( id INTEGER PRIMARY KEY AUTOINCREMENT CHECK (id>= 0), name VARCHAR(128) NOT NULL, label VARCHAR(128) NOT NULL, properties TEXT NOT NULL, PRIMARY KEY (name) ); ; Array ( ) in db_create_table() (line 2688 of /includes/database/database.inc).
Comment #5
wjaspers CreditAttribution: wjaspers commentedHmm, apparently SQLite complains in my patch, not when the module is installed, but when you try to create new entities.
Notice: Undefined index: primary key in DBObject->__construct() (line 34 of /sites/all/modules/eck/eck.classes.inc).
Comment #6
geek-merlinif we have a serial, that is the primary key. sqlite is picky about that, mysql not.
here's a patch tht is re-rolled accordingly.
install and entity creation worked without problems here.
Comment #7
acrazyanimal CreditAttribution: acrazyanimal commentedNice Patch. The only thing missing is a function eck_update_7010() to update already installed versions to the new schema with proper primary key and indexes.
Comment #8
nevergone CreditAttribution: nevergone commentedAnd now?
Comment #9
acrazyanimal CreditAttribution: acrazyanimal commentedI was hoping that someone would take the initiative to update the patch with an update hook to make sure existing installs get updated..... anyone volunteering?
Comment #10
nevergone CreditAttribution: nevergone commentedSomething?
Comment #11
GavinMcGimpsey CreditAttribution: GavinMcGimpsey commentedI seem to be having this problem. Can someone guide me through installing the patch?
Comment #13
fmizzell CreditAttribution: fmizzell commentedI create an update hook, but it was difficult to drop the primary key. So I am only adding the unique keys. The primary keys were not a problem before for mysql, and they are not being a problem after, so new system will get the advantage of the new schema if they want to use sqlite, and current system should continue to work the same.