Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by whitelisting our website.

How to get or export SQL query from Laravel migration file?

Export SQL query from Laravel migration file

Hey there.. hope you are facing the same problem as I am facing to update the DB from phpMyAdmin.. and no ssh access from Cpanel to run the migration command on the terminal.

And you are in the right place.. here is the solution to get the dump query from the Laravel migration file.


php artisan migrate –path=database/migrations/2022_06_08_201508_create_currencies_table.php –pretend > backup/currency.sql



create table `currencies` (
  `id` bigint unsigned not null auto_increment primary key,
  `currency_code` varchar(20) not null,
  `currency_symbol` varchar(20) not null,
  `exchange_rate` decimal(10, 2) not null,
  `is_default` tinyint(1) not null default ‘0’ comment ‘1=Yes, 0=No’,
  `status` tinyint(1) not null default ‘1’ comment ‘1=Active, 0=Inactive’,
  `created_by` int unsigned null,
  `updated_by` int unsigned null,
  `created_at` timestamp null,
  `updated_at` timestamp null
) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’ engine = InnoDB;



  1. php artisan migrate: it is the command to migrate the database.
  2. –path: is the location/path of the migration file. This is not mandatory. In my case, I only want to migrate a specific migration.
  3. — pretend: is used to output the query on the terminal to store or used in phpMyAdmin.
  4. > backup/currency.sql: is used to save the dump SQL file in the backup folder and this part is not mandatory. If you don’t want to save it as a file, remove/ignore this part of the command.


Hoping this information help and saves your time. You can share this article because sharing is caring 🙂


#HappyCoding #SharingIsCaring


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Wordpress Social Share Plugin powered by Ultimatelysocial