spatie / laravel-medialibrary

Associate files with Eloquent models
https://spatie.be/docs/laravel-medialibrary
MIT License
5.78k stars 1.08k forks source link

fix: Add drop functionality to media table migration on rollback #3614

Closed shojibflamon closed 6 months ago

shojibflamon commented 6 months ago

Hi @freekmurze,

The package is fantastic and saves a lot of time on media handling. However, I encountered an issue when rolling back and re-running migrations. It caused an exception: General error: 1 table "media" already exists. This indicates the table isn't dropped on rollback.

This PR adds the drop table functionality during rollback to resolve the issue.

Thanks

Nielsvanpach commented 6 months ago

We don't use down migrations in any package / project.

99.9% of the time you are not gonna use a down migration and you’re probably never testing them. Just write an up migration if you want to drop a column again. 👍

shojibflamon commented 6 months ago

Hi @Nielsvanpach, I don't think so that down migration is not useful. In development section we have to do the rollback & fresh/refresh migration functionality several times. Specially in TDD approach or some other works. But without down migration it will be a exception to migration again in the same database. So, what do you think about this? Manually remove the table & do the migration again & again?

image

Thanks.