Skip to content

Instantly share code, notes, and snippets.

@Aabill
Last active March 11, 2022 17:34
Show Gist options
  • Save Aabill/dc1413d98e51e5b9091c19b0aad2a278 to your computer and use it in GitHub Desktop.
Save Aabill/dc1413d98e51e5b9091c19b0aad2a278 to your computer and use it in GitHub Desktop.
Cakephp SEED MIGRATE Sample
<?php
use Migrations\AbstractMigration;
class AddOperatorRoleSeedToRoles extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function up()
{
$builder = $this->getQueryBuilder();
$builder
->insert(['name', 'alias'])
->into('roles')
->values(['name' => 'Operator', 'alias' => 'operator'])
->execute();
}
public function down() {
// Remove records
$builder = $this->getQueryBuilder();
$builder
->delete('roles')
->where(['alias' => 'operator', 'name' => 'Operator'])
->execute();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment