Apologies if i have not formatting correct.
Here is an example of reading the data in iex. This is a postgresql database and we use mariadb (galera cluster) in production.
$ iex -S mix
Erlang/OTP 23 [erts-11.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Interactive Elixir (1.10.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> import Ecto.Query
Ecto.Query
iex(2)> Upi.Account.CurrentUser |> Upi.Repo.all
[debug] QUERY OK source="currentuser" db=12.0ms decode=1.5ms queue=1.7ms idle=194.4ms
SELECT c0."id", c0."actiondate", c0."clientversion", c0."closesession", c0."facility_fk", c0."ipaddress", c0."last_updated", c0."logindate", c0."os_version", c0."python_version", c0."usermachine", c0."username" FROM "currentuser" AS c0 []
[
%Upi.Account.CurrentUser{
__meta__: #Ecto.Schema.Metadata<:loaded, "currentuser">,
actiondate: ~N[2020-08-10 04:40:14],
clientversion: "v10 build 436",
closesession: false,
facility_fk: 1,
id: 756780,
ipaddress: "127.0.1.1",
last_updated: ~N[2020-08-10 06:16:56],
logindate: ~N[2020-08-10 04:40:14],
os_version: "Linux",
python_version: nil,
usermachine: "mark@auMan103Mark",
username: "mark"
},
%Upi.Account.CurrentUser{
__meta__: #Ecto.Schema.Metadata<:loaded, "currentuser">,
actiondate: ~N[2020-08-04 03:31:11],
clientversion: "v10 build 436",
closesession: false,
facility_fk: 1,
id: 756727,
ipaddress: "192.168.2.77",
last_updated: ~N[2020-08-10 06:16:56],
logindate: ~N[2020-08-04 03:31:11],
os_version: "Windows 10",
python_version: nil,
usermachine: "chris@auWin77Chris",
username: "chris"
}
]
defmodule Upi.Account.CurrentUser do
use Ecto.Schema
import Ecto.Changeset
schema "currentuser" do
field :actiondate, :naive_datetime
field :clientversion, :string
field :closesession, :boolean, default: false
field :facility_fk, :integer
field :ipaddress, :string
field :last_updated, :naive_datetime
field :logindate, :naive_datetime
field :os_version, :string
field :python_version, :string
field :usermachine, :string
field :username, :string
# timestamps()
end
The data is not written by Ecto/Phoenix.
But I just updated the last_updated column as follows, and you can see the dates in sql.
sql> update currentuser set last_updated = now();
sql> select actiondate, last_updated, logindate from currentuser;
actiondate | last_updated | logindate
-------------------------------+-------------------------------+-------------------------------
2020-08-10 14:40:14.473904+10 | 2020-08-10 16:16:56.257595+10 | 2020-08-10 14:40:14.473915+10
2020-08-04 13:31:11+10 | 2020-08-10 16:16:56.257595+10 | 2020-08-04 13:31:11+10
(2 rows)
sql> show timezone;
TimeZone
------------------
Australia/Sydney
(1 row)