Skip to content

Commit

Permalink
more fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
beporter committed Jun 14, 2016
1 parent d2e0213 commit 25f530d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Template/Bake/Element/add-foreign-keys-from-create.ctp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<% foreach ($constraints as $table => $tableConstraints):
echo $this->element('Migrations.add-foreign-keys', ['constraints' => $tableConstraints, 'table' => $table]);
echo $this->element('LoadsysTheme.add-foreign-keys', ['constraints' => $tableConstraints, 'table' => $table]);
endforeach; %>
9 changes: 5 additions & 4 deletions src/Template/Bake/Element/create-tables.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ $specialPk = (count($primaryKeys) > 1 || $primaryKeys[0]['name'] !== 'id' || $pr
%>
<% if ($specialPk): %>

$this->table('<%= $tableArgForArray %>', ['id' => false, 'primary_key' => ['<%= implode("', '", \Cake\Utility\Hash::extract($primaryKeys, '{n}.name')) %>']])
$this->table('<%= $tableArgForArray %>', ['id' => false, 'primary_key' => ['<%= implode("', '", \Cake\Utility\Hash::extract($primaryKeys, '{n}.name')) %>'], ['comment' => '']])
<% else: %>

$this->table('<%= $tableArgForArray %>')
$this->table('<%= $tableArgForArray %>', ['comment' => ''])
<% endif; %>
<% if ($specialPk || !$autoId):
foreach ($primaryKeys as $primaryKey) :
Expand All @@ -30,7 +30,8 @@ foreach ($this->Migration->columns($tableArgForMethods) as $column => $config):
%>
->addColumn('<%= $column %>', '<%= $config['columnType'] %>', [<%
$columnOptions = $this->Migration->getColumnOption($config['options']);
$columnOptions['comment'] = '@' . 'TO' . 'DO';
$columnOptions['comment'] = '';
//@TODO: init proper integrity checks matching MigrationsTest from skeleton. (Example: int id must be signed=false)
if ($config['columnType'] === 'boolean' && isset($columnOptions['default']) && $this->Migration->value($columnOptions['default']) !== 'null'):
$columnOptions['default'] = (bool)$columnOptions['default'];
endif;
Expand Down Expand Up @@ -77,5 +78,5 @@ endforeach; %>
->create();
<% endforeach; %>
<% if (!empty($constraints)): %>
<% echo $this->element('Migrations.add-foreign-keys-from-create', ['constraints' => $constraints]); %>
<% echo $this->element('LoadsysTheme.add-foreign-keys-from-create', ['constraints' => $constraints]); %>
<% endif; %>
12 changes: 6 additions & 6 deletions src/Template/Bake/config/diff.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class <%= $name %> extends AbstractMigration {
<%- endif; %>
<%- endforeach; %>
<%- if (!empty($tables['add'])): %>
<%- echo $this->element('Migrations.create-tables', ['tables' => $tables['add'], 'autoId' => $autoId, 'useSchema' => true]) %>
<%- echo $this->element('LoadsysTheme.create-tables', ['tables' => $tables['add'], 'autoId' => $autoId, 'useSchema' => true]) %>
<%- endif; %>
<%- foreach ($data as $tableName => $tableDiff): %>
<%- if (!empty($tableDiff['columns']['add'])):
Expand All @@ -113,14 +113,14 @@ class <%= $name %> extends AbstractMigration {

<%= $statement %>
<%- endif; %>
<%- echo $this->element('Migrations.add-columns', ['columns' => $tableDiff['columns']['add']]) %>
<%- echo $this->element('LoadsysTheme.add-columns', ['columns' => $tableDiff['columns']['add']]) %>
<%- endif; %>
<%- if (!empty($tableDiff['indexes']['add'])):
$statement = $this->Migration->tableStatement($tableName);
if (!empty($statement)): %>
<%= $statement %>
<%- endif; %>
<%- echo $this->element('Migrations.add-indexes', ['indexes' => $tableDiff['indexes']['add']]) %>
<%- echo $this->element('LoadsysTheme.add-indexes', ['indexes' => $tableDiff['indexes']['add']]) %>
<%- endif;
if (isset($this->Migration->tableStatements[$tableName])): %>
->update();
Expand Down Expand Up @@ -170,7 +170,7 @@ class <%= $name %> extends AbstractMigration {
<%- endforeach; %>
<%- endif; %>
<%- if (!empty($tables['remove'])): %>
<%- echo $this->element('Migrations.create-tables', ['tables' => $tables['remove'], 'autoId' => $autoId, 'useSchema' => true]) %>
<%- echo $this->element('LoadsysTheme.create-tables', ['tables' => $tables['remove'], 'autoId' => $autoId, 'useSchema' => true]) %>
<%- endif; %>
<%- foreach ($data as $tableName => $tableDiff): %>
<%- if (!empty($tableDiff['indexes']['add'])): %>
Expand All @@ -190,7 +190,7 @@ class <%= $name %> extends AbstractMigration {
<%= $this->Migration->tableStatement($tableName, true) %>
<%- endif; %>
<%- if (!empty($tableDiff['columns']['remove'])): %>
<%- echo $this->element('Migrations.add-columns', ['columns' => $tableDiff['columns']['remove']]) %>
<%- echo $this->element('LoadsysTheme.add-columns', ['columns' => $tableDiff['columns']['remove']]) %>
<%- endif; %>
<%- if (!empty($tableDiff['columns']['changed'])):
$oldTableDef = $dumpSchema[$tableName];
Expand All @@ -213,7 +213,7 @@ class <%= $name %> extends AbstractMigration {
<%- endforeach; %>
<%- endif; %>
<%- if (!empty($tableDiff['indexes']['remove'])): %>
<%- echo $this->element('Migrations.add-indexes', ['indexes' => $tableDiff['indexes']['remove']]) %>
<%- echo $this->element('LoadsysTheme.add-indexes', ['indexes' => $tableDiff['indexes']['remove']]) %>
<%- endif;
if (isset($this->Migration->tableStatements[$tableName])): %>
->update();
Expand Down
4 changes: 2 additions & 2 deletions src/Template/Bake/config/skeleton.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class <%= $name %> extends AbstractMigration {
*/
public function change() {
<% foreach ($tables as $table): %>
$table = $this->table('<%= $table%>');
$table = $this->table('<%= $table%>', ['comment' => '']);
<% if ($tableMethod !== 'drop') : %>
<% if ($columnMethod === 'removeColumn'): %>
<% foreach ($columns['fields'] as $column => $config): %>
Expand All @@ -61,7 +61,7 @@ class <%= $name %> extends AbstractMigration {
$table-><%= $columnMethod %>('<%= $column %>', '<%= $config['columnType'] %>', [<%
$columnOptions = $config['options'];
$columnOptions = array_intersect_key($columnOptions, $wantedOptions);
$columnOptions['comment'] = '@' . 'TO' . 'DO';
$columnOptions['comment'] = '';
echo $this->Bake->stringifyList($columnOptions, ['indent' => 3]);
%>]);
<% endforeach; %>
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Bake/config/snapshot.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class <%= $name %> extends AbstractMigration {
* @return void
*/
public function up() {
<%- echo $this->element('Migrations.create-tables', ['tables' => $tables, 'autoId' => $autoId, 'useSchema' => false]) %>
<%- echo $this->element('LoadsysTheme.create-tables', ['tables' => $tables, 'autoId' => $autoId, 'useSchema' => false]) %>
}

/**
Expand Down

0 comments on commit 25f530d

Please sign in to comment.