This question has been flagged
1 Reply
6082 Views

I have a database that apparently has some corruption somewhere inside it.  In this database, I'm unable to view stock picking reports.  If I create a new, clean database, this function works just fine, so it must be a problem with the first DB.  However, if you do a simple DB copy from the database manager, restoring to a new database, the problem is migrated along with all the data.  I have tried doing data-only dumps using psql and pg_dump from the command line, but restoring always errors out or leaves me with a database that can be seen from the Odoo DB selection screen, but doesn't show any of the modules/apps as installed.  How do others solve issues like this?  I'm really hoping to avoid having to do table by table export/import via the Odoo interface.  What a pain in the butt that would be!  Any suggestions?

Avatar
Discard
Best Answer

It sounds to mie like you have issue with inconsistent data in the DB. Best approach is to figure out which table is causing the problems.

Try analysing the log file if there are exceptions. If required, you can increase the log-level to log the SQL statements (--log-sql). Once you had identified the table, you can try to fixing the data in that table. Here the tables from a clean database can be handy.

Hope this will help you find the problem.

Avatar
Discard
Author

How would you go about "fixing" the data? Everything should be changed via the front end, to keep the ORM happy, right?

Not necessary, you can change the data from the back-end as well, but you need basic understanding of the relational databases, mainly about the foreign keys. ORM will convert the python object to SQL statements in order to insert/update/delete the data in the database. If you perform same modifications, ORM will not be aware that the data was modified from the database side. I have done changes of the data many times with SQL statement, however, I don't recommend this for beginners. Before you do any change, make sure you test on duplicate database and make sure you have fresh backup.