Created
November 20, 2023 15:59
-
-
Save pytlv/f7fc5f20e9eddae5c740350defcbcc94 to your computer and use it in GitHub Desktop.
add last_modified column to an sqlite3 database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ALTER TABLE your_table | |
| ADD COLUMN last_update TEXT; | |
| CREATE TRIGGER update_last_update | |
| AFTER UPDATE | |
| ON Your_Table_Name | |
| FOR EACH ROW | |
| BEGIN | |
| UPDATE Your_Table_Name | |
| SET last_update = CURRENT_TIMESTAMP | |
| WHERE id = NEW.id; | |
| END; | |
| PRAGMA recursive_triggers = OFF; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment