what is artisan migrate:install use for? - laravel

It is not mentioned in the docs and in the CLI help, it says - Creates the Migration Repository.
What does that mean?
When I run thus command it says - database laravel not found.

Laravel creates a migrations table in your database to keep track of what migrations have already been ran on your database. If you run php artisan migrate:install, this table is created.
This table makes sure that when you run php artisan migrate, migrations that have already been ran on the database are not done again.
When migrating, this table is also created automatically, there is no need to run the install command beforehand.
The reason for your error is probably because you have not set the correct database credentials in either your .env file or config/database.php file.

Related

Accidental deletion on Laravel Migration gives me migration not found

I accidentally deleted a migration file via my IDE manually earlier, after creating it and running php artisan migrate. now when im trying to run php artisan migrate:rollback, i get Migration not found: 2020_03_02_074557_add_dispute_into_company_order . How can i get my migration back?
If the rollback did not execute the task due to missing migration you may have a chance to recover your sql schema from database itself. From that part you can manually create a new migration.
Alternatively you can do as SKR suggested: try clicking 'undo' in your IDE.
You can try:
composer dump-autoload
It just regenerates the list of all classes that need to be included in the project

Creating Schema automatically using migration in Laravel

Is it possible to create schemas automatically in the database when xampp is turning on? There is no information about it in the Laravel documentation, documentation says only how to do it manually by writing the command php artisan migrate.
Xampp includes a script called apache_startup.bat in the root directory, you can add the following line to it
c:\xampp\php\php.exe -f /path/to/laravel/app/artisan migrate
Then when the apache server starts, it should run that the equivalent of php artisan migrate to setup the database.
You can do php artisan make:migration [migration-name] - other than that, you have to fill the rest yourself.

Not work "Migrate" and mysql in laravel project

I install laravel and create project.
I Configed configuration file database and create database in mysql(mysql runnig in wamp server).
I want use migrate for create table in mysql,but i should wait a lot of time and see error.
What shoud i do?
This could help you run these command in terminal:
php artisan migrate --force
The migrate:refresh will roll back all of your migrations then execute the migrate command.this will re-creates your entire database.
php artisan migrate:refresh
This will absolutely help you,run this command:
php artisan migrate:fresh
if it did't help please chick out this:
https://laravel.com/docs/5.7/migrations
Probably you entered your mysql Server credentials in the database config, but you have to edit the .env file. Values in there overwrite config settings.

Laravel migration undefined index

I am using Laravel 5.3.I deleted one of my migration files name 'feature' and everything related to it very carefully like its id from other tables etc.then i manually deleted the table from database.But now while i'm running the command "php artisan migrate:refresh".It's showing error exception with 'undefined index:***_create_features_table'.And when I'm running just 'php artisan migrate'.it shows that it was successful and all the tables successfully appear in the database.but then when i run migrate:refresh all the table disappears.what should i do to completely delete the migration file?
Try this.
First Manually delete the migration file under app/database/migrations/my_migration_file_name.php
Reset the composer autoload files: composer dump-autoload
Modify your database: Remove the last entry from the migrations table
Here is what I did.I cleared all the data from the database including all tables and then ran 'php artisan migrate'..that is how i made it work..But i am looking for a better solution which will not need to delete everything from the database.
Try check that you have the correct migrations first
php artisan migrate:status
Then you can try something like
php artisan migrate:refresh --step=1
And check again the status.
If you have Undefined index error and your migration was made with --path option, then add to your ModuleServiceProvier boot() method:
$this->loadMigrationsFrom(base_path('database/migrations/directory-name'));
in the migration just add $table->index(['column Name 1',''column Name 1']);
With my case, I forgot to do the Laravel migrate before running Infyomlabs to create scaffold!
So one of the reasons for "Undefined index" is that the table is not there yet.

Migration Class CreateSessionTable error 301

i accidentally execute php artisan migrate:session.
and it migrated, i delete the file createSessionTable,
and now i try to execute php artisan migrate:reset and the migrator in laravel still searching for CreateSessionTable.
i already use composer dump-autoload
composer dumpautoload
php artisan dump-autoload
php artisan dumpautoload
composer update // doesn't resolve the problem
it doesn't work anymore.
do you encounter it?
If you deleted the migration file you have two options:
1) Create a new one with the same name 2014_0000_create_session_table.php (the numbers doesn't really matter in this case, and rollback with it, you don't really need to create things in those methods (but you better create a drop method to drop that sessions table for you), you just need the class CreateSessionTable to be available for Laravel. After creating that file you'll need to composer dump.
2) Manually delete the line in the migrations table and also drop the sessions table.
You can also delete all your tables manually and all records on migrations file and then migrate again.

Resources