{"action":"created","issue":{"url":"https://api.github.com/repos/bitwalker/timex/issues/132","repository_url":"https://api.github.com/repos/bitwalker/timex","labels_url":"https://api.github.com/repos/bitwalker/timex/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/bitwalker/timex/issues/132/comments","events_url":"https://api.github.com/repos/bitwalker/timex/issues/132/events","html_url":"https://github.com/bitwalker/timex/issues/132","id":140546285,"number":132,"title":"How do you use Timex.Ecto.* as column default value?","user":{"login":"ibizaman","id":1044950,"avatar_url":"https://avatars.githubusercontent.com/u/1044950?v=3","gravatar_id":"","url":"https://api.github.com/users/ibizaman","html_url":"https://github.com/ibizaman","followers_url":"https://api.github.com/users/ibizaman/followers","following_url":"https://api.github.com/users/ibizaman/following{/other_user}","gists_url":"https://api.github.com/users/ibizaman/gists{/gist_id}","starred_url":"https://api.github.com/users/ibizaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibizaman/subscriptions","organizations_url":"https://api.github.com/users/ibizaman/orgs","repos_url":"https://api.github.com/users/ibizaman/repos","events_url":"https://api.github.com/users/ibizaman/events{/privacy}","received_events_url":"https://api.github.com/users/ibizaman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-14T00:20:02Z","updated_at":"2016-03-14T00:26:48Z","closed_at":null,"body":"How would you define a default value for a `Timex.Ecto.*` column? I tried the obvious, using `Timex.Date.from` but it does not work when using `mix ecto.migrate` because `:tzdata` is not yet started.\r\n\r\n```elixir\r\ndefmodule WPI.Postgres.MyTable do\r\n    use Ecto.Schema\r\n    schema \"my_table\" do\r\n        field :my_date, Timex.Ecto.DateTimeWithTimezone, default: Timex.Date.from({{2099, 1, 1}, {0, 0, 0}}, \"UTC\")\r\n    end\r\nend\r\n```\r\n\r\n```\r\n== Compilation error on file lib/database/postgres.ex ==\r\n** (ArgumentError) argument error\r\n    (stdlib) :ets.lookup(:tzdata_current_release, :release_version)\r\n    lib/tzdata/release_reader.ex:41: Tzdata.ReleaseReader.current_release_from_table/0\r\n    lib/tzdata/release_reader.ex:13: Tzdata.ReleaseReader.simple_lookup/1\r\n    lib/tzdata/release_reader.ex:7: Tzdata.ReleaseReader.zone_and_link_list/0\r\n    lib/tzdata.ex:61: Tzdata.zone_exists?/1\r\n    lib/timezone/timezone.ex:91: Timex.Timezone.get/2\r\n    lib/date/date.ex:321: Timex.Date.from/2\r\n    lib/database/postgres.ex:223: (module)\r\n```\r\n\r\nIs there a workaround or is this not achievable?\r\nI am still using timex 1.X.X."},"comment":{"url":"https://api.github.com/repos/bitwalker/timex/issues/comments/196087768","html_url":"https://github.com/bitwalker/timex/issues/132#issuecomment-196087768","issue_url":"https://api.github.com/repos/bitwalker/timex/issues/132","id":196087768,"user":{"login":"bitwalker","id":955793,"avatar_url":"https://avatars.githubusercontent.com/u/955793?v=3","gravatar_id":"","url":"https://api.github.com/users/bitwalker","html_url":"https://github.com/bitwalker","followers_url":"https://api.github.com/users/bitwalker/followers","following_url":"https://api.github.com/users/bitwalker/following{/other_user}","gists_url":"https://api.github.com/users/bitwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/bitwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitwalker/subscriptions","organizations_url":"https://api.github.com/users/bitwalker/orgs","repos_url":"https://api.github.com/users/bitwalker/repos","events_url":"https://api.github.com/users/bitwalker/events{/privacy}","received_events_url":"https://api.github.com/users/bitwalker/received_events","type":"User","site_admin":false},"created_at":"2016-03-14T00:26:48Z","updated_at":"2016-03-14T00:26:48Z","body":"Add `Application.ensure_all_started(:timex)` at the top of the module, but you can also use an Erlang datetime time as the default, I believe, that might be worth trying first, that or constructing the DateTime struct manually, especially since it's UTC, the default DateTime value is UTC, so you really just have to set the date fields.\r\n\r\nAnyway, those are a few options :)"}}