aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorJoris2021-01-03 19:48:29 +0100
committerJoris2021-01-03 19:48:29 +0100
commit406767e9eed613b5a1513ada772e4bfb78e46290 (patch)
tree3bbf2a3c79631c7bc1f6c23221a196bc1524b589 /src/db
parent11052951b74b9ad4b6a9412ae490086235f9154b (diff)
Let Sqlite provide a default created_at
Diffstat (limited to 'src/db')
-rw-r--r--src/db/categories.rs4
-rw-r--r--src/db/incomes.rs4
-rw-r--r--src/db/payments.rs9
3 files changed, 8 insertions, 9 deletions
diff --git a/src/db/categories.rs b/src/db/categories.rs
index 05b1323..0e2a28c 100644
--- a/src/db/categories.rs
+++ b/src/db/categories.rs
@@ -60,9 +60,9 @@ pub async fn create(pool: &SqlitePool, c: &Create) -> Option<i64> {
let res = sqlx::query(
r#"
INSERT INTO
- categories(name, color, created_at)
+ categories(name, color)
VALUES
- (?, ?, datetime())
+ (?, ?)
"#,
)
.bind(c.name.clone())
diff --git a/src/db/incomes.rs b/src/db/incomes.rs
index cbbfce7..5f44398 100644
--- a/src/db/incomes.rs
+++ b/src/db/incomes.rs
@@ -133,9 +133,9 @@ pub async fn create(pool: &SqlitePool, i: &Create) -> Option<i64> {
let res = sqlx::query(
r#"
INSERT INTO
- incomes(user_id, date, amount, created_at)
+ incomes(user_id, date, amount)
VALUES
- (?, ?, ?, datetime())
+ (?, ?, ?)
"#,
)
.bind(i.user_id)
diff --git a/src/db/payments.rs b/src/db/payments.rs
index 0197375..35e7f68 100644
--- a/src/db/payments.rs
+++ b/src/db/payments.rs
@@ -257,9 +257,9 @@ pub async fn create(pool: &SqlitePool, p: &payment::Create) -> Option<i64> {
let res = sqlx::query(
r#"
INSERT INTO
- payments(name, cost, user_id, category_id, date, frequency, created_at)
+ payments(name, cost, user_id, category_id, date, frequency)
VALUES
- (?, ?, ?, ?, ?, ?, datetime())
+ (?, ?, ?, ?, ?, ?)
"#,
)
.bind(p.name.clone())
@@ -443,15 +443,14 @@ ON
pub async fn create_monthly_payments(pool: &SqlitePool) -> () {
let query = r#"
INSERT INTO
- payments(name, cost, user_id, category_id, date, frequency, created_at)
+ payments(name, cost, user_id, category_id, date, frequency)
SELECT
name,
cost,
user_id,
category_id,
date() AS date,
- 'Punctual' AS frequency,
- datetime() AS created_at
+ 'Punctual' AS frequency
FROM
payments
WHERE