Legion. Store. Postgres. Migration
(Legion v0.5.0)
View Source
Runs versioned PostgreSQL migrations for Legion.Store.Postgres.
Usage
defmodule MyApp.Repo.Migrations.AddLegionAgents do
use Ecto.Migration
def up, do: Legion.Store.Postgres.Migration.up()
def down, do: Legion.Store.Postgres.Migration.down()
endMigrations are versioned and idempotent. up/1 applies only versions that
haven't already run and records the resulting version in the table comment.
When a new Legion release adds a schema version, generate another migration using the same calls. You can pin that migration to a specific version:
defmodule MyApp.Repo.Migrations.AddLegionAgentsV01 do
use Ecto.Migration
def up, do: Legion.Store.Postgres.Migration.up(version: 1)
def down, do: Legion.Store.Postgres.Migration.down(version: 1)
endRolling back the example above removes version 1.
Options
:table- the table name, defaults to"legion_agents". It must match the:tablegiven touse Legion.Store.Postgres.:version- the target version.up/1defaults to the latest version;down/1defaults to rolling back all versions.
Migrating Without Ecto
If your application uses something other than Ecto for migrations, be it an external system or another ORM, it may be helpful to create plain SQL migrations for Legion's database schema changes.
The simplest mechanism for obtaining the SQL changes is to create the migration locally and run
mix ecto.migrate --log-migrations-sql. That will log all of the generated SQL, which you can
then paste into your migration system of choice.