Database Setup and Migrations

Image Upload Service

In this video lesson we tackle our database by setting up the migrations we are going to be using for our database.

Video Information

Hi everyone , welcome back to Laracademy. It's Mickey again and in this video we are going to work on our database for our image service. We can start off by deleting the two migrations that come with Laravel. However, if you are planning to include users in your application just skip this part. The plan for the final release as of right now we are not using any user information, so I am going to delete the two migrations.

Now using our terminal we are going to create a migration. You could skip this step and create a model with a migration, but the model is in the next video so today I am just going to create the migration, however if you want to do both at once you would do the following command.

php artisan make:model Models\Image -m

However, let's just create the migration for now. Also the reason I am including the models directory is to just keep things cleaner.

php artisan make:migraton create_images_table --create=images

Now we can find this new file in database\migrations\. We want a few columns for our table.

$table->string('original_name');
$table->string('storage_name');
$table->bigInteger('views')->default(0);

Now we can save our database migration and before we run our migrate command let's just check out our .env file to ensure our database properties are in there.

Now let's migrate our table structures by running

php artisan migrate

And we are done. We now have a table in our database that will hold all of the image information we need. Thanks for watching.

Do you have a question? Go ahead and ask it below.

Please login to ask your question