BeniaminoBaggins
BeniaminoBaggins

Reputation: 12433

ecto table not being created

I run mix ecto.migrate and have this file in my migrations:

api/priv/repo/migrations/20180724182549_create_user_table.exs:

defmodule Api.Repo.Migrations.CreateUserTable do
  use Ecto.Migration

  def change do
    create table(:users) do
      add :first_name, :string
      add :last_name, :string
      add :email, :string
      add :u_id, :string
  end

  create unique_index(:users, [:u_id])
end

It does not create the user table. What could the reason be?

Upvotes: 0

Views: 130

Answers (1)

BitParser
BitParser

Reputation: 3968

You're missing the closing end for do:

defmodule Api.Repo.Migrations.CreateUserTable do
  use Ecto.Migration

  def change do
    create table(:users) do
      add :first_name, :string
      add :last_name, :string
      add :email, :string
      add :u_id, :string
    end # this was missing
  end

  create unique_index(:users, [:u_id])
end

Upvotes: 1

Related Questions