Javacadabra
Javacadabra

Reputation: 5758

Installing Sentry2 with Laravel4

I am trying to install Sentry2 with Laravel4 and I've managed to get as far as to include it within the project as a dependency however in terms of the database I am a bit lost. On their website they say:

Note: The database schema is located under vendor/cartalyst/sentry/schema/mysql.sql

And when I go there I see the sql file with various different tables, now this is where I am unsure, do I need to write a migration for each one of these tables or is there a way I can just run it in order to create the required tables?

I'm new to laravel so apologies for the question if it is very simplistic. It just seems impractical to have to write a migration for each table when all of the sql is contained in this file?

Any help is much appreciated!

Upvotes: 0

Views: 82

Answers (1)

Tomas Buteler
Tomas Buteler

Reputation: 4117

First, make sure you have your database / environments properly configured before running migrations. This may be obvious for some, but it's always worth checking. This means making sure you have the connection details and credentials right inside your database.php file, and that it is located in the folder (or root) which will apply to the environment in which you will run the migrations in.

Second, since Sentry has its own migrations, you don't have to write your own. You just need to run the migrations that come with it. Luckily, Laravel has an easy way to do that. Just run this command on your project's root folder:

php artisan migrate --package="cartalyst/sentry"

All required tables will be created automatically. From there, you can write a seed and start testing...

Alternatively, you can copy the included migrations into your projects own migrations folder. This way you can migrate up and down without having to worry what comes from a package and what doesn't. To do so, just run the migrate:publish command.

php artisan migrate:publish cartalyst/sentry

This is a native functionality of the framework, so you can run both commands above with any package that properly includes migrations.

Finally, run the migrations:

php artisan migrate           // Up
php artisan migrate:rollback  // Down

Upvotes: 1

Related Questions