I know I can run artisan migrate to execute my created migrations in my local environment, but:
How can I run migrations in a hosting, if I don't have command line? (this also applies to migrate:install command so I can make them available)
You can call it from your application:
Artisan::call('migrate');
Related
I have run the following Laravel command PHP artisan make: migration add_category_id_to_posts but I need to run the following command as well PHP artisan make: migration add_category_id_to_posts --table=posts then I need to roll back the first command and run the second command. then How?
As mentioned by Fatima Mazhit, this command cannot be rolled back.
Simply delete the newly created add_category_id_to_posts migration file and run php artisan make:migration add_category_id_to_posts --table=posts.
You need to delete the earlier created migration manually and run the same command again after making appropriate changes in your migration. Or simply run php artisan migrate:rollback, will do your task.
go to your database/migration/your migration
delete the migration you recently created, and then run the command again like so:
php artisan make:migration add_category_id_to_posts --table=posts.
note: you can rollback your migrations if you migrate your migrations on the command : php artisan migrate then you can rollback by php artisan migrate:rollback
I have a laravel app with api. I use Passport to authenticate and manage tokens. On my mac everything work, but when i deploy it and run php artisan migrate it only migrate files that in project/database/migrations. There is another migrations files in project/vendor/laravel/passport/database/migrations there are dont migrate on server, but migrate on my local machine.
Maybe there are some permission problems. You could check that with ls -l on the project/vendor/ directory.
Another way is to publish the migrations
php artisan vendor:publish --tag=passport-migrations
I have created some Command files into my Laravel Application. Laravel version is 5.2. I set command like: get:email in the Command file. Also call the Command file into Kernel.php. After that I can see the artisan command list by typing the command php artisan list. as like as below:
//output
get:email
And I changed the command title get:email to get-bq:email. When I run the command php artisan get-bq:email -- its working nicely. Also I can see the list by typing the command php artisan list::
//output
get-bq:email
Issue / Problem: Both commands are working. But I won't to work with both of them. I have done the following things:
modified command file as well as command
run composer dump-autoload -o
run composer update
remove vendor and storage folder then run composer update again.
Still the old command is working into my system.
What I want: How May I remove my old commands from my Laravel(5.2) application?
Run these commands:
php artisan cache:clear
php artisan config:clear
These commands will clear app cache and config cache and recreate it.
I've had the same problem recently.
Repoeatedly tried
php artisan cache:clear
php artisan config:clear
and the cached Kernal command wouldn't clear.
In desperation i killed the queue worker terminal and restarted the queue with the command
php artisan queue:work
The issue stopped.
When I migrate the table, the php artisan migrate does not work.
Use composer.
Navigate to the root directory of the project. Run,
php artisan october:up
if you want to roalback you can run
php artisan october:down
Be sure to use composer in the project directory
php artisan migrate:refresh php artisan migrate:rollback php artisan migrate --force are some cmd's you could try. I don't know if this helps you otherwise please explain your question a bit more.
Go to the root directory of your project in command prompt and run these commands
To reset the current migrations if there are some php artisan migrate:reset
then run php artisan migrate
I was wondering if there's a way to get the resultant mysql instructions from the command php artisan migrate.
This is needed because on my production server I can run mysql commands from PhpMyAdmin but I'm not allowed to run terminal scripts.
So my idea was to run php artisan migrate on my local environment and get the resultant mysql instructions to import "by hand" on production.
You can call Artisan from code as #maximl337 mentioned but in case you want to look only show SQL that will be executed (without running it), you can use --pretend option this way:
php artisan migrate --pretend
and you will get this way the whole SQL that would be executed running migrations.
Try calling Artisan command via code:
Route::get('/migrate', function () {
Artisan::call('migrate', [
'--force' => true,
]);
})->middleware(['admin']);
https://laravel.com/docs/5.1/artisan#calling-commands-via-code