1

Background:

(1) I use mysql workbench to design my database.

(2) Then I use "Synchronize Model" tool in mysql workbench to apply my modification to mysql database.

(3) Finally I use symfony doctrine:build-schema command to generate schema.yml according to database(For some legacy reason, I have to use Symfony 1.4).

Here comes the problem: I wanna add actAs: { Timestampable: ~ } to schema.yml, but symfony doctrine:build-schema command cannot do that.

The solution I can imagine is to write a shell to edit schema.yml. Clearly this is not an elegant solution.

Any suggestion is greatly appreciated.

4

2 回答 2

0

1)命令给出什么错误symfony doctrine:build-schema

2) 在 schema.yml 中尝试这样的代码

Something:
  actAs:
    Timestampable:
  columns:
...
于 2013-10-18T12:47:12.640 回答
0

我使用MySQL Workbench Schema Exporter(一个开源 PHP 库项目)来节省时间并完成建模过程中的所有数据库模型定义任务。查看此安装教程

使用 MySQL Workbench Schema Exporter,您可以使用表注释来定义表行为。要为表定义添加时间戳行为,请将其放在您的注释中:

{MwbExporter:actAs}actAs: [Timestampable]{/MwbExporter:actAs}

然后使用MySQL Workbench Schema Exporter将您的模型(*.mwb 文件)导出到 YAML(*.yml 文件)并将其放置在 ./config/schema/ 文件夹中以创建 sql 脚本,然后将其加载到已配置的数据库中与 symfony。这很简单!像这样:

  1. 将模型导出到 YAML

    php bin/mysql-workbench-schema-export your_model.mwb

  2. 将 schema.yml 结果文件复制到 ./config/schema 文件夹位置

  3. 创建一个sql脚本

    php symfony doctrine:build-sql

  4. 现在使用以下方法物理构建您的模型:

    php symfony doctrine:build-model

于 2014-08-29T04:52:37.907 回答