All tables define as a classes.

Migrations

migration are like version control for your database.

it’s quickly define a scheme for the a table without the need to learn any language.

  • run the migrate: php artisan migrate
  • if tables exists (drop the tables and recreate): php artisan migrate:fresh
  • if any errors – go to database/mirgation inside function up() add this: Schema::defaultStringLength(191);
  • – after then fix run: php artisan migrate:fresh

you can undo the last migration: php artisan migrate:rollback

create your own migration

DB create example

php artisan make:migration create_projects – if you put create in name – laravel will do “Schema::create” to create a new tables. if there isn’t a create in name it will update the tables by using Schema::table .

public function up() {

Schema::defaultStringLength(191);
Schema::create(‘projects’, function (Blueprint $table) {

$table->increments(‘id’);

$table->string(‘title’);

$table->text(‘description’);

$table->timestamps();

});