comparison roundup/backends/rdbms_common.py @ 6806:bdd28b244839

- issue2551223 - fix timestamp truncation in mysql and postgresql The data types used to represent timestamps in pg and mysql for ephemeral tables: sessions and otks don't have enough signifcant digits to work. As a result the timestamps are rounduped (up/down) rsuling in the stored timestamp being 2 minutes (pg) or 2-3 hours(mysql) off from what it should be. Modify db schema to use a numeric type that preserves more significant figures. Implement schema upgrade. Document need for upgrade in upgrading.txt. Write tests for schema upgrade. Implement test for updateTimestamp method on BasicDatabase that showed this issue in the first place. Write overrides for test for anydbm/memorydb which store timestamp properly or not at all.
author John Rouillard <rouilj@ieee.org>
date Mon, 25 Jul 2022 17:20:20 -0400
parents 408fd477761f
children 9ff091537f43
comparison
equal deleted inserted replaced
6805:09d9c646ca89 6806:bdd28b244839
329 # commit 329 # commit
330 self.sql_commit() 330 self.sql_commit()
331 331
332 # update this number when we need to make changes to the SQL structure 332 # update this number when we need to make changes to the SQL structure
333 # of the backend database 333 # of the backend database
334 current_db_version = 7 334 current_db_version = 8
335 db_version_updated = False 335 db_version_updated = False
336 336
337 def upgrade_db(self): 337 def upgrade_db(self):
338 """ Update the SQL database to reflect changes in the backend code. 338 """ Update the SQL database to reflect changes in the backend code.
339 339
379 379
380 if version < 7: 380 if version < 7:
381 self.log_info('upgrade to version 7') 381 self.log_info('upgrade to version 7')
382 self.fix_version_6_tables() 382 self.fix_version_6_tables()
383 383
384 if version < 8:
385 self.log_info('upgrade to version 8')
386 self.fix_version_7_tables()
387
384 self.database_schema['version'] = self.current_db_version 388 self.database_schema['version'] = self.current_db_version
385 self.db_version_updated = True 389 self.db_version_updated = True
386 return 1 390 return 1
387 391
388 def fix_version_2_tables(self): 392 def fix_version_2_tables(self):
417 pass 421 pass
418 422
419 def fix_version_6_tables(self): 423 def fix_version_6_tables(self):
420 # Default (used by nobody): NOOP 424 # Default (used by nobody): NOOP
421 # Each backend mysql, postgres, sqlite overrides this 425 # Each backend mysql, postgres, sqlite overrides this
426 # You would think ALTER commands would be the same but nooo.
427 pass
428
429 def fix_version_7_tables(self):
430 # Default (used by sqlite): NOOP
431 # Each backend mysql, postgres overrides this
422 # You would think ALTER commands would be the same but nooo. 432 # You would think ALTER commands would be the same but nooo.
423 pass 433 pass
424 434
425 def _convert_journal_tables(self): 435 def _convert_journal_tables(self):
426 """Get current journal table contents, drop the table and re-create""" 436 """Get current journal table contents, drop the table and re-create"""

Roundup Issue Tracker: http://roundup-tracker.org/