when i make command php artisan make:migration creata_companies_table it create table but has no schema function no id no timestamp just up and down function. any idea ?? i'm using laravel 5.4 here's my companiestable
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateCompaniesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { // } /** * Reverse the migrations. * * @return void */ public function down() { // } }php artisan make:migration table_name_here
Only generates the migration file/class and its stubbed methods up()/down(). You need to code out your schema.
https://laravel.com/docs/5.4/migrations#migration-structure
public function up()
{
Schema::create('companies', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}
When your schema is done within the up() method, you can then run the migration with
php artisan migrate
Migration only creates the Migration Class. You need to create the schema by yourself in the up function. It's easy. You can get a sample schema from the documentation.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community