Using Laravel Migrate how can I refresh a single database? - php

I have 2 databases and I used the following command:
php artisan migrate:refresh
This cleared both databases and rebuilt the tables, however I'd like to do this only for a single database. How can I do this?

Try using the --database option:
php artisan migrare:refresh --database=connectionName
For future reference, you can get help with arguments and options for any Artisan command by running:
php artisan help CommandName

Related

How to Migrate Laravel solution from MS SQL Server to MySQL

I am newbie to Laravel 5 and 6. I have very specific question, solution was developed using laravel and MSSQL server as DB server. Now I want to change Database from MSSQL to MySQL, is there any automated way to achieve this ? Or how cumbersome is this process and what will be the step to achieve this?
Thanks & regards
If with solution, you mean to migrate the logic and don't care about data.
Simply create a new database in MySQL.
Config .env file to use said db, for example:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my-db-name-here
DB_USERNAME=root
DB_PASSWORD=
Clear all cache, like:
php artisan config:clear --no-ansi
php artisan cache:clear --no-ansi
composer dump-autoload
php artisan view:clear --no-ansi
php artisan route:clear --no-ansi
Test if the routes work, like:
php artisan route:list --no-ansi
At last, recreate DB structure, like:
php artisan migrate --no-ansi
If your project is new, there are no seed, else another useful command would be:
php artisan db:seed --no-ansi
But if Data are required:
The steps are basically the same as above;
But either you need to follow instructions at:
https://www.thegeekstuff.com/2014/03/mssql-to-mysql/
Which shows how to directly copy data from source DB to destination.
Or you will need to:
Export your MS SQL Server as SQL-file (or zip).
Find/pick a tool, which converts SQL-files from "MS SQL Server" syntax/format to "MySQL" format.
Import resulting SQL-file in MySQL.

php artisan migrate - tables not created in phpMyAdmin

I am following this tutorial here https://www.youtube.com/watch?v=Jbt5bEgv_QM and got stuck in the php artisan migrate part because of this issue. I'm not sure if it's compatibility issue or something. I am fairly new to laravel.
Here's the database.php file and .env file.
UPDATE: i managed to perform the migration using the solutions provided by the user PHP. However, i couldn't find the table in my phpMyAdmin. do i need to change mySQL root password for that? i have actually set the password but in .env and database.php files i left it blank because the migration works that way. if i set the actual password in both files, I'd get access denied error.
Here's the migration files...
php artisan migrate:rollback then run php artisan migrate.
If you make changes to your migration files, simply run php artisan migrate:refresh
1)First you have to Create your related Database.
2)Then:php artisan cache:clear
3)Now run php artisan migrate:install

php artisan serve get cached or does not react while updating code in Laravel 5.5. After a restart, it works again each time

My IDE is phpstorm and running on WAMP Server. While coding, it does not show the expected response, always returns the previously requested response (In postman). Each time, I need to close 'php artisan serve' with CTRL+C and then run again to get the expected response.
I tried changing IDE, changing port but it does not work. Of course, I tired to save manually ( CTRL+S) but the problem persists.
I also tried the following commands:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
composer dump
But the problem still persists.
The issue might be the composer command. Please, have a look on my setup in the Makefile:
run:
php artisan config:cache
php artisan config:clear
php artisan cache:clear
composer.phar dump-autoload -o
php artisan serve
And it's ready to go with a Laravel's "clean build".
Can you try with a diferent request tool, like doing a GET on your browser?
Or just create a new endpoint to test that. This way you make sure that changes are being saved.
I recommend you make tests to see if:
the problem is on your postman (a cache maybe?);
the problem is that your code isn't being saved;
the problem is on your local server (a persistent cache?);
My tip is: Try to eliminate the possible causes and you should achieve an answer.
Let´s try to make sure about above items and if them are ok, we check possible another ones.

How to migrate table in october cms?

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

How to get resultant mysql instructions from 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

Categories