# Ecto Changeset: modify column type from :string to {:array, :string}

**URL:** <https://forum.elixirforum.com/t/ecto-changeset-modify-column-type-from-string-to-array-string/32209>\
**Category:** Questions\
**Tags:** ecto, ecto-migration\
**Created:** [June 8, 2020, 11:05pm UTC](https://forum.elixirforum.com/t/ecto-changeset-modify-column-type-from-string-to-array-string/32209 "2020-06-08T23:05:02Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![dcrck](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dcrck/32/17170_2.png) [@dcrck](https://forum.elixirforum.com/u/dcrck)\
**Post date:** [June 9, 2020, 1:47pm UTC](https://forum.elixirforum.com/t/ecto-changeset-modify-column-type-from-string-to-array-string/32209/3 "2020-06-09T13:47:00Z")

</div>

Thanks for the suggestions. After sleeping on it, I ended up deciding to pluralize the column name. So this simply became a matter of moving the values from one column to the other.

Here’s what I ended up doing:

```elixir
defmodule MyApp.Repo.Migrations.ConvertColumnToList do
  use Ecto.Migration

  alias MyApp.{Repo, MyTable}
  import Ecto.Query

  def change do
    alter table :my_table do
      add :list_column_name, {:array, :string}, default: []
    end

    flush()

    Repo.all(MyTable)
    |> Enum.each(fn row ->
      row
      |> MyTable.changeset(%{ name: row.name, list_column_name: [row.column_name]})
      |> Repo.update()
    end)

    alter table :my_table do
      remove :column_name
    end

  end
end

```

---

_[View the full topic](https://forum.elixirforum.com/t/ecto-changeset-modify-column-type-from-string-to-array-string/32209)._
