3

I've created a new database with the SQL CREATE DATABASE command to host my application tables. I would now generate the database from my Symony 2.1 project using Doctrine. I already have the correct mapping YML-PHP entities but when I try to use the command

php app/vendors doctrine:schema:create

it fails on a query that I run inside my application. What I don't understand is why it seems that it's trying to boot my bundle and so obviously it fails because the queries that I execute don't find the tables. How can I generate the new database?

Base table or view not found: 1146 Table 'mydatabase.mytable_menu' doesn't exist

1 Answer 1

9

That command only creates the database for you. You will need to run this command to generate the actual database tables for your entities.

php app/console doctrine:schema:update --force
Sign up to request clarification or add additional context in comments.

3 Comments

I tried but I still get the error about the table not found. More specifically, I have a container service which runs that query in the constructor to initialize a variable with the array of records. It seems that trying to initialize the container the query is executed and obviously fails
Shouldn't you be able to just comment out the query while you generate the tables to avoid the error?
It's always good practice to run --dump-sql before the --force flag in order to tell what's being done to the databse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.