python-rope/rope

Automatically purge autoimport.db when there is schema change

lieryan opened this issue · 2 comments

Is your feature request related to a problem? Please describe.

Currently, rope/contrib/autoimport/sqlite.py creates an sqlite database at autoimport.db that caches the result of scanning site-packages for names that are useful during autoimport.

Currently, when you upgrade rope version and the database schema has changed, it doesn't have any way to know that it should purge the database and do a re-scan.

Describe the solution you'd like

  • version_hash should be calculated from rope.VERSION, a hash of rope/contrib/autoimport/models.py file, and a hash of user preferences. (#631)
  • create a new metadata table, this table should contain a single column named version_hash
  • if the version_hash changes, then the database should be considered outdated and autoimport should re-scan the environment

Additional context

  • #516 and #515 depends on this mechanism

Can we also version the config so we can handle updates to settings like underlined?

@bagel897 thanks, that's a very good point. I've added it to the ticket.