You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/database-interaction-through-models/using-sqlite.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -217,6 +217,52 @@ user = model("User").create({username: "john"});
217
217
// createdAt and updatedAt are automatically set as ISO 8601 text
218
218
```
219
219
220
+
### DateTime Handling in Migrations
221
+
222
+
SQLite does not support ColdFusion datetime literals (for example `{ts '2025-01-01 10:00:00'}` or any datetime expression generated by CFML functions). Instead, SQLite stores all datetime values using the TEXT datatype in ISO-8601 format.
223
+
224
+
Because of this, when working inside migrations, you must not pass any CFML datetime literal to SQLite, or it will throw an error.
225
+
226
+
`addRecord()` and `updateRecord()` Handling
227
+
228
+
Unlike `removeRecord()`, the `addRecord()` and `updateRecord()` migration functions can safely accept ColdFusion datetime literals.
229
+
230
+
If you pass a CFML datetime literal (e.g., now(), createDateTime(), {ts '...'}) into addRecord() or updateRecord(), the migration system automatically converts the value into a valid SQLite-friendly ISO-8601 text string before inserting or updating the record.
231
+
232
+
This means:
233
+
234
+
```javascript
235
+
addRecord(table ="products", data = { createdAt =now() })
236
+
237
+
and
238
+
239
+
updateRecord(table ="products", data = { updatedAt =createDateTime(2025,1,1,10,0,0) }, where ="id = 5")
240
+
```
241
+
242
+
will both work correctly.
243
+
244
+
#### removeRecord() Restrictions
245
+
246
+
removeRecord() does not convert datetime literals.
247
+
Therefore, you must never use CFML datetime expressions inside the where clause in removeRecord().
0 commit comments