Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
add database migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
malte-christian committed Apr 7, 2016
1 parent fd1d0df commit e8b1637
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,36 @@
if ($util->tableExists('@blog_comment')) {
$util->dropTable('@blog_comment');
}
}
},

'updates' => [

'0.11.2' => function ($app) {

$db = $app['db'];
$util = $db->getUtility();

foreach (['@blog_post', '@blog_comment'] as $name) {
$table = $util->getTable($name);

foreach ($table->getIndexes() as $name => $index) {
if ($name !== 'primary') {
$table->renameIndex($index->getName(), $app['db']->getPrefix() . $index->getName());
}
}

if ($app['db']->getDatabasePlatform()->getName() === 'sqlite') {
foreach ($table->getColumns() as $column) {
if (in_array($column->getType()->getName(), ['string', 'text'])) {
$column->setOptions(['customSchemaOptions' => ['collation' => 'NOCASE']]);
}
}
}
}

$util->migrate();
}

]

];

0 comments on commit e8b1637

Please sign in to comment.