4

I'm pretty new to Laravel. I made a to do application as a school assignment. We have to use migrations to create our database.

I created 2 tables using migrations. My questing is: if you run the project for the first time on your pc, is there a way that the database is automatically created?

Because at this moment, I have to create the empty database first (manually in phpmyadmin) before running the migrations.

2
  • Possible duplicate of stackoverflow.com/questions/16123888/… ? Commented Jan 11, 2015 at 11:20
  • @Crembo, no my questing is not how to generate tables automatically. I want to know there is a possible way to generate the database AND tables automatically. Commented Jan 11, 2015 at 11:32

1 Answer 1

1

Everything you can do with SQL is possible in Laravel. So yes:

DB::statement('CREATE DATABASE your_db_name');

However you might not be able to do this in a migration because of the migrations table that's needed (although I'm not sure about this)

You could check this post about using a command to create a new db

Sign up to request clarification or add additional context in comments.

Comments

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.