Skip to content

WireDatabaseBackup::restore() does not drop tables that don't exist in backup #296

Open
@ghost

Description

@Toutouwai commented on Apr 10, 2019, 3:32 AM UTC:

Short description of the issue

If I make a database backup using WireDatabaseBackup::backup() at time 1, and then later restore that backup at time 2 using WireDatabaseBackup::restore(), I expected the database to be put into the same state as at time 1.

But if there is some new table at time 2 that didn't exist when the backup was made at time 1 then that table is not dropped and persists in the database after the restore. One way this is a problem is with field tables. If a new field "foo" was created between time 1 and time 2 then restoring the backup removes the field from the PW admin (expected) but the "field_foo" table persists (unexpected) which creates a database error when attempting to create a field with that name.

I noticed the problem using ProcessDatabaseBackups but the issue occurs also with the core WireDatabaseBackup::backup() / WireDatabaseBackup::restore() methods.

Field tables at time of backup:
2019-04-10_151530

Creating backup:
2019-04-10_151657

New field "cost" is created.

Restoring backup:
2019-04-10_152727

Field tables after backup is restored:
2019-04-10_151625

Setup/Environment

  • ProcessWire version: 3.0.129

This issue was moved by ryancramerdesign from processwire/processwire-issues#846.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions