Skip to content

Commit d2d1efe

Browse files
committed
db: remove the row seeding query
1 parent 8ac8a40 commit d2d1efe

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

src/cashcode_db.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ impl CashCodeDb {
2626
[],
2727
)?;
2828

29-
for nominal in [1000, 2000, 5000, 10000, 20000] {
30-
db.execute(
31-
"INSERT OR IGNORE INTO accepted_bills (nominal, quantity) VALUES (?1, 0)",
32-
[nominal],
33-
)?;
34-
}
35-
3629
db.execute(
3730
"CREATE TABLE IF NOT EXISTS accepted_coins (
3831
nominal INTEGER PRIMARY KEY,
@@ -47,7 +40,8 @@ impl CashCodeDb {
4740
pub fn record_bill(&self, nominal: BillNominal) -> Result<(), CashCodeError> {
4841
let db = self.conn.lock().unwrap();
4942
db.execute(
50-
"UPDATE accepted_bills SET quantity = quantity + 1 WHERE nominal = ?1",
43+
"INSERT INTO accepted_bills (nominal, quantity) VALUES (?1, 1)
44+
ON CONFLICT(nominal) DO UPDATE SET quantity = quantity + 1",
5145
[nominal.value()],
5246
)?;
5347
Ok(())

0 commit comments

Comments
 (0)