summaryrefslogtreecommitdiff
path: root/lib/schema.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-10-19 17:25:56 -0700
committerBrion Vibber <brion@pobox.com>2010-10-19 17:25:56 -0700
commit3b6f738ab73b7f77dd09ac21dd9446876776fc04 (patch)
tree5c05777f9d03a2d3b10462b58249b0d1ca79f235 /lib/schema.php
parent8b0ba03a2e924fc56440719af1d7564e562ba9c9 (diff)
Convert SamplePlugin to new-style table defs, tweak some stuff to test basic checkschema
Diffstat (limited to 'lib/schema.php')
-rw-r--r--lib/schema.php11
1 files changed, 7 insertions, 4 deletions
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;