My migration failed, so I just ran a query manually in MySQL Workbench.
Is there an artisan command to mark a migration as complete? So that when I run future migrations, it skips the ones I know don't need to be run.
I can list them and their status with this command and see which ones have run and not:
php artisan migrate:status
I can manually insert an entry into the database migrations table probably if no command. ( but not with a migration at the moment :P )
I suppose I could also... delete the migration.
I've just did the following:
Commented out the content of YourMigrationClass::up()
method. Like this:
class AddSessionIdToActivitiesTable extends Migration
{
public function up()
{
/* commenting this out:
Schema::table('activities', function (Blueprint $table) {
$table->integer('session_id')->nullable();
});
*/
}
Run: php artisan migrate
Check it's marked as "Ran?": php artisan migrate:status
(optional) Uncomment the method's content for it to serve as documentation in your VCS.
You wrote that you run the migration's sql directly in the database, so I assume that for you running another 2 statements would be fine too.
With laravel 5.7 (and probably some lower versions) you need to populate the migration information in the database (in the migrations
table).
The information you need is the migration
(the filename without the .php
extension) and the batch
number (to decide which migrations to run at once when rollbacking a migration for instance)
First you have to see wich the last batch number is:
SELECT MAX(batch) from migrations;
Let's say the above query returns 42
, then we have to insert the data with batch number 42 + 1 = 43
Assuming that the migration that you want to mark as run is database/migrations/2019_01_29_091850_update_jobs_table_for_laravel_5_3.php
,
to populate the information you need to run:
-- note that you should not include the .php extension
INSERT INTO migrations VALUES ("2019_01_29_091850_update_jobs_table_for_laravel_5_3", 43);
Then running php artisan migrate:status
will report the migration as run.
May be you can accomplish the task with one query... I'll leave that task open for the comments from the sql experts.
At present (Laravel <= 5.6), There is no command to update the database to mark a migration as run. You'll just have to do so manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With