Problem/Motivation

If the table does not exist in the source database, the migration will fail with the database exception:

[error]  Could not retrieve source count from sql: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'source.foo' doesn't exist: SELECT COUNT(*) AS "expression"
FROM
(SELECT 1 AS "expression"
FROM
"foo" "t") "subquery"; Array
(
)

My specific use-case: custom migration that was executed on multiple websites, where the data structure is a bit different.

Steps to reproduce

1) Create a migration with Table source plugin;
2) Specify not existing sql table;
3) Try running the migration;

Proposed resolution

Implement ::checkRequirements method in Table source plugin.

Remaining tasks

Submit a merge request, review, commit.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Matroskeen created an issue. See original summary.

matroskeen’s picture

Assigned: matroskeen » Unassigned

matroskeen’s picture

Issue summary: View changes
matroskeen’s picture

Status: Active » Needs review

The first commit failed as expected. This is ready for review.

matroskeen’s picture

Status: Needs review » Postponed
Related issues: +#3254986: Remove requirements array from RequirementsException message

I think we should agree on the approach in #3254986: Remove requirements array from RequirementsException message, so I'm postponing this one.

matroskeen’s picture

Status: Postponed » Active
Issue tags: +LutskGCW22

  • Matroskeen committed 9b36ff3 on 8.x-5.x
    Issue #3232214 by Matroskeen: Table source plugin - validate the sql...
matroskeen’s picture

Status: Active » Fixed

Committed to 8.x-5.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.