The problem of software import substitution is under a great deal of attention in Russia since 2015. As a part of import substitution for a complex software system, database migration presents a considerable risk. Despite the SQL ISO standardization efforts, different implementations of SQL relational database management system are partially incompatible on the level of source codes for the schema, queries and stored procedures. Incompatibilities can manifest even at the level of query semantics. Some traits of complex scientometric software systems further complicate the migration process. Such traits include the complex data model and, consequently, the presence of non-trivial graph-traversing SQL queries which should complete fast enough to be used interactively for thousands of users simultaneously. In this paper an experience of refactoring a complex scientometric software system to support PostgreSQL database management system is presented. Our approach includes both usage and modification of the existing tools and development of the in-house software to support the refactoring process compounded with an extensive automated testing procedures.