使用Doctrine / Symfony进行小型模式更新的最佳方式是什么? [英] What's the best way to make small schema updates with Doctrine/Symfony?

查看:102
本文介绍了使用Doctrine / Symfony进行小型模式更新的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的问题是,我正在开发一个新的侧面项目,偶尔会发现自己在这里添加一个新的列,在那里我找到了一个新的列。但是,我的数据库已经有现有的数据,我不想运行一个完整的重建和删除我的数据库与每次更改。



我也不想写固定装置。它们令人讨厌,而且在开发过程中使用我的应用程序来插入数据并保持它变得更加容易。我也不想写一个迁移来添加一列或两列,特别是当我这样做很多时。



我唯一的选择是:


  1. 对模式文件进行更改,
    在每个模式更改后擦拭数据库 - 或 -

  2. 更新架构文件
    并手动运行alter $ on
    我的db

最终,我想要要做的是对我的数据库进行更改,并且symfony确定了模式文件应该是什么样子,或者对模式文件进行更改,并且symfony确定了对现有数据库做出的新更改。



请帮忙!



谢谢。第一次使用SO,迫不及待想看看我是否收到回复!

解决方案

看看这篇文章:



您是否可以使用Doctrine从现有表生成迁移?



并且此链接:
http://www.doctrine-project.org / documentation / cookbook / 1_0 / en / code-igniter-and-doctrine:setup-command-line-interface



我们一直在生成通过更改yaml文件,使用generate-migrations-diff选项运行doctrine命令以生成迁移文件,然后使用migrate选项迁移更改。


What's the best way to make small schema updates to your symfony/doctrine application?

My issue is, I'm working on a new side-project and occasionally find myself adding a new column here, a new column there as i find the need. However, my DB already has existing data and I dont want to run a complete rebuild and drop my DB with the changes each time.

I also dont want to write fixtures. They're annoying, and it's much easier to use my application to insert data and keep it around while developing. I also dont want to write a migration to add one or two columns, especially when I'm doing this a lot.

Are my only choices to:

  1. make changes to the schema file and wipe the db after every schema change -or-
  2. update the schema file and manually run alter statements on my db

Ultimately, what I'd like to do is either make changes to my db, and have symfony figure out what the schema file should look like, or make changes to the schema file and have symfony figure out what new changes to make to the existing database.

Please help!

Thanks. First time using SO, can't wait to see if i get a response!

解决方案

Look at this post:

Can you generate a migration from an existing table with Doctrine?

and this link: http://www.doctrine-project.org/documentation/cookbook/1_0/en/code-igniter-and-doctrine:setup-command-line-interface

We have been generating the changes from doctrine by changing the yaml file, running the doctrine command with generate-migrations-diff option to produce a migration file, then using the migrate option to migrate the change.

这篇关于使用Doctrine / Symfony进行小型模式更新的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆