Ad
Migration Not Inserting Data To Table?
The below migration is running successfully with no errors but it's not inserting any data do table. Why it can be? can some one tell me what is wrong here?
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddValuesTOBusiness extends Migration
{
public function up()
{
// Schema::table('business', function (Blueprint $table) {
DB::table('business')->insertOrIgnore([[
'id' => 1,
'name' => 'fg',
'description' => 'best IT & software solutions',
'clientAddress' => 'fdgd 682028',
'status' => 'active',
'email' => '[email protected]',
'phone' => 3455645656,
'appInfo' => 'learningApp',
'defaultClient' => true,
'eustardApp' => true,
'sellerCategory' => 'internal',
'created_at' => now()]
]);
// }
}
public function down()
{
// Schema::table('business', function (Blueprint $table) {
DB::table('business')->truncate();
//}
}
}
Ad
Answer
You are not getting any error because you are using "insertOrIgnore", this method does not throw any error but simply ignores and moves forward. Your error is probably some data validation, for example, the id that should be set automatically by the database.
Try using the "insert" method instead and you'll probably get the error you are looking for
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad