Merge pull request #60 from simonwelsh/patch-3

BUGFIX Pass create_table_options for the owner class's table to DB::requireTable()
This commit is contained in:
Will Rossiter 2011-09-18 19:25:26 -07:00
commit 1c12a226a3
2 changed files with 6 additions and 4 deletions

View File

@ -99,6 +99,9 @@ abstract class DataExtension extends Extension {
/** /**
* Update the database schema as required by this extension. * Update the database schema as required by this extension.
*
* When duplicating a table's structure, remember to duplicate the create options
* as well. See {@link Versioned->augmentDatabase} for an example.
*/ */
function augmentDatabase() { function augmentDatabase() {
} }

View File

@ -236,6 +236,7 @@ class Versioned extends DataExtension {
else $table = $classTable; else $table = $classTable;
if($fields = DataObject::database_fields($this->owner->class)) { if($fields = DataObject::database_fields($this->owner->class)) {
$options = Object::get_static($this->owner->class, 'create_table_options');
$indexes = $this->owner->databaseIndexes(); $indexes = $this->owner->databaseIndexes();
if ($suffix && ($ext = $this->owner->getExtensionInstance($allSuffixes[$suffix]))) { if ($suffix && ($ext = $this->owner->getExtensionInstance($allSuffixes[$suffix]))) {
if (!$ext->isVersionedTable($table)) continue; if (!$ext->isVersionedTable($table)) continue;
@ -257,7 +258,7 @@ class Versioned extends DataExtension {
} }
if($stage != $this->defaultStage) { if($stage != $this->defaultStage) {
DB::requireTable("{$table}_$stage", $fields, $indexes, false); DB::requireTable("{$table}_$stage", $fields, $indexes, false, $options);
} }
// Version fields on each root table (including Stage) // Version fields on each root table (including Stage)
@ -359,7 +360,7 @@ class Versioned extends DataExtension {
} }
} }
DB::requireTable("{$table}_versions", $versionFields, $versionIndexes); DB::requireTable("{$table}_versions", $versionFields, $versionIndexes, true, $options);
} else { } else {
DB::dontRequireTable("{$table}_versions"); DB::dontRequireTable("{$table}_versions");
foreach($this->stages as $stage) { foreach($this->stages as $stage) {
@ -1092,5 +1093,3 @@ class Versioned_Version extends ViewableData {
return !empty( $this->record['WasPublished'] ); return !empty( $this->record['WasPublished'] );
} }
} }
?>