in the last episode we have connected the database with our laravel application
by typing the details on dirty env file but now we need to verify and to verify
beneath the tables here so do we have to create the table directly here no
because we have level and level will take care of everything
so in level we have a migration system so if I go to this folder called
database folder we have three folder but let's talk about the migrations folder
this folder out of the box contained two migration file and this file are just
having name prefixes with a timestamp so you can see it says create user table
create password reset table so these two tables are created by level or
migrations of these are created but what exactly migration means so migrations
are think about migrations like your blueprint of your table or here it says
a schema of table if schema is like what are the fields you want to have in your
table what are the type of these fields how these are connected
do they have nullable field do they are unique and some of the other things you
can define related to your database table this is going to provide a very
unique system because before actually creating the table you are creating the
structure of table this is going to help us in the thinking process of how the
structure of the table it has to be and this is also going to help us in
creating the database or trading the tables actually so once you have these
migrations like we have for password reset once you have these migrations we
can simply run a command to have table of this migrations or this
blueprint to run that command we just need to say PHP artisan migrate this
will going to create the tables from these structure or schema but let's
first get the help for this command so PHP artisan migrate hyphen H will give
you help for that particular command or for anyone you can just type H at the
last - H at the last it will give you help for that so this command PHP
artisan migrate command we'll run the Mike database migration this means it
will create the tables on your data bills according to the schema you can
also define the database name if you want you can force and you can do all
other things which we will see maybe later but for now to checking that how
it's going to create the tables let's just run this command so if I hit enter
here you can see we have some message it says migration table created
successfully then it says migrating and then migrated
obviously all of these are very fast so migrating and magnitude so two tables
are created actually but we're obviously on our database to check that do we have
these tables we need to go to the sequel pro or if you are on Windows you can go
to the PHP my admin hit on refresh and yes we have these two tables but wait we
have three tables one tables is migrations we don't have three
migrations but you know level will track of every migration because if I again
run this PHP artisan migrate it says nothing to migrate how does very well
know that these tables are actually migrated or actually created so yes this
third table very track of everything so if I go on the content you can see it
says migrations this migration is run this migration is run so this means it
will keep track of all the migration just by having a new table and entries
on the new table what tell the migration has already been run so yes we have a
user table and you can see the structure ID name email email verified password
reset remember token created add updated add so all these things are there but
there is created and updated by using this line we have told to our level that
hailer will create the migration width created at end updated and so these
things are going to populate these two fields on every table so if I open
password reset table it just have created at because if I hope n we don't
have similar timestamp it just saying timestamp of created only we just want
to use this but here or the user table we are not providing anything so what
happen if I save created packed but we have made change in migration and if I
try to run it says nothing to migrate yes because from this migration table
let us know that these migrations are done we want to delete previous one and
restructure and wreath we create the new table so for that we need to save PHP
artisan migrate and we will provide : fresh F r e8 n tur and we are having
error because we need to remove this timestamps s from there and now run
fresh come on you can see it says drop all tables that means every table is
deleted and again started migrating so if I now go yes everything is there but
this time user table just have created at field no updated ID simply let's get
back to the updated add run this fresh command once more and yes this time if i
refresh yes updated at is back so in that way you can use migration and if
you to create a new migration yes you can
simply use another command which is like make migration so here lots of make
command but make migration command is there so we need to say PHP artisan make
migration migration and then you need to give the migration name so it's like
create blog table hit enter and this time it says create block table and
block table is here so this is the way you can create it so let's just remove
it from now and in the next episode we will going to see how we can use these
table and see that database connection is really happened so if you want to
learn more advanced things and work on real project head over to between
Stockholm slash courses section where you will have all the udemy courses some
of the premium courses for this website only you can unlock them everything just
by subscribing to this website then you will have all the videos which are add 3
hello high features pure learning we will meet in the next episode till then
good bye