How can I fix this database error which resulted from creating a new field in Admin?

I created a unique identifier field called ID, and when I saved it I had a few red error banners, and then the server stopped, and it wont restart. The error is as follows, which is a database error. Being new to Strapi, how can I fix this?

I assume its to do with the fact I created a unique identifier, maybe with the name ID? I would guess this is a bug too, I should not have been able to crash the system simply by creating a field in the admin?

error: CREATE TABLE _knex_temp_alter648 (id varchar(255) PRIMARY KEY AUTOINCREMENT, name varchar(255) NULL, created_at datetime NULL, updated_at datetime NULL, published_at datetime NULL, created_by_id integer NULL, updated_by_id integer NULL, CONSTRAINT accessories_created_by_id_fk FOREIGN KEY (created_by_id) REFERENCES admin_users (id) ON DELETE SET NULL, CONSTRAINT accessories_updated_by_id_fk FOREIGN KEY (updated_by_id) REFERENCES admin_users (id) ON DELETE SET NULL, CONSTRAINT accessories_created_by_id_fk FOREIGN KEY (created_by_id) REFERENCES admin_users (id) ON DELETE SET NULL, CONSTRAINT accessories_updated_by_id_fk FOREIGN KEY (updated_by_id) REFERENCES admin_users (id) ON DELETE SET NULL) - SQLITE_ERROR: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY

I’m not sure why that might have happened.

Your best bet to get going again is to delete the column from the Strapi metadata.

I am not familiar with the inner workings of Strapi. Seeing the SQL error got me all confused. Your post made me think its hard coded in a file. So a little digging and I found src/api/MYCONTENTYTYPE/schema.json, and the ID was set in Schema, so I deleted it and it works.

So that was easy. Perhaps it was a good thing to get the error so I can delve into part of its inner workings!

Thanks

1 Like