Ant Build File Migrate Doctrine (asking for yes/no)
-
12-12-2019 - |
Question
So I have this target in my ant build file:
<target name="migrate" description="Migrate the database">
<exec executable="${basedir}/vendor/bin/doctrine-module" failonerror="true">
<arg line="migrations:migrate"/>
</exec>
</target>
The doctrine migrate command is asking a question and expecting yes or no answer before it runs though. So my build fails:
richard@richard-desktop:~/projects/myproject$ ant migrate
Buildfile: /home/richard/projects/myproject/build.xml
migrate:
[exec]
[exec] Doctrine Migrations
[exec]
[exec]
[exec]
[exec]
[exec]
[exec] [RuntimeException]
[exec] Aborted
[exec]
[exec]
[exec]
[exec] migrations:migrate [--write-sql] [--dry-run] [--configuration[="..."]] [--db-configuration[="..."]] [version]
[exec]
[exec]
[exec] WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)
BUILD FAILED
/home/richard/projects/myproject/build.xml:42: exec returned: 1
Total time: 0 seconds
richard@richard-desktop:~/projects/myproject$
How can I make ant automatically answer yes to that question so it runs the migration?
Solution
It was actually very easy:
<target name="migrate" description="Migrate the database">
<exec executable="${basedir}/vendor/bin/doctrine-module" failonerror="true">
<arg line="migrations:migrate --no-interaction"/>
</exec>
</target>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow