how to add a new table? #317
-
I added a new table in initDB and increased the version number by 1. The table was successfully created, but I couldn't add any data to it, and reported a {
"message": "Failed to execute 'add' on 'IDBObjectStore': Evaluating the object store's key path yielded a value that is not a valid key.",
"type": "DataError"
} error. Or I changed the table I added in initDB to alter, the table can be successfully created, but the generated table structure is different from the initialized structure. The code in alter mode is like this {
name: tableChatName,
columns: {
},
alter: {
2: {
drop: {
},
modify: {
id: {
primaryKey: true,
autoIncrement: true
},
content: {
notNull: true,
dataType: DATA_TYPE.String
},
createTime: {
notNull: true,
dataType: DATA_TYPE.DateTime
}
},
add: {
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
The alter won't do anything with new table - alter is for existing table. You can just add the new table into the database schema with newer version of db. It will check if there is new table and then add that table into newer version. |
Beta Was this translation helpful? Give feedback.
-
There was issue with autoincrement value in database upgrade. I have fixed the issue in version - 4.5.3. Please check and let me know. here is issue link - #318 |
Beta Was this translation helpful? Give feedback.
There was issue with autoincrement value in database upgrade. I have fixed the issue in version - 4.5.3. Please check and let me know.
here is issue link - #318