For a new Laravel project, I need to use an existing MySQL database (176 tables). I don't want to create a Laravel migration for each existing table, so I've made an export of the database structure to a sql file.
In a migration I want to execute the SQL file, like so:
public function up()
{
DB::unprepared(file_get_contents('/path/to/file.sql'));
}
unprepared returns true but it seems the import will not be (fully) executed. No error, no effect (sometimes, there are 1 or 2 tables created, for example after dropping and recreating the database before executing the sql file).
When I execute this file with mysql source /path/to/file.sql, the import works fine (some errors by version difference will be reported, but the execution continues).
My question: for testing purposes, I want to creating the 176 old/existing tables from an SQL file during the migration process. I need to alter some tables during the migration process.
I don't want to create a migration for each table.