Creating the database schema
Doctrine is smart enough to generate the database schema corresponding to the entity mapping information.
Note
It's a good practice to always design entities first and to generate the related database schema after that.
To do this, we will again use Command-Line Tools installed in the first chapter. Type this command in the root directory of our project:
php vendor/bin/doctrine.php orm:schema-tool:create
The following text must be printed in the terminal:
ATTENTION: This operation should not be executed in a production environment.
Creating database schema...
Database schema created successfully!
A new table called Post
has been created in the database. You can use the SQLite client to show the structure of the generated table:
sqlite3 data/blog.db ".schema Post"
It should return the following query:
CREATE TABLE Post (id INTEGER NOT NULL, title VARCHAR(255) NOT NULL, body CLOB NOT NULL, publicationDate DATETIME NOT NULL, PRIMARY KEY(id)); CREATE INDEX...