spatie / laravel-webhook-client

Receive webhooks in Laravel apps
https://freek.dev/1383-sending-and-receiving-webhooks-in-laravel-apps
MIT License
1k stars 147 forks source link

Migration published missing "down" function, causing migrate issues #185

Closed bfadamm closed 1 year ago

bfadamm commented 1 year ago

Description:

I've discovered an issue with one of the migrations published by the package in our Laravel application. The migration is missing a "down" function, which is causing problems when running php artisan migrate:rollback as the table persists after rolling back and subsequently causes failures when running php artisan migrate again.

Steps to reproduce:

  1. Install the package in a Laravel application.
  2. Publish the migrations using php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations"
  3. Run php artisan migrate to apply the package's migrations.
  4. Run php artisan migrate:rollback to rollback the migrations.
  5. Observe that the table created by the package's migration still exists in the database.
  6. Run php artisan migrate again, which results in an error.

Expected behavior:

When running php artisan migrate:rollback, the migration should have a "down" function to reverse its effects and properly remove the created table from the database. This would allow php artisan migrate to run again without errors.

Actual behavior:

The migration is missing a "down" function, causing the table to persist after rolling back, and subsequent migrations to fail.

Environment:

Additional context:

Please consider adding a "down" function in the migration to properly handle rollbacks and avoid conflicts with other migrations. The "down" function should include the necessary schema operations to drop the table created by the migration.

Example of a "down" function:


public function down()
{
    Schema::dropIfExists('table_name');
}
freekmurze commented 1 year ago

We don't offer down migrations for any of our package, as we think migration down is bad practice.

If you want it, add it to your own project 👍

bfadamm commented 1 year ago

We don't offer down migrations for any of our package, as we think migration down is bad practice.

If you want it, add it to your own project 👍

I'm quite surprised by this response, have you written a blog post to explain why you believe this?

freekmurze commented 1 year ago

Here you go: https://laraveldaily.com/post/still-need-migrations-taylor-says-no