Skip to content

Migration from cqrs_tools #10

@yleflour

Description

@yleflour

I first of all thank you for cqrs_tools and blunt.

We are trying to migrate to blunt but have no idea on how to apply the migration.
Do you have a sample project we could use ?

(Edit) Steps to migrate

I will live update this comment with the steps followed to migrate from cqrs_tools to blunt. Please note that as we didn't use every available cqrs_tools feature, not everything will be documented

Install blunt

# mix.exs
defp deps do
     [ {:blunt, github: "blunt-elixir/blunt", ref: "reorg", sparse: "apps/blunt", override: true},
      {:blunt_data,
       github: "blunt-elixir/blunt", ref: "reorg", sparse: "apps/blunt_data", override: true},
      {:blunt_ddd,
       github: "blunt-elixir/blunt", ref: "reorg", sparse: "apps/blunt_ddd", override: true},
      {:blunt_absinthe,
       github: "blunt-elixir/blunt", ref: "reorg", sparse: "apps/blunt_absinthe", override: true},
      {:blunt_absinthe_relay,
       github: "blunt-elixir/blunt",
       ref: "reorg",
       sparse: "apps/blunt_absinthe_relay",
       override: true}]
end

Replace imports

A find and replace from Cqrs to Blunt will handle ~80% of the migration

Message

Common struct patterns have been factored into Blunt.Message

It is used by (at least):

  • Blunt.Command
  • Blunt.ValueObject

Options

The option require_all_fields is now require_all_fields?

Behaviors

If using specific @impl (such as @impl Cqrs.ValueObject) for please note that it now implements Blunt.Message. This is important for migrating:

  • before_validate
  • handle_validate
  • after_validate

DomainEvent

  • from option is now derive_from
  • If using Cqrs.DomainEvent.new(__MODULE__, cmd, attrs) switch to Blunt.Message.Constructor.apply( __MODULE__, cmd, attrs, [])

Query

  • The filter macro is not available anymore, use a field directly
  • handle_create and handle execute should be implemented in a handler, see example

Absinthe

  • derive_input_object is now derive_object(name, module, input_object: true)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions