Last active
March 11, 2022 17:34
-
-
Save Aabill/dc1413d98e51e5b9091c19b0aad2a278 to your computer and use it in GitHub Desktop.
Cakephp SEED MIGRATE Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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