Twist Migrations
Migration
To maintain consistency with your existing connection methods and table prefixes, you can use the BaseMigration
abstract class to create migration files.
php
<?php
use Obelaw\Twist\Base\BaseMigration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends BaseMigration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create($this->prefix . 'table_name', function (Blueprint $table) {
//
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists($this->prefix . 'table_name');
}
};
Define migration path
We need to Define the migration path to run this path by our command line
php
<?php
use Filament\Panel;
use Obelaw\Twist\Base\BaseAddon;
use Obelaw\Twist\Concerns\InteractsWithMigration;
use Obelaw\Twist\Contracts\HasMigration;
class AccountingAddon extends BaseAddon implements HasMigration
{
use InteractsWithMigration;
protected $pathMigrations = __DIR__ . '/database/migrations';
public function register(Panel $panel): void
{
//
}
public function boot(Panel $panel): void
{
//
}
}
Twist Migrate
To run all migrations from each addon, you can use the following command:
bash
php artisan twist:migrate
To rollback migrations, you can use the -r
option.