659 B · text History e569b6d
defmodule CartosnapApp.Repo.Migrations.AddSharingToTrips do
  @moduledoc """
  A trip can be shared by link: `share_token` is the unguessable part of
  `/s/<token>`, null while the trip isn't shared. Stored as is rather than
  hashed so its owner can copy the link again; replacing or clearing it is
  how a link is taken back. `share_promoted_only` limits the shared view to
  the trip's promoted photos.
  """

  use Ecto.Migration

  def change do
    alter table(:photo_trips) do
      add :share_token, :string
      add :share_promoted_only, :boolean, default: false, null: false
    end

    create unique_index(:photo_trips, [:share_token])
  end
end