Skip to content

Instantly share code, notes, and snippets.

@borantula
Created February 13, 2017 10:47
Show Gist options
  • Save borantula/29a9befebde2d57a89e7a4025f9693e8 to your computer and use it in GitHub Desktop.
Save borantula/29a9befebde2d57a89e7a4025f9693e8 to your computer and use it in GitHub Desktop.
CakePHP I18N Table Migration
<?php
use Migrations\AbstractMigration;
class ArticlesI18n extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-change-method
* @return void
*/
public function change()
{
$table = $this->table('articles_i18n');
$table->addColumn('locale', 'string', [
'default' => null,
'limit' => 6,
'null' => false,
]);
$table->addColumn('model', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('foreign_key', 'integer', [
'default' => null,
'limit' => 11,
'null' => false,
]);
$table->addColumn('field', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('content', 'text', [
'default' => null,
'null' => false,
]);
$table->addIndex(array('locale', 'model', 'foreign_key', 'field'), array('unique' => true, 'name' => 'I18N_LOCALE_FIELD'));
$table->addIndex(array('model', 'foreign_key', 'field'), array('unique' => false, 'name' => 'I18N_FIELD'));
$table->create();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment