Description:
Typically, when restoring a schema that has been backed up using the
"complete backup" option, errors will be thrown. "Can't find..."
The problem is due to tables/views referring (either explicitly or via foreign keys) to other tables/views which have not been restored yet.
How to repeat:
(1) create a schema
(2) populate with tables (`table_one`, `table_two`)
(3) create a view (`a_view`) where `table_one` joins `table_two`
(4) create a FK that refers from `table_one.id` (FK) to `table_two.id` (PK)
(5) backup the schema with the following option selected "complete backup"
(6) delete the schema
(7) restore the schema from backup
restore will fail because it will create a view that refers to a non-existant table
Suggested fix:
Is it possible to have the backup engine perform an initial pass to determine which tables or views should be backed up first?
A logical BACKUP could look like:
1) backup tables
1a) backup primary tables
1b) backup secondary tables
2) backup views
OR
A logical RESTORE could look like:
1) disable all keys
2) restore tables
3) restore views
The second method would probably avoid the situation where two tables reference each other.
4) enable FKs