我无法使用Symfony 4上的Doctrine Migration捆绑包。我在Docker容器中启动Web应用程序。在容器启动后要执行迁移的尝试上,迁移失败并显示“连接被拒绝”异常。但是:
示例:
root@3af0cf70b099:/var/www# php bin/console doctrine:migration:migrate -qn
In StreamSocketClient.php line 225:
Failed to write to socket: fwrite(): send of 185 bytes failed with errno=111 Connection refused (8)
doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]
root@3af0cf70b099:/var/www# php bin/console dbtest
[OK] Found user with login demo
root@3af0cf70b099:/var/www# php bin/console doctrine:migration:migrate -qn
In StreamSocketClient.php line 225:
Failed to write to socket: fwrite(): send of 185 bytes failed with errno=111 Connection refused (8)
doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]
root@3af0cf70b099:/var/www#
仅在容器启动后20秒钟以上才能进行迁移。
我的学说配置:
doctrine:
dbal:
# configure these for your database server
driver: '%env(DB_DRIVER)%'
server_version: '%env(DB_SERVER_VERSION)%'
charset: '%env(DB_CHARSET)%'
default_table_options:
charset: '%env(DB_CHARSET)%'
collate: '%env(DB_COLLATION)%'
mapping_types:
enum: string
types:
phone_number: Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType
url: 'mysql://%env(DB_USER)%:%env(MYSQL_ROOT_PASSWORD)%@%env(DB_HOST)%:%env(DB_PORT)%/%env(MYSQL_DATABASE)%'
orm:
auto_generate_proxy_classes: false
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
文档迁移配置为默认设置:
doctrine_migrations:
dir_name: '%kernel.project_dir%/src/Migrations'
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
namespace: DoctrineMigrations