I have followed the tutorial (here) to setup my app. Then I tried to replicate the steps to create more tables, so I ran a few command in the terminal like:
php artisan migrate:make create_generalUserInfo_table
Then in the create_generalUserInfo_table file I added:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateGeneralUserInfoTable extends Migration {
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('generalUserInfo', function($table){
$table->increments('id');
$table->integer('user_id');
$table->string('firstname', 100);
$table->string('lastname', 100);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::drop('generalUserInfo');
}
}
Then Back to terminal I ran:
php artisan migrate:refresh
It is adding the migrants but the tables are not being create in mysql. the Users table from the initial tutorial was created
Migrated: 2015_01_28_055418_create_users_table
Migrated: 2015_01_28_213951_create_imprints_table
Migrated: 2015_01_28_214023_create_generalUserInfo_table
Migrated: 2015_01_28_214103_create_roles_table
Migrated: 2015_01_28_214114_create_role_user_table
Migrated: 2015_01_28_214146_create_comments_table
Migrated: 2015_01_28_214159_create_books_table
Try to change this line:
Schema::create('generalUserInfo', function($table){
to
Schema::create('generalUserInfo', function(Blueprint $table){
and run the migration command like this:
php artisan migrate
You should also make sure that
your migration table doesn't have those tables inserted as migrated
your database credentials are correct and point to the correct DB
Related
The command in the title return error message below:
Type error: Too few arguments to function
Illuminate\Database\Schema\Builder::create(), 1 passed in
C:\xampp7\htdocs\assurance-web\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php
on line 221 and exactly 2 expected
I installed the framework with the commands:
composer create-project --prefer-dist laravel/laravel assurance-web
version 5.7
Then executed:
php artisan make:migration create_banks_table --create=banks
I was able to run php artisan migrate with no errors. However, then when I run php artisan migrate:refresh I get the error above.
This is "2018_12_04_033726_create_table_banks.php":
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBanksTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('banks', function(Blueprint $table) {
$table->increments('id');
$table->string('bank_name');
$table->string('bank_code');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::dropIfExists('banks');
}
}
Maybe your migration table is compromised.
You can use:
php artisan migrate:fresh
instead of "php artisan migrate:refresh" and the migration will see that it will work.
The "php artisan migrate:fresh" command physically deletes all tables instead of rolling back.
I'm trying to build a laravel application where I have already create all the migration file. But when I tried to run the
php artisan migrate
command, I saw the following Error :
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'atom.users' does
n't exist (SQL: select exists(select * from `users`) as `exists`)
[PDOException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'atom.users' does
n't exist
I tried to update the composer and migrate:rollback But same Error I'm getting whenever I run the commands.Besides that there is no error with the .env files as well.I couldn't find what's the Error, if any one could help me to find the problem ..Thank you.
Here is my user table migration file :
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::drop('users');
}
}
here's my history on the migration of user.
php artisan make:auth
php artisan make:model User
php artisan make:model User --migration
php artisan migrate:install
sudo php artisan migrate:install
sudo php artisan make:migration
sudo php artisan make:migration users
Btw, your migration file seems ok, hope this will help you
If it doesnt, try to "fake" some data in db table, and try again...
Run: php artisan clear-compiled then run your migration again.
I tried to implement the default auth login system in laravel
php artisan make:migration create_users_table
Created Migration: 2016_03_10_115611_create_users_table
On running the above command only migration file is created and not the tables are created.
Also i have tried to reinstall composer but it didn't work
//In 2016_03_10_115611_create_users_table file
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::drop('users');
}
}
on running
php artisan migrate
it took a few amounts of time and returned
[ErrorException]PDO::__construct(): MySQL server has gone away
Thanks to everyone i have not configured the .env file properly so that it doesn't work
What's your MySQL version?
Or you not yet modify .env
Try SQLite and change settings database to sqlite. I think this problem on php extension.
First you have run this command to install migration
php artisan migrate:install
Note :- if you look at database/migrations there will be already two migrations files
2014_10_12_000000_create_users_table.php
2014_10_12_100000_create_password_resets_table.php
php artisan migrate
I'm getting an error on my deployed application:
Base table or view not found: 1146 Table 'ebdb.users' doesn't exist
This leads me to believe my php artisan migrate command isn't working, and the users table isn't being created.
This is one of my config files (in my .elasticbeanstalk folder)
container_commands:
00testCommand:
command: "echo test"
01migrateSeed:
command: "php artisan migrate --force"
02seed:
command: "php artisan db:seed --force"
This is my create users migration file:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('email')->unique();
$table->string('referral_id')->unique();
$table->string('referred_by')->nullable()->default(null);
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::drop('users');
}
}
Am I missing something obvious? Is this error not related to my migration? I'd like to know if these commands are even being run, but can't find them in the Elastic Beanstalk environment log.
Any help appreciated, thanks.
move the config file to the .ebextensions folder. it does not belong to the .elasticbeanstalk one
I've created a migration for CreateUserTable successfully.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserTable extends Migration {
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('user', function(Blueprint $table)
{
$table->increments('id');
$table->string('email')->unique;
$table->string('password', 60);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::drop('user');
}
}
but I'm not able to rollback:
$ php artisan migrate:rollback
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'CreateUserTable' not found","file":"C:\\xampp\\htdocs\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Migrations\\Migrator.php","line":301}}
Someone suggested to run below but it give me an other error:
$ composer dump-autoload
Composer could not find the config file: C:\ProgramData\ComposerSetup\bin
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section
Any solution to rollback and avoid this second error related to composer.json? I'[m using Laravel 4 with fresh installation.
Rollback often requires you to run composer dumpautoload first. I've had the same problems in Laravel 5.1.
In your case dumpautoload should be in one word - this way it works for me.
And of course composer should be run in a folder that contains the composer.json file. This would be your Laravel project folder.