开发者

doctrine how to generate db table from yaml

Is there any command in doctrine which can create db table from YAML. I can see we can create YAML from DB using ./doctrine generate-yaml-db

But How can we achieve the reverse feature of this. from yaml to db.

is there any command something like this 开发者_StackOverflow./doctrine generate-db-yaml


Generating a database from a yaml file must be done in two steps.

  1. Generate the models from the yaml file using Doctrine_Core::generateModelsFromYaml().

  2. Generate the database from the models using Doctrine_Core::createTablesFromModels().

I suggest writing a command-line script to call both these functions in sequence, and to automate a few other necessary steps. Here is the core of the script I use to re-generate my database.

echo 'Deleting old models...';
deleteAllFilesInDirectory(APPPATH . '/models/generated');
echo "done.\n";

echo 'Generating models...';
Doctrine_Core::generateModelsFromYaml('schema.yml', APPPATH . '/models');
echo "done.\n";

echo 'Recreating database tables...';
Doctrine_Core::dropDatabases();
Doctrine_Core::createDatabases();
Doctrine_Core::createTablesFromModels(APPPATH . '/models');
echo "done.\n";

echo 'Loading data...';
Doctrine_Core::loadData('autoload.yml', 'true');
echo "done.\n";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜