I had started a phoenix project with --database mysql, then I decided that I want to use postgresql. After the switch to postgrex my ecto migrations scripts which were running fine with mariaex are now throwing syntax errors in postgrex.
I have updated my config Repo adapters and am able to create a database via ecto.create, is there anything else am missing?
The exception raised is as below:
[wogembo@hostname myapp] $ mix ecto.migrate
13:59:40.504 [info] == Running Contrebate.Repo.Migrations.CreateSubscriber.change/0 forward
13:59:40.504 [info] create table subscribers
** (Postgrex.Error) ERROR 42601 (syntax_error): syntax error at or near “(”
(ecto) lib/ecto/adapters/sql.ex:195: Ecto.Adapters.SQL.query!/5
(ecto) lib/ecto/adapters/postgres.ex:86: anonymous fn/4 in Ecto.Adapters.Postgres.execute_ddl/3
(elixir) lib/enum.ex:1623: Enum."-reduce/3-lists^foldl/2-0-"/3
Below is the migration script raising this error:
defmodule Contrebate.Repo.Migrations.CreateSubscriber do
use Ecto.Migration
def change do
create table(:subscribers) do
add :msisdn, :bigint, size: 12
add :first_name, :string
add :middle_name, :string
add :last_name, :string
add :account_id, :bigint
timestamps()
end
create unique_index(:subscribers, [:msisdn])
end
end