From 718b9b5b3421136a54402df3f4112151d1520aee Mon Sep 17 00:00:00 2001 From: simonwelsh Date: Sat, 17 Sep 2011 00:21:54 +1200 Subject: [PATCH 1/2] Pass create_table_options for the owner class's table to DB::requireTable() when creating tables for the stages and the _version table. --- model/Versioned.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/model/Versioned.php b/model/Versioned.php index 9a646fb63..2084a0411 100644 --- a/model/Versioned.php +++ b/model/Versioned.php @@ -236,6 +236,7 @@ class Versioned extends DataExtension { 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 @@ class Versioned extends DataExtension { } 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 @@ class Versioned extends DataExtension { } } - 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 @@ class Versioned_Version extends ViewableData { return !empty( $this->record['WasPublished'] ); } } - -?> From b80efb75d4f613a34b138073ab8ef44f286f3b07 Mon Sep 17 00:00:00 2001 From: simonwelsh Date: Mon, 19 Sep 2011 14:20:38 +1200 Subject: [PATCH 2/2] Add comment about duplicating create options as well as structure. --- model/DataExtension.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/DataExtension.php b/model/DataExtension.php index 0f23a2abd..23824dd4b 100644 --- a/model/DataExtension.php +++ b/model/DataExtension.php @@ -99,6 +99,9 @@ abstract class DataExtension extends 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() { }