improve accuracy of timestamps

This commit is contained in:
2025-04-05 01:13:00 +00:00
parent e2c17b6b51
commit c7bd7238c6
29 changed files with 120 additions and 66 deletions

View File

@ -10,7 +10,7 @@ defmodule Cannery.Repo.Migrations.CreateUsersAuthTables do
add :hashed_password, :string, null: false
add :confirmed_at, :naive_datetime
add :role, :string
timestamps(type: :utc_datetime)
timestamps(type: :naive_datetime)
end
create unique_index(:users, [:email])

View File

@ -10,7 +10,7 @@ defmodule Cannery.Repo.Migrations.CreateTags do
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
timestamps(type: :utc_datetime)
timestamps(type: :naive_datetime)
end
create index(:tags, [:user_id])

View File

@ -31,7 +31,7 @@ defmodule Cannery.Repo.Migrations.CreateAmmoTypes do
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
timestamps(type: :utc_datetime)
timestamps(type: :naive_datetime)
end
end
end

View File

@ -11,7 +11,7 @@ defmodule Cannery.Repo.Migrations.CreateContainers do
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
timestamps(type: :utc_datetime)
timestamps(type: :naive_datetime)
end
create index(:containers, [:user_id])

View File

@ -12,7 +12,7 @@ defmodule Cannery.Repo.Migrations.CreateAmmoGroups do
add :container_id, references(:containers, on_delete: :nothing, type: :binary_id)
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
timestamps(type: :utc_datetime)
timestamps(type: :naive_datetime)
end
create index(:ammo_groups, [:ammo_type_id])

View File

@ -11,7 +11,7 @@ defmodule Cannery.Repo.Migrations.CreateInvites do
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
timestamps(type: :utc_datetime)
timestamps(type: :naive_datetime)
end
create index(:invites, [:user_id])

View File

@ -8,7 +8,7 @@ defmodule Cannery.Repo.Migrations.CreateContainerTags do
add :container_id, references(:containers, on_delete: :delete_all, type: :binary_id)
add :tag_id, references(:tags, on_delete: :delete_all, type: :binary_id)
timestamps(type: :utc_datetime)
timestamps(type: :naive_datetime)
end
create index(:container_tags, [:container_id])

View File

@ -11,7 +11,7 @@ defmodule Cannery.Repo.Migrations.CreateShotGroups do
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
add :ammo_group_id, references(:ammo_groups, on_delete: :delete_all, type: :binary_id)
timestamps(type: :utc_datetime)
timestamps(type: :naive_datetime)
end
create index(:shot_groups, [:id])

View File

@ -0,0 +1,52 @@
defmodule Cannery.Repo.Migrations.SetUtcDatetime do
use Ecto.Migration
def change do
alter table(:users) do
modify :confirmed_at, :utc_datetime_usec, from: :naive_datetime
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
end
alter table(:users_tokens) do
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
end
alter table(:tags) do
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
end
alter table(:types) do
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
end
alter table(:containers) do
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
end
alter table(:packs) do
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
end
alter table(:invites) do
modify :disabled_at, :utc_datetime_usec, from: :naive_datetime
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
end
alter table(:container_tags) do
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
end
alter table(:shot_records) do
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
end
end
end