protected array $migration = [
/* This table would be created as it contains an 'id' column */
'table_to_be_created' => [
'id'
'name',
'date:dob' => ['nullable'],
'timestamps',
],
/* This table would be updated as it doesn't contains an 'id' or 'uuid' column */
'table_to_be_updated' => [
'name' => ['after:id']
],
/* A table of name "pivot_table" would be created as the method has been defined */
'create:pivot_table' => [
'foreignId:key_1' => ['index'],
'foreignId:key_2' => ['index'],
],
];
use MylesDuncanKing\SimpleMigration\SimpleMigration;
class ExampleMigration extends SimpleMigration
{
protected array $migration = [
// Create "roles" table as "id" column is specified
'roles' => [
'id', // $table->id();
'softDeletes', // $table->softDeletes();
'string:role,64', // $table->string('role', 64);
'unique:deleted_at|role,roles_unique_role', // $table->unique(['deleted_at', 'role'], 'roles_unique_role');
],
// Update "users" table as no "id" or "uuid" column is specified
'users' => [
'role_id' => ['after:id', 'nullable'], // ends in _id so $table:foreignId('role_id')->after('id')->nullable()->index();
'foreign:role_id' => ['references:id', 'on:roles'], // $table->foreign('role_id')->references('id')->on('roles')->index();
]
];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.