凤凰城:**(混合)无法找到迁移目录" priv / repo / migrations"

时间:2017-02-11 13:34:59

标签: phoenix-framework circleci

在Circle CI上运行我的测试以获得干净生成的Phoenix项目时,我得到:

$ mix test
==> connection
Compiling 1 file (.ex)
Generated connection app
==> gettext
Compiling 1 file (.erl)
Compiling 20 files (.ex)
Generated gettext app
===> Compiling ranch
==> poolboy (compile)
==> decimal
Compiling 1 file (.ex)
Generated decimal app
==> poison
Compiling 4 files (.ex)
warning: HashDict.size/1 is deprecated, use maps and the Map module instead
  lib/poison/encoder.ex:283

Generated poison app
==> db_connection
Compiling 23 files (.ex)
warning: module attribute @regulator was set but never used
  lib/db_connection/sojourn.ex:39

Generated db_connection app
==> phoenix_pubsub
Compiling 12 files (.ex)
Generated phoenix_pubsub app
===> Compiling cowlib
===> Compiling cowboy
==> mime
Compiling 1 file (.ex)
Generated mime app
==> plug
Compiling 44 files (.ex)
Generated plug app
==> phoenix_html
Compiling 8 files (.ex)
Generated phoenix_html app
==> phoenix
Compiling 60 files (.ex)
Generated phoenix app
==> postgrex
Compiling 61 files (.ex)
Generated postgrex app
==> ecto
Compiling 69 files (.ex)
Compiling lib/ecto/query/builder/lock.ex (it's taking more than 10s)
Compiling lib/ecto/repo/queryable.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder/filter.ex (it's taking more than 10s)
Compiling lib/ecto/repo/preloader.ex (it's taking more than 10s)
Compiling lib/ecto/migration/runner.ex (it's taking more than 10s)
Compiling lib/ecto/repo/schema.ex (it's taking more than 10s)
Compiling lib/ecto/migration/schema_migration.ex (it's taking more than 10s)
Compiling lib/ecto/adapters/postgres/connection.ex (it's taking more than 10s)
Compiling lib/ecto/changeset.ex (it's taking more than 10s)
Generated ecto app
==> phoenix_ecto
Compiling 4 files (.ex)
Generated phoenix_ecto app
==> martinffx
Compiling 15 files (.ex)
Generated martinffx app
** (Mix) Could not find migrations directory "priv/repo/migrations"
for repo Martinffx.Repo.

This may be because you are in a new project and the
migration directory has not been created yet. Creating an
empty directory at the path above will fix this error.

If you expected existing migrations to be found, please
make sure your repository has been properly configured
and the configured path exists.

但在本地运行相同的命令时,它会成功运行:

$ mix test
....

Finished in 0.1 seconds
4 tests, 0 failures

Randomized with seed 328700

为什么呢?我没有迁移吗?它在本地工作......发生了什么?

circle.yml

machine:
  environment:
    PATH: "$HOME/.asdf/bin:$HOME/.asdf/shims:$PATH"

dependencies:
  cache_directories:
    - ~/.asdf
    - deps
    - _build
  pre:
    - chmod +x ./circle_pre_build.sh
    - ./circle_pre_build.sh

database:
  override:
    - psql -U ubuntu < ./db/init-test.sql

test:
  override:
    - elixir -v
    - mix deps
    - node -v
    - npm -v
    - mix test

circle_pre_build.sh

#!/bin/bash

# http://code.parent.co/phoenix-circleci-heroku/
# Ensure exit codes other than 0 fail the build
set -e

# Check for asdf
if [ ! asdf | grep version ]
then
    git clone https://github.com/HashNuke/asdf.git ~/.asdf;

    # Add plugins for asdf
    asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git
    asdf plugin-add elixir https://github.com/HashNuke/asdf-elixir.git
fi

# Install erlang/elixir
erlang_version=$(awk '/erlang/ { print $2 }' .tool-versions)
asdf install erlang $erlang_version
elixir_version=$(awk '/elixir/ { print $2 }' .tool-versions)
asdf install elixir $elixir_version

# Get dependencies
yes | mix deps.get
yes | mix deps.compile

# Exit successfully
exit 0

INIT-TEST.SQL

DROP DATABASE martinffx_test;
DO $$
BEGIN
  IF NOT EXISTS (
     SELECT *
     FROM   pg_catalog.pg_user
     WHERE  usename = 'martinffx') THEN

     CREATE ROLE martinffx LOGIN PASSWORD 'password';
     ALTER USER martinffx CREATEDB;
   END IF;
END
$$;

软件版本

$ elixir -v
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:32:2] [async-threads:10] [hipe] [kernel-poll:false]

Elixir 1.4.0

$ mix deps
* connection 1.0.4 (Hex package) (mix)
  locked at 1.0.4 (connection) a1cae722
  ok
* fs 0.9.1 (Hex package) (rebar)
  locked at 0.9.2 (fs) ed17036c
  ok
* gettext 0.13.1 (Hex package) (mix)
  locked at 0.13.1 (gettext) 5e0daf4e
  ok
* ranch 1.3.2 (Hex package) (rebar3)
  locked at 1.3.2 (ranch) e4965a14
  ok
* poolboy 1.5.1 (Hex package) (rebar)
  locked at 1.5.1 (poolboy) 6b461639
  ok
* decimal 1.3.1 (Hex package) (mix)
  locked at 1.3.1 (decimal) 157b3ced
  ok
* poison 2.2.0 (Hex package) (mix)
  locked at 2.2.0 (poison) 4763b69a
  ok
* db_connection 1.1.0 (Hex package) (mix)
  locked at 1.1.0 (db_connection) b2b88db6
  ok
* phoenix_pubsub 1.0.1 (Hex package) (mix)
  locked at 1.0.1 (phoenix_pubsub) c10ddf62
  ok
* cowlib 1.0.2 (Hex package) (rebar3)
  locked at 1.0.2 (cowlib) 9d769a1d
  ok
* cowboy 1.1.2 (Hex package) (rebar3)
  locked at 1.1.2 (cowboy) 61ac29ea
  ok
* mime 1.0.1 (Hex package) (mix)
  locked at 1.0.1 (mime) 05c39385
  ok
* plug 1.3.0 (Hex package) (mix)
  locked at 1.3.0 (plug) 6e2b01af
  ok
* phoenix_html 2.9.3 (Hex package) (mix)
  locked at 2.9.3 (phoenix_html) 1b5a2122
  ok
* phoenix 1.2.1 (Hex package) (mix)
  locked at 1.2.1 (phoenix) 6dc59224
  ok
* phoenix_live_reload 1.0.8 (Hex package) (mix)
  locked at 1.0.8 (phoenix_live_reload) 4333f9c7
  ok
* postgrex 0.13.0 (Hex package) (mix)
  locked at 0.13.0 (postgrex) e101ab47
  ok
* ecto 2.1.3 (Hex package) (mix)
  locked at 2.1.3 (ecto) ffb24e15
  ok
* phoenix_ecto 3.2.1 (Hex package) (mix)
  locked at 3.2.1 (phoenix_ecto) 6cf11d59
  ok

$ node -v
v4.2.6

$ npm -v
2.14.12

1 个答案:

答案 0 :(得分:2)

git不存储不包含任何文件本身或任何子目录的目录。由于您的迁移目录没有任何迁移,即使您将整个应用程序添加并提交到git中,当您将git repo克隆到另一个目录时,您也会发现priv/repo/migrations目录不存在。 Ecto要求存在此目录,这就是您收到错误的原因。

为了让git创建priv/repo/migrations,您可以在priv/repo/migrations内创建并提交一个虚拟文件。您还可以将以下行添加到预构建shell文件(mix compile之前)以创建该目录(如果它不存在):

mkdir -p priv/repo/migrations
相关问题