add autoincrement
This commit is contained in:
parent
9b1ac5ad52
commit
659e57f0ea
|
@ -57,13 +57,12 @@ pub fn select_n_last_messages(
|
||||||
pub fn add_message(message: Message, conn: &Connection) -> Result<()> {
|
pub fn add_message(message: Message, conn: &Connection) -> Result<()> {
|
||||||
match conn.execute(
|
match conn.execute(
|
||||||
"INSERT INTO messages (
|
"INSERT INTO messages (
|
||||||
id,
|
|
||||||
user_id,
|
user_id,
|
||||||
date,
|
date,
|
||||||
message,
|
message,
|
||||||
from_me
|
from_me
|
||||||
) VALUES (?1, ?2, ?3, ?4, ?5)",
|
) VALUES (?1, ?2, ?3, ?4)",
|
||||||
params![message.id, message.user_id, message.date, message.message, false],
|
params![message.user_id, message.date, message.message, false],
|
||||||
) {
|
) {
|
||||||
Ok(_) => log::info!("message {:} added succsessfully!", message.id),
|
Ok(_) => log::info!("message {:} added succsessfully!", message.id),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
@ -31,7 +31,7 @@ fn create_db(conn: &Connection) -> Result<()> {
|
||||||
}
|
}
|
||||||
match conn.execute(
|
match conn.execute(
|
||||||
"CREATE TABLE messages (
|
"CREATE TABLE messages (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
user_id BLOB NOT NULL,
|
user_id BLOB NOT NULL,
|
||||||
date datetime NOT NULL,
|
date datetime NOT NULL,
|
||||||
message TEXT NOT NULL,
|
message TEXT NOT NULL,
|
||||||
|
|
Loading…
Reference in a new issue