diff options
author | Brion Vibber <brion@pobox.com> | 2010-10-19 17:07:37 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-10-19 17:07:37 -0700 |
commit | 8b0ba03a2e924fc56440719af1d7564e562ba9c9 (patch) | |
tree | 0e56637dcae6eba3c539d83796e3b2f87b4a826a /scripts | |
parent | 4f7eae8702be28a081db05feb26366a1f83bfd90 (diff) |
Starting to encapsulate some of the schema_version checksum / updater logic
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/dumpschema.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/dumpschema.php b/scripts/dumpschema.php index 613364487..2b238f006 100644 --- a/scripts/dumpschema.php +++ b/scripts/dumpschema.php @@ -28,11 +28,12 @@ Attempt to pull a schema definition for a given table. --raw skip compatibility filtering for diffs --create dump SQL that would be run to update or create this table --build dump SQL that would be run to create this table fresh + --checksum just output checksums from the source schema defs END_OF_CHECKSCHEMA_HELP; -$longoptions = array('diff', 'all', 'create', 'update', 'raw'); +$longoptions = array('diff', 'all', 'create', 'update', 'raw', 'checksum'); require_once INSTALLDIR.'/scripts/commandline.inc'; function indentOptions($indent) @@ -207,6 +208,24 @@ function tweakPrimaryKey($def) return $def; } +function dumpChecksum($tableName) +{ + $schema = Schema::get(); + $def = getCoreSchema($tableName); + + $updater = new SchemaUpdater($schema); + $checksum = $updater->checksum($def); + $old = @$updater->checksums[$tableName]; + + if ($old == $checksum) { + echo "OK $checksum $tableName\n"; + } else if (!$old) { + echo "NEW $checksum $tableName\n"; + } else { + echo "MOD $checksum $tableName (was $old)\n"; + } +} + if (have_option('all')) { $args = getCoreTables(); } @@ -219,6 +238,8 @@ if (count($args)) { dumpBuildTable($tableName); } else if (have_option('update')) { dumpEnsureTable($tableName); + } else if (have_option('checksum')) { + dumpChecksum($tableName); } else { dumpTable($tableName, true); } |