Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.43 KB

Getting Started.md

File metadata and controls

55 lines (41 loc) · 1.43 KB

Getting started

You should already have Ecto installed and configured before proceeding. Please follow Ecto's Getting Started guide to get going first.

  1. Add :commanded_ecto_projections to your list of dependencies in mix.exs:

    def deps do
      [
        {:commanded_ecto_projections, "~> 1.4"}
      ]
    end
  2. Generate an Ecto migration in your app:

    $ mix ecto.gen.migration create_projection_versions
  3. Modify the generated migration, in priv/repo/migrations, to create the projection_versions table:

    defmodule CreateProjectionVersions do
      use Ecto.Migration
    
      def change do
        create table(:projection_versions, primary_key: false) do
          add(:projection_name, :text, primary_key: true)
          add(:last_seen_event_number, :bigint)
    
          timestamps(type: :naive_datetime_usec)
        end
      end
    end
  4. Run the Ecto migration:

    $ mix ecto.migrate
  5. Define your first read model projector:

    defmodule MyApp.ExampleProjector do
      use Commanded.Projections.Ecto,
        application: MyApp.Application,
        repo: MyApp.Projections.Repo,
        name: "example_projection"
    end

Refer to the Usage guide for more detail on how to configure and use a read model projector.