开发者

How does Doctrine handle changes to the database schema?

In brief, what happens when you add a column to a table? What happens when you remove one?

In more details, suppose you have the following:

class User extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->hasColumn('username', 'string', 255);
        $this->hasColumn('password', 'string', 255);
    }
}

What happens when you add the following line to the setTableDefinition function?

$this->hasColumn('firstname',开发者_如何学Go 'string', 255);

What happens when you delete the following line from the setTableDefinition function?

$this->hasColumn('password', 'string', 255);


You'd want to have a look at Doctrine migrations that allows you to

The Doctrine migration package allows you to easily update your production databases through a nice programmatic interface. The changes are done in a way so that your database is versioned and you can walk backwards and forwards through the database versions.

That will allow you to perform changes to your database without screwing up your data.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜