Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Elixir 运行EXTO迁移时出错_Elixir_Phoenix Framework_Ecto - Fatal编程技术网

Elixir 运行EXTO迁移时出错

Elixir 运行EXTO迁移时出错,elixir,phoenix-framework,ecto,Elixir,Phoenix Framework,Ecto,我对长生不老药和凤凰是个新手。我试图用mix-exto.migrate为几个迁移文件运行迁移,但它抛出了这个错误 18:27:24.471 [info] == Running FatLobster.Repo.Migrations.CreateRecipeTable.change/0 forward ** (Ecto.MigrationError) cannot execute command outside of block (ecto) lib/ecto/migration/runn

我对长生不老药和凤凰是个新手。我试图用
mix-exto.migrate
为几个迁移文件运行迁移,但它抛出了这个错误

18:27:24.471 [info]  == Running FatLobster.Repo.Migrations.CreateRecipeTable.change/0 forward
** (Ecto.MigrationError) cannot execute command outside of block
    (ecto) lib/ecto/migration/runner.ex:139: Ecto.Migration.Runner.subcommand/1
    _build/dev/lib/fat_lobster/priv/repo/migrations/20160423115340_create_recipe_table.exs:5: FatLobster.Repo.Migrations.CreateRecipeTable.change/0
    (stdlib) timer.erl:197: :timer.tc/3
    (ecto) lib/ecto/migration/runner.ex:25: Ecto.Migration.Runner.run/6
    (ecto) lib/ecto/migrator.ex:121: Ecto.Migrator.attempt/6
    (ecto) lib/ecto/migrator.ex:71: anonymous fn/4 in Ecto.Migrator.do_up/4
    (ecto) lib/ecto/pool.ex:292: Ecto.Pool.with_rollback/3
    (ecto) lib/ecto/adapters/sql.ex:582: Ecto.Adapters.SQL.transaction/8
    (ecto) lib/ecto/pool.ex:244: Ecto.Pool.outer_transaction/6
    (ecto) lib/ecto/adapters/sql.ex:551: Ecto.Adapters.SQL.transaction/3
    (ecto) lib/ecto/migrator.ex:226: anonymous fn/4 in Ecto.Migrator.migrate/4
    (elixir) lib/enum.ex:1088: Enum."-map/2-lists^map/1-0-"/2
    (ecto) lib/mix/tasks/ecto.migrate.ex:63: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
    (elixir) lib/enum.ex:604: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:604: Enum.each/2
    (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
    (elixir) lib/code.ex:363: Code.require_file/2
这就是迁移

defmodule FatLobster.Repo.Migrations.CreateRecipeTable do
  use Ecto.Migration

  def change do
    add :recipe_title, :string
    add :recipe_description,  :string

    add :cover_img, :string
    add :picture_one, :string
    add :picture_two, :string
    add :picture_three, :string

    add :user_id, :integer
    add :upvote_count, :integer
    add :downvote_count, :integer

    timestamps
  end
end

现在,这里到底出了什么问题?我到底错过了什么?是否需要查找特定的内容?

您缺少
创建表(…)
块:

defmodule FatLobster.Repo.Migrations.CreateRecipeTable do
    use Ecto.Migration

    def change do
        create table(:recipes) do
            add :recipe_title, :string
            add :recipe_description,  :text
            add :cover_img, :string
            add :picture_one, :string
            add :picture_two, :string
            add :picture_three, :string

            add :user_id, :integer
            add :upvote_count, :integer
            add :downvote_count, :integer

            timestamps
        end
    end
end

更多信息:

你能发布“CreateRecipeTable”迁移的源代码吗?@Dogbert嗨,我刚刚编辑了这个问题。我可以重现错误<代码>**(FunctionClauseError)在exto.Migration.table/2(exto)lib/exto/Migration.ex:400:exto.Migration.table(“recipes”,[])\u build/dev/lib/my_app/priv/repo/migrations/20160423173600\u create\u recipe.exs:5:MyApp.repo.migrations.CreateRecipe.change/0。。。通过使用字符串而不是原子。也就是说,您可能已经有了
创建表(“菜谱”)的操作
,它应该是
创建表(:菜谱)的操作
。这是我肯定错过的。但我仍然没有得到结果。@code.prio错误是否相同?新错误是什么?(FunctionClauseError)在exto.Migration.table/2(exto)lib/exto/Migration.ex:363:exto.Migration.table(“recipes”,[])中没有匹配的函数子句_build/dev/lib/fat_lobster/priv/repo/migrations/20160423115340_create_recipe_table.exs:5:FatLobster.repo.migrations.CreateRecipeTable.change/0是的文本类型不合适,因此我将其更改为string@code.prio请在添加新代码和错误后更新您的问题