Skip to content

Tables get deleted/added even though they are in both databases #35

Open
@chland

Description

@chland

I guess nobody is maintaining this repository anymore but I thought I would mention this bug and how to (probably) fix it.

When I run the script I sometimes end up with a migration-script that wants to delete tables that are still in both databases (I suspect that this could also happen the other way round where the migration wants to add an already existing table but so far I haven't encountered this particular situation).

The issue seems to be the base64_encode function in combination with the RegEx used to parse the table-definitions.

base64_encode (and base64_decode) are used in Parser.php to replace comments and default-values with their base64-encoded versions. My guess is that this is done to make parsing easier. Problem is, that base64_encode can produce a string containing a slash at the end. This makes it so that the regex will no longer be able to parse the table-definition and therefore the script will act strangely.

To "fix" this issue I replaced base64_encode/base64_decode with "custom" versions. I used the base64url_encode/base64_decode functions from the comments of the base64_encode-function on php.net - they basically just replace "+/" with "-_" - and this seems to fix the issue (DISCLAIMER: I didn't have the time to test that a whole lot but the few tests I did worked flawlessly).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions