From 7167ad1bae414c53c931cbdabdb81af0a75e9348 Mon Sep 17 00:00:00 2001 From: vtm Date: Fri, 21 Mar 2025 00:10:41 +0100 Subject: [PATCH] Add timestamps to migrations --- .../store/persistent/ecto/record.ex | 1 + .../00000000000001_add_timestamps.exs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 priv/ecto_repo/migrations/00000000000001_add_timestamps.exs diff --git a/lib/fun_with_flags/store/persistent/ecto/record.ex b/lib/fun_with_flags/store/persistent/ecto/record.ex index ffda5af3..c0ca0cf1 100644 --- a/lib/fun_with_flags/store/persistent/ecto/record.ex +++ b/lib/fun_with_flags/store/persistent/ecto/record.ex @@ -13,6 +13,7 @@ defmodule FunWithFlags.Store.Persistent.Ecto.Record do field :gate_type, :string field :target, :string field :enabled, :boolean + timestamps(type: :utc_datetime) end @fields [:flag_name, :gate_type, :target, :enabled] diff --git a/priv/ecto_repo/migrations/00000000000001_add_timestamps.exs b/priv/ecto_repo/migrations/00000000000001_add_timestamps.exs new file mode 100644 index 00000000..e7e6f210 --- /dev/null +++ b/priv/ecto_repo/migrations/00000000000001_add_timestamps.exs @@ -0,0 +1,17 @@ +defmodule FunWithFlags.Dev.EctoRepo.Migrations.AddTimestamps do + use Ecto.Migration + + def up do + alter table(:fun_with_flags_toggles) do + add :inserted_at, :utc_datetime, null: false, default: fragment("CURRENT_TIMESTAMP") + add :updated_at, :utc_datetime, null: false, default: fragment("CURRENT_TIMESTAMP") + end + end + + def down do + alter table(:fun_with_flags_toggles) do + remove :inserted_at + remove :updated_at + end + end +end