Add a migration for native_stats_start_at (#2716)

This commit is contained in:
Adam 2023-03-01 12:01:27 +01:00 committed by GitHub
parent de0f68a647
commit 05e7f93da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,23 @@
defmodule Plausible.Repo.Migrations.AddNativeStatsStartDate do
use Ecto.Migration
def up do
alter table(:sites) do
add :native_stats_start_at, :naive_datetime, null: true
end
execute """
UPDATE sites SET native_stats_start_at = inserted_at
"""
alter table(:sites) do
modify :native_stats_start_at, :naive_datetime, null: false, default: fragment("now()")
end
end
def down do
alter table(:sites) do
remove :native_stats_start_at
end
end
end