Hi…
I am getting the following error when trying to use references() in a migration:
2018-01-30 17:02:33 700006a5c000 Error in foreign key constraint of table migrations_dev/clients:
FOREIGN KEY (`client_group_id`) REFERENCES `client_groups`(`id`), `inserted_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`)) ENGINE = INNODB:
Cannot resolve table name close to:
(`id`), `inserted_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`)) ENGINE = INNODB
Here are my two migrations:
defmodule Migrations.Repo.Migrations.Clients do
use Ecto.Migration
def change do
create table(:clients) do
add :name, :string
add :client_group_id, references ("client_groups")
timestamps()
end
end
end
defmodule Migrations.Repo.Migrations.ClientGroups do
use Ecto.Migration
def change do
create table(:client_groups) do
add :name, :string
timestamps()
end
end
end
I have tried to cut back my migrations to the most basic as possible and there is no issues running ecto.migration without the references() call… As far as I can tell my example matches the documentation for references().
Any ideas?