Zend Basic Tutorial
Zend Forms
Zend Database
Zend Advanced
Doctrine Migrations allow tracking, versioning, and updating your database schema. Think of it like Git for your database.
|
Feature |
Explanation |
|---|---|
|
Version Control |
Track schema changes with version numbers. |
|
Rollbacks |
Revert unwanted changes easily. |
|
Deployment |
Sync production DBs with codebase changes safely. |
Doctrine installation setup link
Create User.php in (module\Application\src\Entity\User.php)
namespace Application\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="user")
*/
class User
{
/** @ORM\Id @ORM\GeneratedValue @ORM\Column(type="integer") */
private $id;
/** @ORM\Column(type="string", length=255) */
private $email;
/** @ORM\Column(type="string", length=255) */
private $password;
}
php vendor/bin/doctrine-migrations diff
This creates a file like:
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(255), password VARCHAR(255), PRIMARY KEY(id))');
}
php vendor/bin/doctrine-migrations migrate
To rollback the previous change:
php vendor\bin\doctrine-migrations migrate prev