Ewan Delanoy
Ewan Delanoy

Reputation: 1282

Doctrine thinks it has created a table, but it hasn't

I am following the "Getting Started with Doctrine" simple, short tutorial (here )

At some point, there is the following conversation between Doctrine and me :

ewandelanoy$ vendor/bin/doctrine orm:schema-tool:create --dump-sql
CREATE TABLE products (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
ewandelanoy$

So it seems that things works correctly ; when I go look into my database with phpAdmin however, I find that the table has not been created. And indeed, I get error messages when I try to continue with the tutorial and use that table.

How can I "debug Doctrine" in this situation ? It seems that Doctrine fails to connect to the database ?

So here are my configuration details :

<?php
// bootstrap.php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

require_once "vendor/autoload.php";

$paths = array("src/");
$isDevMode = false;

// the connection configuration
$dbParams = array(
    'driver'   => 'pdo_mysql',
    'user'     => 'root',
    'password' => 'root',
    'dbname'   => 'flea_database',
);

$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);

Upvotes: 3

Views: 53

Answers (1)

chalasr
chalasr

Reputation: 13167

To make your dump really create the schema, you have to use :

php vendor/bin/doctrine orm:schema-tool:update --dump-sql --force

The --dump-sql shows you the query, the --force execute it really.

Run the command without options for more informations.

See the Tools part of doctrine documentation

Upvotes: 3

Related Questions