{"id":13508796,"url":"https://github.com/xerions/ecto_migrate","last_synced_at":"2026-02-20T00:32:24.588Z","repository":{"id":28797124,"uuid":"32320074","full_name":"xerions/ecto_migrate","owner":"xerions","description":"Automatic migrations for ecto","archived":false,"fork":false,"pushed_at":"2023-05-30T11:56:33.000Z","size":85,"stargazers_count":35,"open_issues_count":7,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-21T18:52:41.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xerions.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-03-16T11:22:12.000Z","updated_at":"2023-08-27T13:27:38.000Z","dependencies_parsed_at":"2024-01-08T19:22:16.080Z","dependency_job_id":null,"html_url":"https://github.com/xerions/ecto_migrate","commit_stats":{"total_commits":38,"total_committers":7,"mean_commits":5.428571428571429,"dds":"0.42105263157894735","last_synced_commit":"e6fbdd1401717a7bf6a117bd2a4f19945da1bac9"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/xerions/ecto_migrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerions%2Fecto_migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerions%2Fecto_migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerions%2Fecto_migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerions%2Fecto_migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xerions","download_url":"https://codeload.github.com/xerions/ecto_migrate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerions%2Fecto_migrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29637411,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"ssl_error","status_checked_at":"2026-02-19T22:32:38.330Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:58.578Z","updated_at":"2026-02-20T00:32:24.574Z","avatar_url":"https://github.com/xerions.png","language":"Elixir","funding_links":[],"categories":["ORM and Datamapping"],"sub_categories":[],"readme":"Ecto Migrate [![Build Status](https://travis-ci.org/xerions/ecto_migrate.svg)](https://travis-ci.org/xerions/ecto_migrate)\n============\n\nEcto migrate brings automatic migrations to ecto. Instead of defining and writting manuall diffing\nfrom actual model and old model. The `ecto_migrate` do it for you. It save actual represantation of\na model model in database and checks, if actual model have the same format as saved in database.\n\nTo test, use EctoIt (is depended on it for tests purposes):\n\n```\niex -S mix\n```\n\nAfter, it should be possible:\n\n```elixir\n:application.start(:ecto_it)\nalias EctoIt.Repo\n\nimport Ecto.Query\n\ndefmodule Weather do # is for later at now\n  use Ecto.Model\n\n  schema \"weather\" do\n    field :city\n    field :temp_lo, :integer\n    field :temp_hi, :integer\n    field :prcp,    :float, default: 0.0\n  end\nend\n\nEcto.Migration.Auto.migrate(Repo, Weather)\n\n%Weather{city: \"Berlin\", temp_lo: 20, temp_hi: 25} |\u003e Repo.insert\nRepo.all(from w in Weather, where: w.city == \"Berlin\")\n\n```\n\nLets redefine the same model in a shell and migrate it\n\n```elixir\n\ndefmodule Weather do # is for later at now\n  use Ecto.Model\n\n  schema \"weather\" do\n    field :city\n    field :temp_lo, :integer\n    field :temp_hi, :integer\n    field :prcp,    :float, default: 0.0\n    field :wind,    :float, default: 0.0\n  end\nend\n\nEcto.Migration.Auto.migrate(Repo, Weather)\nRepo.all(from w in Weather, where: w.city == \"Berlin\")\n\n```\n\nLets use references\n\n```elixir\n\ndefmodule Post do\n  use Ecto.Model\n\n  schema \"posts\" do\n    field :title, :string\n    field :public, :boolean, default: true\n    field :visits, :integer\n    has_many :comments, Comment\n  end\nend\n\ndefmodule Comment do\n  use Ecto.Model\n\n  schema \"comments\" do\n    field :text, :string\n    belongs_to :post, Post\n  end\nend\n\nEcto.Migration.Auto.migrate(Repo, Post)\nEcto.Migration.Auto.migrate(Repo, Comment)\n\n```\n\n`ecto_migrate` also provides additional `migrate/3` API. For using with custom source defined models. Example:\n\n```elixir\ndefmodule Taggable do\n  use Ecto.Model\n\n  schema \"this is not a valid schema name and it will never be used\" do\n    field :tag_id, :integer\n  end\nend\n\ndefmodule MyModel do\n  use Ecto.Model\n  schema \"my_model\" do\n    field :a, :string\n    has_many :my_model_tags, {\"my_model_tags\", Taggable}, [foreign_key: :tag_id]\n  end\nend\n```\n\nNow we can migrate `my_model_tags` table with:\n\n```elixir\nEcto.Migration.Auto.migrate(Repo, MyModel)\nEcto.Migration.Auto.migrate(Repo, Taggable, [for: MyModel])\n```\n\nIt will generate and migrate `my_model_tags` table to the database which will be associated with `my_model` table.\n\nIndexes\n-------\n\n`ecto_migrate` has support of indexes:\n\n```elixir\ndefmodule Weather do # is for later at now\n  use Ecto.Model\n  use Ecto.Migration.Auto.Index\n\n  index(:city, unique: true)\n  index(:prcp)\n  schema \"weather\" do\n    field :city\n    field :temp_lo, :integer\n    field :temp_hi, :integer\n    field :prcp,    :float, default: 0.0\n  end\nend\n```\n\nIf you do not want to use DSL for defining indexes, macro index doing no more, as generate function:\n\n```elixir\ndefmodule Weather do # is for later at now\n  use Ecto.Model\n\n  schema \"weather\" do\n    field :city\n    field :temp_lo, :integer\n    field :temp_hi, :integer\n    field :prcp,    :float, default: 0.0\n  end\n\n  def __indexes__ do\n    [{[:city], [unique: true]},\n     {[:prpc], []}]\n  end\nend\n```\n\nExtra attribute options\n-----------------------\n\n```elixir\ndefmodule Weather do # is for later at now\n  use Ecto.Model\n  use Ecto.Migration.Auto.Index\n\n  schema \"weather\" do\n    field :city\n    field :temp_lo, :integer\n    field :temp_hi, :integer\n    field :prcp,    :float, default: 0.0\n  end\n\n  def __attribute_option__(:city), do: [size: 40]\n  def __attribute_option__(_),     do: []\nend\n```\n\nPossibility to have more sources\n--------------------------------\n\nIf the same model used by different sources, it is possible to define callback for it\n\n```elixir\ndefmodule Weather do # is for later at now\n  use Ecto.Model\n  use Ecto.Migration.Auto.Index\n\n  schema \"weather\" do\n    field :city\n    field :temp_lo, :integer\n    field :temp_hi, :integer\n    field :prcp,    :float, default: 0.0\n  end\n\n  def __sources__, do: [\"weather\", \"history_weather\"]\nend\n```\n\nUpgrades in 0.3.x versions\n--------------------------\n\nIf you have installed version before 0.3.2, use 0.3.2 or 0.3.3 for upgrading the table, after that it is possible to\nupgrade higher versions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxerions%2Fecto_migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxerions%2Fecto_migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxerions%2Fecto_migrate/lists"}