Closed (outdated)
Project:
Migrate
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
10 May 2011 at 13:13 UTC
Updated:
21 Feb 2018 at 13:40 UTC
Jump to comment: Most recent
In some scenarios there are some facts about the data source, that I want to be sure are true.
For example:
a) Those things could be checked during an import. How to do error reporting in prepare or prepareRow?
b) A seperate method, just for assertions and something like drush migrate-check Migration would be a useful feature.
Comments
Comment #1
mikeryanYou got me thinking about a related subject: #1152878: Add source analysis. I started down that line here, but I think that is a different solution than the assertion case.
For assertions, I think it makes most sense to add them to field mappings, which also helps make the expectations visible (we can display the assertions on the migration info pages):
Assertions could be tested in applyMappings, and assertion failures added to the message table.
Thanks!
Comment #2
mikeryanComment #3
Niklas Fiekas commentedLooks good. How would I add "custom" assertions there?
Comment #4
mikeryanPerhaps
Of course, you can always do what you want in prepareRow().
Comment #5
Niklas Fiekas commentedAwesome.
Some details:
Comment #6
mikeryanYou can do the first two today in prepareRow - do nothing beyond saveMessage() to continue, return FALSE to skip the row. You could also abort the import by setting the status column in migrate_status to MigrationBase::STATUS_STOPPING.
Don't expect this to go into Migrate soon - I'm going to be releasing a beta of Migrate 2.1 shortly, I'll save this for Migrate 2.2. For now, I would recommend just doing your assertions in prepareRow().
Comment #7
Niklas Fiekas commentedYes. I don't really need assertions for my current project. Only I found at some points, that they would be handy.
Comment #8
joachim commented> Other, more complex assertions
Would getting something like the MigrateTaxonomyTermReferenceFieldHandler to file a log message if it fails to get a taxonomy term from the incoming data come under this heading? Not sure whether to file a new feature request or pile in on this one :)
Comment #9
mikeryanThat falls under the heading of runtime notice (doing a saveMessage with MigrationBase::MESSAGE_INFORMATIONAL), it's not an assertion on the source data.
Comment #10
pifagor commented