Issues when trying to migrate - laravel

I am having a problem when trying to make migrate.
MY DATABASE DOES NOT RECEIVE NEW MIGRATION, NO NEW FILES NO UPDATES
From my project;
I do:
php artisan migrate
But nothing shows in my database, I already verify my database and my file .env
Both are correct.

I know you said you verified it, but please check again that the correct database information is entered in your .env file. It should be something like the following for a dev environment:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
You need to edit that data if you haven't and make sure it's correct. You also need to make sure that your database actually exists.
Also make sure you're actually entering the correct command. The general way you should making migrations is:
php artisan make:migration create_example_table --create=example
After that, run
php artisan migrate
Lastly, are you getting any errors in the console? If so, you need to edit your post and post them here.

firts thanks for answering
I had already checked .env file and I replaced database name from my sql (I use phpadmin), and also I changed username and password as I entered on sql server, but there is no migration
I had created a new table using artisan command (besides I have a users table that comes when downloading laravel project). After creating this new table I expected to upload this new one to my database located in sql server, but nothing happen
it shows your users yable already exists, mentions my users tables and not my new table that i just created. It is weird bcz it does not EVEN upload any changes made in default table users.....always answer your table users already exits

Related

Laravel - Moved project now can't login

I have an existing Laravel 5.6 project, I have moved it over to a new Bitnami WAMP installation.
I have migrated the database and seeded it so it contains my user account, but whenever I attempt to log in I get the following error..
these credentials do not match our records
I have confirmed the password is correct and that it can access the database, is there anything else I should be checking?
I am leaning towards it being a configuration issue with the Bitnami install but am slightly lost on where to be checking.
Change .env file, DB name, DB user name And DB Password
composer update
php artisan key:generate

Artisan rollback, Undefined index (file missing)

I'm trying to do a rollback in Laravel 5.4. I deleted a file manually from the migrations folder. Now when I try to rollback I get an error:
[root#xxx]# php artisan migrate:rollback
[ErrorException]
Undefined index: 2017_08_22_204640_create_tasks_table
That file was a test (with a controller and a view), but I'm new on Laravel and didn't know that deleting that file manually would be a problem.
How can repair that now?
Edit: The main goal is to rename a column from a table made with migrations.
I made this migration file:
[root#xxx]# php artisan make:migration rename_nombre_generadora_column --table="admin_generadora" --create
Created Migration: 2017_08_24_160600_rename_nombre_generadora_column
But then I saw that the name of the table was wrong, should be admin_generadoras. I wanted to create a new migration file but I got this error:
[root#xxx]# php artisan make:migration rename_nombre_generadora_column --table="admin_generadoras" --create
[InvalidArgumentException]
A RenameNombreGeneradoraColumn migration already exists.
So how can I undo that migration?
In situations like this I always tend to simply delete whole database and run "correct" migrations again. You have seeds right? You have factories right?
I copy some text I have written before:
Note for migrations and how to do it right (IMHO):
always use migrations to create and update database schema
if you are a lone developer AND there is no production environment set up, just amend the migrations and do database reset (remove all tables) + migrate
if you are a team OR there is production environment already set up, always create new migration
do not bother with down() method that much
Some material from creator & friends of Laravel regarding migrations can be heard in this podcast http://www.laravelpodcast.com/episodes/68236-episode-53-bigger-better around 30 minute mark.
What you need to do now is to understand deeply how migrations work! To do that you need to take a look at migrations table and play with it; play with artisan and migrations related commands. And remember you can update/amend database schema with SQL (that means using some kind of database client like PhpMyAdmin) but also amend/update corresponding migration.
the --table flag just helps you fill out the migration file faster. Just go in to the RenameNombreGeneradoraColumn file and change admin_generadora to admin_generadoras

Laravel - Access denied for user 'homestead'#'localhost

I am learning laravel, and working on a blog application. Anyway, I made my model for articles + migration, and migrated it fine. But now that I want to pull articles from database in my controller, I get "Access denied for user 'homestead'#'localhost".
And yes, I've changed my settings in .env file, and restarted the server. Still wont work. I tried everything from that other thread on this same issue, but nothing worked.
Any help would be appreciated.
EDIT:
Here are the mysql settings in .env file:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=faks_blog
DB_USERNAME=root
DB_PASSWORD=''
If migration worked, then settings must be correct. Otherwise, how would laravel make all those tables?
I also use HeidiSql to access my database, and those login credentials worked.
Just remove empty brackets after DB_PASSWORD
write like this
DB_PASSWORD=
Please tell if it helps
When you make changes to the .env file you should always run php artisan config:cache because Laravel caches config to avoid reading the same files twice.

Laravel 5.2 How to authenticate with a real mysql database

I'm new with laravel, I read the documentation of laravel, but I don't know how I make an authentication with a real mysql database.
I mean, I see that there is a php migration command, but it makes a table in php and not in my database right ?
Actually, I have a mysql database with a user table with login and password.
I'm lost with this framework, because I never used a php framework.
Thanks !!
Edit :
Excuse me, I misspoke and my problem has evolved, how did you to authenticate with a user table already exists in the database by using the Authentication service?
in .env or config>database.php you can set your database and related database connections configurations
after that create migrations and run them it will create database tables in your database as per your .env or config>database.php database configurations.
I think you might need to read again Laravel documentations.
Try the following.
Make sure you have a database create in your MySql.
Check again your .env for: database_host, database_name, database_user, database_password - make sure you have the right
Try bellow code on your route.php
Route::get('/', function () {
if(DB::connection()->getDatabaseName())
{
echo "Yes! successfully connected to the DB: " . DB::connection()->getDatabaseName();
}
});
If above is successful your migration should work.

Laravel migration on correct DB, but data retrieve on wrong DB

I just recently put a project of mine into bitbucket as my start project. Now I cloned this project into another folder. I did the composer install command.
I created a new database for this new project and changed the variables in .env to match the new DB. When I do a 'php artisan migrate' all the tables get built in my new DB, however when I retrieve data, for example posts, it gets the posts from the other DB (used with my other project). I also checked if in the database file it was not set manually to the old DB. So I have no clue what causes this behavior.
Can anyone explain what may be the cause of this?
Thanks

Resources