PhoenixReplay.Storage.Ecto.Migration (PhoenixReplay v0.6.2)

Copy Markdown View Source

Creates and upgrades the table PhoenixReplay.Storage.Ecto stores recordings in.

Call it from a migration in your application:

defmodule MyApp.Repo.Migrations.AddPhoenixReplay do
  use Ecto.Migration

  def up, do: PhoenixReplay.Storage.Ecto.Migration.up(version: 3)
  def down, do: PhoenixReplay.Storage.Ecto.Migration.down(version: 3)
end

Pin the version, so the migration does the same thing after later releases add versions. The table is versioned, and each PhoenixReplay release that changes it adds a version:

  1. the table PhoenixReplay 0.4 created
  2. error_count, tab, viewport, device and source, which the dashboard lists and filters by, and saved_at, which keeps its pages in place
  3. medium, campaign, device_type, browser and release, and the phoenix_replay_marks table of the moments each session reached, all of which the dashboard filters by, and an index on view. Rows saved earlier get their source split into source, medium and campaign, and their device type from their viewport; their browser stays empty.

up/1 runs every version after :from (default 0), up to :version (default the latest); down/1 reverses them. A table made by an earlier release is upgraded with a new migration:

def up, do: PhoenixReplay.Storage.Ecto.Migration.up(from: 2, version: 3)
def down, do: PhoenixReplay.Storage.Ecto.Migration.down(from: 2, version: 3)

The module is a migration itself, creating the latest table, so tools such as Ecto.Migrator.run/4 can run it directly.

Summary

Functions

Reverses the versions up/1 with the same options runs.

The latest version of the table.

Runs the versions after :from, up to :version.

Functions

down(opts \\ [])

@spec down(keyword()) :: :ok

Reverses the versions up/1 with the same options runs.

latest()

@spec latest() :: pos_integer()

The latest version of the table.

up(opts \\ [])

@spec up(keyword()) :: :ok

Runs the versions after :from, up to :version.