Skip to content

Instantly share code, notes, and snippets.

@chrismccord
Last active September 23, 2024 03:02
Show Gist options
  • Save chrismccord/e53e79ef8b34adf5d8122a47db44d22f to your computer and use it in GitHub Desktop.
Save chrismccord/e53e79ef8b34adf5d8122a47db44d22f to your computer and use it in GitHub Desktop.

Revisions

  1. chrismccord revised this gist Apr 22, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions phx-1.5-upgrade.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    # Phoenix 1.4.x to 1.5.0-rc upgrade instructions
    # Phoenix 1.4.x to 1.5.0 upgrade instructions

    Phoenix 1.5 requires Elixir >= 1.7. Be sure your existing version is up to date by running `elixir -v` on the command line.

    ## Install the new phx.new project generator

    ```console
    $ mix archive.uninstall phx_new
    $ mix archive.install hex phx_new 1.5.0-rc.0
    $ mix archive.install hex phx_new 1.5.0
    ```

    ## Bump your deps
    @@ -18,7 +18,7 @@ Update your Phoenix and Phoenix PubSub deps to their latest versions.
    ```elixir
    defp deps do
    [
    {:phoenix, "~> 1.5.0-rc.0", override: true},
    {:phoenix, "~> 1.5.0"},
    {:phoenix_pubsub, "~> 2.0"},
    {:plug_cowboy, "~> 2.1"},
    ...
  2. chrismccord created this gist Apr 16, 2020.
    80 changes: 80 additions & 0 deletions phx-1.5-upgrade.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,80 @@
    # Phoenix 1.4.x to 1.5.0-rc upgrade instructions

    Phoenix 1.5 requires Elixir >= 1.7. Be sure your existing version is up to date by running `elixir -v` on the command line.

    ## Install the new phx.new project generator

    ```console
    $ mix archive.uninstall phx_new
    $ mix archive.install hex phx_new 1.5.0-rc.0
    ```

    ## Bump your deps

    Update your Phoenix and Phoenix PubSub deps to their latest versions.

    *Note:* The outdated Phoenix.Endpoint.CowboyAdapter for Cowboy 1 is deprecated. Please make sure `{:plug_cowboy, "~> 2.1"}` is specified in your deps.

    ```elixir
    defp deps do
    [
    {:phoenix, "~> 1.5.0-rc.0", override: true},
    {:phoenix_pubsub, "~> 2.0"},
    {:plug_cowboy, "~> 2.1"},
    ...
    ]
    end
    ```

    ## PubSub 2.0 Changes

    Phoenix.PubSub 2.0 provides a simpler, more extensible, and more performant Phoenix.PubSub API. For users of Phoenix.PubSub, the API is the same, but the pubsub server being started by the endpoint has been deprecated in favor of starting the PubSub server yourself. This prevents race conditions on startup and decouples the PubSub system from the endpoint.

    First, replace your endpoint's `:pubsub` config with a new `:pubsub_server` key in `config/config.exs`:

    ```diff
    config :my_app, MyApp.Endpoint,
    url: [host: "localhost"],
    ...,
    - pubsub: [name: MyApp.PubSub, adapter: Phoenix.PubSub.PG2],
    + pubsub_server: MyApp.PubSub,
    ```

    Next, update your `lib/my_app/application.ex` supervision tree to start its own PubSub:

    ```diff
    children = [
    + # Start the PubSub system
    + {Phoenix.PubSub, name: MyApp.PubSub},
    # Start the Endpoint (http/https)
    MyApp.Endpoint,
    ]
    ```

    ## Update your layouts

    Rendering the child template from layouts is deprecated. Replace:

    <%= render(@view_module, @view_template, assigns) %>

    With the new `@inner_content` assign:

    <%= @inner_content %>


    ## Update your Tests

    Using `Phoenix.ConnTest` is deprecated, replace usage:

    use Phoenix.ConnTest

    with:

    import Plug.Conn
    import Phoenix.ConnTest

    *Note*: for most applications, this will be located in a single place in `test/support/conn_case.ex`

    ## Add the new Phoenix LiveDashboard (optional)

    The new LiveDashboard project provides real-time performance monitoring and debugging tools for Phoenix developers. Follow the steps in the project readme to include it in your existing applications https://github.com/phoenixframework/phoenix_live_dashboard