Skip to content
Extraits de code Groupes Projets
Valider 38baf090 rédigé par Okhin's avatar Okhin
Parcourir les fichiers

Let's have an up and down migration

parent 070ca0af
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!89Preprod
......@@ -30,17 +30,29 @@ class AddParentField extends AbstractMigration
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
public function up()
{
$table = $this->table('contreparties');
$table->addColumn('parent', 'integer');
$table->update();
if (!$table->hasColumn('parent')) {
$table->addColumn('parent', 'integer');
$table->save();
}
// Let's set some default value
$builder = $this->getQueryBuilder();
$stmt = $builder->update('contreparties')
$stmt = $builder->update('contreparties', 'c')
->set('parent', 'id')
->where(['parent' => ''])
// ->where('parent = 0')
->execute();
}
public function down()
{
$table = $this->table('contreparties');
if ($table->hasColumn('parent')) {
$table->removeColumn('parent')
->save();
}
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter