set primary key laravel migration code example Example: laravel migration with primary key $table->string('code', 30)->primary();