ExShopifyApp.AccessToken.Migrations (ex_shopify_app v1.1.0)
Versioned migrations for the canonical shopify_access_tokens table.
Instead of copying the table definition into your application, write a
one-line migration that delegates here — the schema can then never drift from
the ExShopifyApp.AccessToken.Token contract the library is compiled against:
defmodule MyApp.Repo.Migrations.CreateShopifyAccessTokens do
use Ecto.Migration
def up, do: ExShopifyApp.AccessToken.Migrations.up()
def down, do: ExShopifyApp.AccessToken.Migrations.down()
endThis runs every versioned migration up to the latest version.
Upgrading
As the library evolves, new schema versions are released. The migrated version
is recorded in the table's comment, so re-running up/0 is a no-op once you are
on the latest version. To pin a migration to a specific version — for example
when a new release adds version 2 — generate a new migration and pass version:
defmodule MyApp.Repo.Migrations.UpgradeShopifyAccessTokensToV2 do
use Ecto.Migration
def up, do: ExShopifyApp.AccessToken.Migrations.up(version: 2)
def down, do: ExShopifyApp.AccessToken.Migrations.down(version: 2)
endRequires :ecto_sql (an optional dependency of this library): this module is
only compiled when Ecto.Migration is available.
Summary
Functions
Migrates storage down to (and including) version, defaulting to the first
version — i.e. dropping everything.
Identifies the last migrated version, or 0 if the table has never been
migrated. The version is read from the shopify_access_tokens table comment.
Migrates storage up to the latest version (or to version if given).
Functions
@spec down(keyword()) :: :ok
Migrates storage down to (and including) version, defaulting to the first
version — i.e. dropping everything.
@spec migrated_version(keyword()) :: non_neg_integer()
Identifies the last migrated version, or 0 if the table has never been
migrated. The version is read from the shopify_access_tokens table comment.
@spec up(keyword()) :: :ok
Migrates storage up to the latest version (or to version if given).
Only the versions between the currently migrated version and the target are run, so this is safe to re-run and to call on an already up-to-date database.