mix phoenix_kit.entities.import (phoenix_kit v1.7.38)

Copy Markdown View Source

Mix task to import entity definitions and data from JSON files.

Each JSON file contains both the entity definition and all its data records.

Imports from the configured mirror path (default: priv/entities/).

Usage

# Import from default path (priv/entities/)
mix phoenix_kit.entities.import

# Import with specific conflict resolution
mix phoenix_kit.entities.import --on-conflict skip
mix phoenix_kit.entities.import --on-conflict overwrite
mix phoenix_kit.entities.import --on-conflict merge

# Dry-run to preview changes
mix phoenix_kit.entities.import --dry-run

# Import specific entity
mix phoenix_kit.entities.import --entity brand

# Import from custom path
mix phoenix_kit.entities.import --input /path/to/import

Options

--on-conflict STRATEGY   How to handle conflicts: skip, overwrite, merge (default: skip)
--dry-run               Preview what would be imported without making changes
--entity NAME           Import specific entity only
--input PATH            Custom input directory
--quiet                 Suppress output messages
-y                      Skip confirmation prompts

Conflict Strategies

  • skip (default): Skip import if record already exists
  • overwrite: Replace existing record with imported data
  • merge: Merge imported data with existing record

Conflict Detection

  • Entity definitions: matched by name field
  • Entity data records: matched by entity_name + slug

Examples

# Preview what would be imported
mix phoenix_kit.entities.import --dry-run

# Import and overwrite any conflicts
mix phoenix_kit.entities.import --on-conflict overwrite

# Import from a backup directory
mix phoenix_kit.entities.import --input ./backup/entities

# Import just the brand entity without confirmation
mix phoenix_kit.entities.import --entity brand -y