diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-06-28 08:55:13 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-06-28 08:55:13 +0000 |
commit | e519a05dbd8a7fe2d5c94cf6786d2bc396ddc40c (patch) | |
tree | cc83c2f58dcd19c0a47992da4e8ae9002e3102da /did-model.lua | |
parent | 4474a7aba82746c3d8c7bf433aa57bb4617e1605 (diff) | |
download | acf-did-e519a05dbd8a7fe2d5c94cf6786d2bc396ddc40c.tar.bz2 acf-did-e519a05dbd8a7fe2d5c94cf6786d2bc396ddc40c.tar.xz |
Added lastchange timestamp to definition table.
Diffstat (limited to 'did-model.lua')
-rw-r--r-- | did-model.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/did-model.lua b/did-model.lua index 121fbf5..42d81f8 100644 --- a/did-model.lua +++ b/did-model.lua @@ -25,7 +25,7 @@ local con local database_creation_script = { "CREATE AGGREGATE array_accum(anyelement) (SFUNC = array_append, STYPE = anyarray, INITCOND = '{}')", "CREATE TABLE dbhistlog (logdatetime timestamp(3) without time zone NOT NULL, msgtext text, userid text)", - "CREATE TABLE definition (did character varying(40) NOT NULL, identification character varying(7), department character varying(40), description character varying(255))", + "CREATE TABLE definition (did character varying(40) NOT NULL, identification character varying(7), department character varying(40), description character varying(255), lastchange timestamp without time zone)", "CREATE TABLE pubdid (did character varying(40), extension character varying(40), starttime time without time zone, endtime time without time zone, stale boolean)", "CREATE TABLE rule (did character varying(40) NOT NULL, extension character varying(40) NOT NULL, starttime time without time zone, endtime time without time zone, startdate date, enddate date, dayofweek bit(7))", "ALTER TABLE ONLY definition ADD CONSTRAINT definition_pkey PRIMARY KEY (did)", @@ -222,7 +222,7 @@ local getdefinitionentries = function(sql) cur = assert (con:execute(sql)) row = cur:fetch ({}, "a") while row do - entries[#entries+1] = {did=row.did, identification=row.identification, department=row.department, description=row.description, extension=row.extension} + entries[#entries+1] = {did=row.did, identification=row.identification, department=row.department, description=row.description, extension=row.extension,lastchange=row.lastchange} row = cur:fetch (row, "a") end -- close everything @@ -337,9 +337,9 @@ local findunuseddefinition = function(exchange) end local updatedefinitionentry = function(definition) - local sql = string.format("UPDATE definition SET identification='%s', department='%s', description='%s' WHERE did='%s'", + local sql = string.format("UPDATE definition SET identification='%s', department='%s', description='%s', lastchange='%s' WHERE did='%s'", escape(definition.identification), escape(definition.department), - escape(definition.description), escape(definition.did)) + escape(definition.description), os.date("%Y-%m-%d %H:%M:%S"), escape(definition.did)) local res = assert (con:execute(sql)) -- logme("Updated DID "..definition.did) return res @@ -845,6 +845,7 @@ function getdefinition(did) group.did = cfe({ value=stripdash(did) or "", label="DID" }) group.identification = cfe({ label="Identification Number" }) group.department = cfe({ label="Department" }) + group.lastchange = cfe({ label="Last Change" }) group.description = cfe({ label="Description" }) group.rules = cfe({ type="longtext", label="Rules", descr="One entry (extension, starttime, endtime, startdate, enddate, dayofweek) per line"}) if did then |