items table ID column

by jaym, Monday, July 14, 2014, 16:40 (3632 days ago)

Hi, Just wondering... shouldn't then field ID in the items table be autoincrement?

In my items table it's not...
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| id | int(11) | NO | | 0 | |
| datetime | datetime | NO | | NULL | |
| title | text | NO | | NULL | |
| content | longtext | NO | | NULL | |

...and in my table of 15000 items...

mysql> SELECT COUNT(id) from items where id=0;
+-----------+
| COUNT(id) |
+-----------+
| 8960 |
+-----------+

...more than half have ID=0. This isn't very helpful if I want to use this field as a foreign key.

Anyone else have this issue? Perhaps my db setup is incorrect?

Thanks!

items table ID column

by jaym, Monday, July 14, 2014, 18:12 (3632 days ago) @ jaym

Update... I did some digging into SELFOSS to find where the db gets created and found that for some reason the original db spec for the items table has changed (note the spec for sources which hasn't changed):


[image]


It is indeed supposed to pk, ai... but somehow it's been changed. Perhaps the python mysql libs I'm using to access it have done that.

Anyone have any thoughts?

RSS Feed of thread
powered by my little forum