[ALOY-634] Alloy: Create a Model that contains a field/column with a Default value of CURRENT_TIMESTAMP
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Low |
| Status | Resolved |
| Resolution | Won't Fix |
| Resolution Date | 2014-03-10T19:13:04.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Models, Runtime, XML |
| Labels | alloy, database, models |
| Reporter | Mark Anthony Sabandal |
| Assignee | Unknown |
| Created | 2013-04-18T17:48:59.000+0000 |
| Updated | 2018-03-07T22:26:05.000+0000 |
Description
The current alloy 1.1.0 Models doesn't support creating a Column with a Default value of CURRENT_TIMESTAMP. I've already tested the following configurations:
Not Working
config: {
"columns": {
"date_created": "TIMESTAMP"
},
"defaults": {
"date_created": "CURRENT_TIMESTAMP"
},
"adapter": {
"type": "sql",
"collection_name": "Table1"
}
}
Not Working
config: {
"columns": {
"date_created": "TIMESTAMP DEFAULT CURRENT_TIMESTAMP"
},
"defaults": {
},
"adapter": {
"type": "sql",
"collection_name": "Table1"
}
}
Is there a reason you can't do this?
exports.definition = { config: { "columns" : { "name" : "text", "date_created" : "text" }, "defaults" : { "date_created": new Date() }, adapter: { type: "sql", collection_name: "mycollection" } }Marking resolved/won't fix because there's a suitable technique already. Not that SQLite doesn't offer support for datetime-type data types for fields. To simulate these, we'd have to pass through the date and time functions (http://sqlite.org/lang_datefunc.html) which offer no inherent advantage over the JavaScript functions that can be executed directly.