mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Renamed habits to chores as this is more what it is about
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
ALTER TABLE habits_log
|
||||
ADD done_by_user_id;
|
||||
ADD done_by_user_id INTEGER;
|
||||
|
||||
DROP TABLE api_keys;
|
||||
|
||||
|
31
migrations/0035.sql
Normal file
31
migrations/0035.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
ALTER TABLE habits RENAME TO chores;
|
||||
|
||||
CREATE TABLE chores_log (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
chore_id INTEGER NOT NULL,
|
||||
tracked_time DATETIME,
|
||||
done_by_user_id INTEGER,
|
||||
row_created_timestamp DATETIME DEFAULT (datetime('now', 'localtime'))
|
||||
);
|
||||
|
||||
INSERT INTO chores_log
|
||||
(chore_id, tracked_time, done_by_user_id, row_created_timestamp)
|
||||
SELECT habit_id, tracked_time, done_by_user_id, row_created_timestamp
|
||||
FROM habits_log;
|
||||
|
||||
DROP TABLE habits_log;
|
||||
|
||||
DROP VIEW habits_current;
|
||||
CREATE VIEW chores_current
|
||||
AS
|
||||
SELECT
|
||||
h.id AS chore_id,
|
||||
MAX(l.tracked_time) AS last_tracked_time,
|
||||
CASE h.period_type
|
||||
WHEN 'manually' THEN '2999-12-31 23:59:59'
|
||||
WHEN 'dynamic-regular' THEN datetime(MAX(l.tracked_time), '+' || CAST(h.period_days AS TEXT) || ' day')
|
||||
END AS next_estimated_execution_time
|
||||
FROM chores h
|
||||
LEFT JOIN chores_log l
|
||||
ON h.id = l.chore_id
|
||||
GROUP BY h.id, h.period_days;
|
Reference in New Issue
Block a user