3.4 KiB
3.4 KiB
WissKI Table Update Data Integrity Testing
This directory contains scripts to test data integrity when updating WissKI tables. The scripts ensure that no data is lost or truncated during schema updates.
Files
test-wisski-data-integrity.php- PHP script to export and verify datatest-wisski-update.sh- Bash wrapper script for the complete testing process
Usage
Option 1: Automated Testing (Recommended)
Run the complete test process (export → update → verify):
./test-wisski-update.sh
This script will:
- Export all WissKI table data (row counts, checksums, sample rows)
- Prompt you to run Drupal updates
- Verify data integrity after updates
- Generate a detailed report
Option 2: Manual Step-by-Step
Step 1: Export Data Before Update
php test-wisski-data-integrity.php export
This creates a directory wisski-data-integrity-test/ with:
before-update-summary.json- Summary of all tables- Individual table JSON files with row counts, checksums, and sample data
Step 2: Run Drupal Updates
drush updatedb -y
Or use the Drupal admin interface: /update.php
Step 3: Verify Data Integrity
php test-wisski-data-integrity.php verify
This compares the current state with the exported data and reports:
- Row count changes
- Checksum mismatches (data changes)
- Sample data differences
Output
All test results are saved in wisski-data-integrity-test/:
before-update-summary.json- Complete export before updateverification-report.json- Detailed verification results- Individual table JSON files for detailed inspection
What Gets Tested
For each WissKI table (all tables with wisski prefix):
- Row Count - Ensures no rows are lost or added unexpectedly
- Data Checksum - MD5 hash of all table data to detect any changes
- Sample Rows - First 10 rows compared to detect data corruption
- Column Information - Schema changes are logged
Interpreting Results
✓ Success
- All row counts match
- All checksums match
- No data loss detected
⚠️ Issues Detected
- Row count mismatch: Rows were added or deleted
- Checksum mismatch: Data content changed (may be expected for schema updates)
- Sample data mismatch: First rows differ (investigate for corruption)
Important Notes
- Backup First: Always backup your database before running updates
- Schema Changes: Some checksum changes may be expected if column types change (e.g., VARCHAR to TEXT)
- Large Tables: For very large tables, checksum calculation may fall back to partial checksums
- Empty Tables: Empty tables are marked with checksum 'empty' and skipped in checksum comparison
Troubleshooting
If verification fails:
- Check
verification-report.jsonfor detailed information - Compare individual table JSON files before/after
- Review Drupal update logs for errors
- Check if schema changes are expected (column type changes, etc.)
Example Output
Exporting data for 450 WissKI tables...
Processing wisski_entity_map...
Processing wisski_calling_bundles...
...
✓ Data export complete.
Verifying data integrity for 450 tables...
Checking wisski_entity_map...
✓ Row count matches: 1234
✓ Checksum matches
✓ Sample data matches
==========================================
✓ SUCCESS: All data verified successfully!
==========================================