PRAGMA foreign_keys=1; CREATE TABLE example ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL, content TEXT NOT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, expires_at DATETIME NOT NULL ); -- Add an index on the created column. CREATE INDEX idx_example_created ON example(created_at); -- Add a trigger to keep timestamp updated. CREATE TRIGGER snippet_example_timestamp AFTER UPDATE ON example FOR EACH ROW BEGIN UPDATE example SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id; END;