diff --git a/README.md b/README.md index 46f3e05..7eba417 100644 --- a/README.md +++ b/README.md @@ -200,9 +200,22 @@ return Car::migration(function (Blueprint $table) { }) ``` +An end-developer can also add multiple callbacks programmatically if needed, which are great to separate concerns. + +```php +use MyVendor\MyPackage\Models\Car; +use Illuminate\Database\Schema\Blueprint; + +return Car::migration( + fn ($table) => /* ... */, + fn ($table) => /* ... */, + fn ($table) => /* ... */, +); +``` + > [!TIP] > -> If you don't want to support additional columns, it's fine. If the end-developer adds a callback, it won't be executed regardless. +> You can omit the `addColumns()` call if you don't want to support additional columns, as any added callback won't be executed. ### Morphs @@ -234,7 +247,7 @@ return Car::migration()->morph('ulid', 'custom_index_name'); ### After Up & Before Down -The `CustomizableMigration` contains two methods, `afterUp()` and `beforeDown()`. The first is executed after the table is created, while the latter is executed before the table is dropped. This allows the developer to run custom logic to enhance its migrations, or avoid failing migrations. +An end-developer can execute logic after the table is created, and before the table is dropped, using the `afterUp()` and `beforeDown()` methods, respectively. This allows the developer to run enhance the table, or avoid failing migrations. For example, the end-developer can use these methods to create foreign column references, and remove them before dropping the table. @@ -251,6 +264,10 @@ return Car::migration() }); ``` +> [!IMPORTANT] +> +> The `afterUp()` and `beforeDown()` adds callbacks to the migration, it doesn't replace them. + ## Package documentation If you plan to add this to your package, you may also want to copy-and-paste the [MIGRATIONS.md](MIGRATIONS.md) file in your package. This way developers will know how to use your model and migrations. Alternatively, you may also just copy its contents, or link back to this repository.