cakephp / cakephp/phinx

Migrate cannot run with postgres schema that needs to be escaped

Open
#1,783 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

If you have a schema which contains characters which need escaping

this-needs-quotes

and you specify the default migration table as follows

'default_migration_table' => 'this-needs-quotes.phinxlog',

The the create table portion of the migration process works without issue. However it then tries to run a select using the unescaped schema to see which migrations have run and fails preventing migration.

If you specify the schema as follows

'default_migration_table' => '"this-needs-quotes".phinxlog',

Then the create process double escapes

CREATE TABLE ""this-needs-quotes""."phinxlog"

And the SQL fails to execute.

If you do not include a default migration table then it appears that the schema selected is public and not the default search path schema.

There appears to be no way of creating migrations for a schema which requires escaping.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the migration with a PostgreSQL schema requiring escaping and a default_migration_table, then compare the SQL used to create the table with the SQL used to select migration records. Done means both operations handle the schema correctly without double escaping, and migrations without an explicit table use the intended default schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.