Convert SamplePlugin to new-style table defs, tweak some stuff to test basic checkschema

This commit is contained in:
Brion Vibber
2010-10-19 17:25:56 -07:00
parent 8b0ba03a2e
commit 3b6f738ab7
3 changed files with 23 additions and 9 deletions

View File

@@ -172,9 +172,20 @@ class SamplePlugin extends Plugin
// For storing user-submitted flags on profiles
$schema->ensureTable('user_greeting_count',
array(new ColumnDef('user_id', 'integer', null,
true, 'PRI'),
new ColumnDef('greeting_count', 'integer')));
array(
'fields' => array(
'user_id' => array('type' => 'int', 'not null' => true),
'greeting_count' => array('type' => 'int'),
),
'primary key' => array('user_id'),
'foreign keys' => array(
// Not all databases will support foreign keys, but even
// when not enforced it's helpful to include these definitions
// as documentation.
'user_greeting_count_user_id_fkey' => array('user', array('user_id' => 'id')),
),
)
);
return true;
}