Skip to content

Commit 5a71284

Browse files
committed
timestamp -> timezone
1 parent 634df4a commit 5a71284

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

integration_test/pg/storage_test.exs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ defmodule Ecto.Integration.StorageTest do
2929

3030
def create_database(owner \\ nil) do
3131
query = "CREATE DATABASE #{params()[:database]}"
32-
query = if owner do
33-
query <> " OWNER #{owner};"
34-
else
35-
query <> ";"
36-
end
32+
33+
query =
34+
if owner do
35+
query <> " OWNER #{owner};"
36+
else
37+
query <> ";"
38+
end
39+
3740
run_psql(query)
3841
end
3942

@@ -86,8 +89,8 @@ defmodule Ecto.Integration.StorageTest do
8689
drop_database()
8790
end
8891

89-
test "storage up with custom timestamp timezone" do
90-
assert Postgres.storage_up([timestamp: "America/New_York"] ++ params()) == :ok
92+
test "storage up with custom timezone" do
93+
assert Postgres.storage_up([timezone: "America/New_York"] ++ params()) == :ok
9194
{output, _} = run_psql("SHOW timezone;", [params()[:database]])
9295
assert output =~ "America/New_York"
9396
after
@@ -109,10 +112,12 @@ defmodule Ecto.Integration.StorageTest do
109112
end
110113

111114
test "storage up with unprivileged user with access to the database" do
112-
unprivileged_params = Keyword.merge(params(),
113-
username: "unprivileged",
114-
password: "pass"
115-
)
115+
unprivileged_params =
116+
Keyword.merge(params(),
117+
username: "unprivileged",
118+
password: "pass"
119+
)
120+
116121
run_psql("CREATE USER unprivileged WITH NOCREATEDB PASSWORD 'pass'")
117122
refute Postgres.storage_up(unprivileged_params) == :ok
118123
create_database("unprivileged")
@@ -190,7 +195,9 @@ defmodule Ecto.Integration.StorageTest do
190195
assert contents =~ "CREATE TABLE public.schema_migrations"
191196
assert contents =~ ~s[INSERT INTO public."schema_migrations" (version) VALUES (#{version})]
192197
assert contents =~ "CREATE TABLE test_schema.schema_migrations"
193-
refute contents =~ ~s[INSERT INTO test_schema."schema_migrations" (version) VALUES (#{version})]
198+
199+
refute contents =~
200+
~s[INSERT INTO test_schema."schema_migrations" (version) VALUES (#{version})]
194201
after
195202
drop_schema_migrations_table(PoolRepo.config()[:database], "test_schema")
196203
drop_schema(PoolRepo.config()[:database], "test_schema")
@@ -212,7 +219,9 @@ defmodule Ecto.Integration.StorageTest do
212219
assert contents =~ "CREATE TABLE public.schema_migrations"
213220
assert contents =~ ~s[INSERT INTO public."schema_migrations" (version) VALUES (#{version})]
214221
assert contents =~ "CREATE TABLE test_schema.schema_migrations"
215-
assert contents =~ ~s[INSERT INTO test_schema."schema_migrations" (version) VALUES (#{version})]
222+
223+
assert contents =~
224+
~s[INSERT INTO test_schema."schema_migrations" (version) VALUES (#{version})]
216225
after
217226
drop_schema_migrations_table(PoolRepo.config()[:database], "test_schema")
218227
drop_schema(PoolRepo.config()[:database], "test_schema")
@@ -234,13 +243,14 @@ defmodule Ecto.Integration.StorageTest do
234243
refute contents =~ "CREATE TABLE public.schema_migrations"
235244
refute contents =~ ~s[INSERT INTO public."schema_migrations" (version) VALUES (#{version})]
236245
assert contents =~ "CREATE TABLE test_schema.schema_migrations"
237-
assert contents =~ ~s[INSERT INTO test_schema."schema_migrations" (version) VALUES (#{version})]
246+
247+
assert contents =~
248+
~s[INSERT INTO test_schema."schema_migrations" (version) VALUES (#{version})]
238249
after
239250
drop_schema_migrations_table(PoolRepo.config()[:database], "test_schema")
240251
drop_schema(PoolRepo.config()[:database], "test_schema")
241252
end
242253

243-
244254
test "storage status is up when database is created" do
245255
create_database()
246256
assert :up == Postgres.storage_status(params())

lib/ecto/adapters/postgres.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ defmodule Ecto.Adapters.Postgres do
228228

229229
case run_query(create_command, opts) do
230230
{:ok, _} ->
231-
storage_up_timestamp(database, opts)
231+
storage_up_timezone(database, opts)
232232

233233
{:error, %{postgres: %{code: :duplicate_database}}} ->
234234
{:error, :already_up}
@@ -239,11 +239,11 @@ defmodule Ecto.Adapters.Postgres do
239239
end
240240
end
241241

242-
defp storage_up_timestamp(database, opts) do
243-
timestamp = Keyword.get(opts, :timestamp, "Etc/UTC")
242+
defp storage_up_timezone(database, opts) do
243+
timezone = Keyword.get(opts, :timezone, "Etc/UTC")
244244

245-
if timestamp do
246-
alter_command = ~s(ALTER DATABASE "#{database}" SET timezone TO '#{timestamp}')
245+
if timezone do
246+
alter_command = ~s(ALTER DATABASE "#{database}" SET timezone TO '#{timezone}')
247247

248248
case run_query(alter_command, opts) do
249249
{:ok, _} -> :ok

0 commit comments

Comments
 (0)