From 3b6f738ab73b7f77dd09ac21dd9446876776fc04 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 19 Oct 2010 17:25:56 -0700 Subject: Convert SamplePlugin to new-style table defs, tweak some stuff to test basic checkschema --- lib/schema.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/schema.php b/lib/schema.php index 20bd95f28..e4b7f416c 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -254,6 +254,9 @@ class Schema */ function appendForeignKeyDef(array &$sql, $name, array $def) { + if (count($def) != 2) { + throw new Exception("Invalid foreign key def for $name: " . var_export($def, true)); + } list($refTable, $map) = $def; $srcCols = array_keys($map); $refCols = array_values($map); @@ -884,7 +887,7 @@ class Schema if (!$cd->nullable) { $column['not null'] = true; } - if ($cd->autoincrement) { + if ($cd->auto_increment) { $column['type'] = 'serial'; } if ($cd->default) { @@ -942,13 +945,13 @@ class Schema */ function validateDef($tableName, array $def) { - if (count($defs) && $defs[0] instanceof ColumnDef) { - $def = $this->oldToNew($tableName, $defs); + if (count($def) && $def[0] instanceof ColumnDef) { + $def = $this->oldToNew($tableName, $def); } // A few quick checks :D if (!isset($def['fields'])) { - throw new Exceptioni("Invalid table definition for $tableName: no fields."); + throw new Exception("Invalid table definition for $tableName: no fields."); } return $def; -- cgit v1.2.3-54-g00ecf