Look this image : https://postimg.org/image/4fvu34juz/
When I run php artisan migrate, there is display :
[symfony\component\debug\exception\fatalthrowableerror]
call to undefined method illuminate\database\schema\blueprint::textarea<>
Any solution to solve my problem?
Update :
Code :
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFlightTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
//
Schema::create('flights', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('airline');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
//
Schema::drop('flights');
}
}
It means there is no function named textarea() in class Blueprint. Remove code that call it.
Related
I'm learning Laravel and migrating a database table with
php artisan migrate
then I get an error
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\Database\Schema\Blueprint::create_table()
Where does it come from?
Here is the code of the migration:
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTodoTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
//
Schema::create('todos', function (Blueprint $table) {
$table->increments('id');
$table->string('text');
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
//
Schema::dropIfExists('todos');
}
}
Laravel doesn't have create_table method. This means you've tried to use this name somewhere instead of using create.
So, search for create_table, change it to create. Then run composer du and php artisan migrate commands.
migrate generates the exception after pivot migration of Laravel 5.3.
schema1 : software_houses
schema2 : skill_domains
I generated the command make:migration:pivot skill_domains software_houses
and the migration is created by the name of skill_domain_software_house
but when I execute php artisan migrate
following error occurs :
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'CreateSkillDomainSoftwareHousePivotTable' not found
See this Image
SKILL Domain
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSkillDomainsTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('skill_domains', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::dropIfExists('skill_domains');
}
}
Software House
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSoftwareHousesTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('software_houses', function (Blueprint $table) {
$table->increments('id');
$table->string('name',100)->unique();
$table->string('desc',500);
$table->string('url',100);
$table->string('rating')->default('3');
$table->string('logo')->nullable();
$table->string('city')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::dropIfExists('software_houses');
}
}
Pivot table created after running the make:migration::pivot command
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSkill_domainSoftware_housePivotTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('skill_domain_software_house', function (Blueprint $table) {
$table->integer('skill_domain_id')->unsigned()->index();
$table->foreign('skill_domain_id')->references('id')->on('skill_domains')->onDelete('cascade');
$table->integer('software_house_id')->unsigned()->index();
$table->foreign('software_house_id')->references('id')->on('software_houses')->onDelete('cascade');
$table->primary(['skill_domain_id', 'software_house_id']);
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::drop('skill_domain_software_house');
}
}
Try with below class name line:
class SkillDomainsSoftwareHouses extends Migration
Make sure the file name should be match with class name Documentation.
UPDATE
I think you should try this:
first remove above software_houses,skill_domains from migrations folder also remove from migrations table in your database then follow below steps :
1) php artisan make:migration skilldomain
2) php artisan make:migration softwarehouses
3) php artisan make:migration:pivot skilldomains softwarehouses
4) php artisan migrate
I have created a file Order.php:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
/**
* The table associated with the model.
* #var string
*/
protected $table = 'order';
}
Then I have created a migration, called 2016_01_01_111111_create_orders_table.php:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOrdersTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('order', function (Blueprint $table) {
$table->increments('id');
$table->string('orderIdent');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
//
}
}
Then I did the migration with
php artisan migrate
Then, I wanted to add some fields, created a new migration file called 2016_01_02_111111_alter_orders.php:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AlterOrders extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
//
Schema::table('order', function(Blueprint $table)
{
$table->string('selecteddate');
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
//
}
}
Then again I did
php artisan migrate
But now I get this message in console:
[Illuminate\Database\QueryException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'order' already exists
What do I need to do, to add the new fields to my table?
Thanks in advance!
Adding this as an answer vs a comment to show what needs to be done. Since rollback was done, up needs to be commented out for now.
public function up()
{ /*
Schema::create('order', function (Blueprint $table) {
$table->increments('id');
$table->string('orderIdent');
$table->timestamps();
}); */
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::drop('order');
}
Try this
public function up()
{
//
Schema::table('order', function($table)
{
$table->string('selecteddate');
});
}
remove Blueprint.
Try this :
php artisan migrate:refresh
I am trying to use oauth2-server-laravel with laravel-mongodb. After I generate migration using this command php artisan oauth2-server:migrations I tried to use php artisan migrate. But I got this error.
[ErrorException]
Missing argument 1 for Illuminate\Database\Schema\Blueprint::primary(),
called in
/home/opu/www/cwc_penguins/app/database/migrations/2015_01_19_203037
_create_oauth_scopes_table.php on line 17 and defined
2015_01_19_203037_create_oauth_scopes_table.php Migration code here
<?php
use Illuminate\Database\Schema\Blueprint;
use LucaDegasperi\OAuth2Server\Support\Migration;
class CreateOauthScopesTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
$this->schema()->create('oauth_scopes', function (Blueprint $table) {
$table->string('id', 40)->primary();
$table->string('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
$this->schema()->drop('oauth_scopes');
}
}
Remove this:
->primary()
And it should work.
Or you can change it to ->primary('id') (or whatever the field name is). That's what I did.
I have this migration php file:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCategoriesTable.php extends Migration {
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('categories', function($table)
{
$table->increments('id');
$table->string('name',200);
$table->string('description',200);
$table->boolean('is_disabled');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::drop('categories');
}
}
Then I executed php artisan migrate and got this error:
Fatal error: Illuminate\Filesystem\Filesystem::requireOnce(): Failed opening required 'WWW_DIRECTORY/app/database/migrations/2013_11_23_154547_cre
ate_categories_table.php'
Aynone knows why this can be happening? I'm learning to use Laravel..
You are not declaring your class properly. That .php extension needs to be removed. Instead of
class CreateCategoriesTable.php extends Migration {
use
class CreateCategoriesTable extends Migration {