Permalink
Browse files

Merge pull request #60 from simonwelsh/patch-3

BUGFIX Pass create_table_options for the owner class's table to DB::requireTable()
  • Loading branch information...
2 parents 7b56008 + b80efb7 commit 1c12a226a3916a3187302b972d23629d459c6e5b @wilr wilr committed Sep 19, 2011
Showing with 6 additions and 4 deletions.
  1. +3 −0 model/DataExtension.php
  2. +3 −4 model/Versioned.php
View
@@ -99,6 +99,9 @@ function augmentSQL(SQLQuery &$query) {
/**
* 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() {
}
View
@@ -236,6 +236,7 @@ function augmentDatabase() {
else $table = $classTable;
if($fields = DataObject::database_fields($this->owner->class)) {
+ $options = Object::get_static($this->owner->class, 'create_table_options');
$indexes = $this->owner->databaseIndexes();
if ($suffix && ($ext = $this->owner->getExtensionInstance($allSuffixes[$suffix]))) {
if (!$ext->isVersionedTable($table)) continue;
@@ -257,7 +258,7 @@ function augmentDatabase() {
}
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)
@@ -359,7 +360,7 @@ function augmentDatabase() {
}
}
- DB::requireTable("{$table}_versions", $versionFields, $versionIndexes);
+ DB::requireTable("{$table}_versions", $versionFields, $versionIndexes, true, $options);
} else {
DB::dontRequireTable("{$table}_versions");
foreach($this->stages as $stage) {
@@ -1092,5 +1093,3 @@ function Published() {
return !empty( $this->record['WasPublished'] );
}
}
-
-?>

0 comments on commit 1c12a22

Please sign in to comment.