Basically I want to convert a table from mysql to sqlite with the following schema:
create table items ( id integer auto_increment, version integer default 0, primary key (id, version) );
Essentially, I want the identifier to automatically increment every time I insert something into the table, with VERSION starting at 0, but still allowing multiple elements with the same identifier, while VERSION is different.
I am trying to replicate this behavior using Sqlite, but I can not get to work with tables. It seems that you are only allowed one column as an auto-increment, and it should be the main key. If I make the primary key identifier, then I cannot use VERSION as part of the key. However, if I create a multi-column key (ID, VERSION), then I cannot get the identifier for auto-increment.
Is there a workaround, or perhaps a better way to design my table?
I was thinking of the following solution:
Table 1:
create table items { id integer primary autoincrement, version integer}
table 2:
create table item_version { id integer, version integer, primary key (id, version) }
When I add a new element, I add it to the elements and automatically increase the ID. however, if I ever have a new version of the same identifier, I will add it to item_version. I mainly use item_version to store everything except items to create unique identifiers.