Packages

Store changes to your models, for auditing or versioning.

Current section

Files

Jump to
ecto_cellar lib tasks gen.ex
Raw

lib/tasks/gen.ex

defmodule Mix.Tasks.EctoCellar.Gen do
use Mix.Task
@shortdoc "Generates a new migration file for EctoCellar"
def run(opts \\ []) do
change = """
create table(:versions) do
add :model_id, :string, null: false
add :model_name, :string, null: false
add :model_inserted_at, :naive_datetime, null: false
add :version, :text, null: false
timestamps()
end
create index(:versions, [:model_name, :model_id])
"""
Mix.Tasks.Ecto.Gen.Migration.run(
["-r", to_string(EctoCellar.repo()), "create_version_tables", "--change", change] ++ opts
)
end
end