mix attr_engine.gen.migration (attr_engine v0.4.0)

Copy Markdown View Source

Generates Ecto migrations for AttrEngine tables.

Usage

mix attr_engine.gen.migration

Options

--prefix PREFIX   Table name prefix (e.g. "cms_" or "ac_")
--repo REPO       Target Ecto repo module
--db DB            Force adapter: `sqlite` or `postgres`. Without it,
                  the repo's `__adapter__/0` decides (default: postgres).

Creates migrations for:

  • attributes
  • attribute_sets
  • attribute_set_attributes (join table)
  • attribute_set_data
  • block_types
  • blocks
  • block_trees
  • attribute_set_trees (DAG)
  • attribute_set_type_associations

Summary

Functions

Renders the migration source for the given prefix and adapter.

Resolves the target adapter from CLI opts, then the configured repo.

Functions

migration_content(prefix, arg2)

@spec migration_content(String.t(), :postgres | :sqlite) :: String.t()

Renders the migration source for the given prefix and adapter.

adapter is :postgres (the default, unchanged) or :sqlite. Exposed for testing the adapter branch without touching the filesystem.

resolve_adapter(opts)

@spec resolve_adapter(keyword()) :: :postgres | :sqlite

Resolves the target adapter from CLI opts, then the configured repo.

Precedence: an explicit --db sqlite|postgres flag wins; otherwise the configured repo's __adapter__/0 decides (that's "the type of db in the config" branching out). Anything unresolved falls back to :postgres, so existing Postgres consumers are never affected.