kaliop-uk / ezmigrationbundle

This bundle makes it easy to handle eZPlatform / eZPublish5 content upgrades/migrations
GNU General Public License v2.0
53 stars 81 forks source link

ez platform 2.3 migration failure: "Could not find 'content' with identifier 'id: 14'" #185

Closed jdcrecur closed 5 years ago

jdcrecur commented 5 years ago
  1. ez 2.3
  2. kalliop 4.7 and also tried on 5.7.3

I cannot run any new migrations, nor even dump the migrations of what we already have. The following:

php bin/console kaliop:migration:generate --type=content_type --match-type=all AppBundle

Results in the error:

php bin/console kaliop:migration:generate --type=content_type --match-type=all AppBundle

In ContentService.php line 380:

  Could not find 'Content' with identifier 'array (  
    'id' => 14,                                      
    'languages' =>                                   
    array (                                          
    ),                                               
    'versionNo' => NULL,                             
  )'                                                 

In DoctrineDatabase.php line 986:

  Could not find 'content' with identifier 'id: 14'  

kaliop:migration:generate [--format FORMAT] [--type TYPE] [--mode MODE] [--match-type MATCH-TYPE] [--match-value MATCH-VALUE] [--match-except] [--lang LANG] [--dbserver DBSERVER] [--role ROLE] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--siteaccess [SITEACCESS]] [--] <command> <bundle> [<name>]

Content type: Article is of id 14. I cannot find a content object of id 14.

Any ideas on where I could debug this further?

gggeek commented 5 years ago

Content with id 14 is admin, at least on eZPlatform 5. I suspect that the migration code is trying to log you in as admin and not finding the admin user. If you have removed the default admin and replaced it with another one, you should use the available command-line switch for migration commands that uses the new admin account - note that that switch might have not yet been implemented for all commands, but at least it is available for migration execution (you can test f.e. with a simple migration created by hand)

crevillo commented 5 years ago

Yup. and just in case. take in account you need to have things in your db before running your first migration. that admin user is automatically added by the install command. ./bin/console ezplatform:install clean once you do this, you can start to work with migrations.

if this is not the case, @gggeek said it. probably you have changed your admin user at some point.

jdcrecur commented 5 years ago

Ah right I see.

Yes, the admin account was removed as we have 3 other accounts under the admin role so this seemed redundant. Is it possible to reinstate the default admin user?

jdcrecur commented 5 years ago

I cannot see by reading the database schema any issue with simply injecting back into the users table the admin user and forcing the admin id to contentobject_id 14.

Is there anything you know of which would break the admin for this?

gggeek commented 5 years ago

well, you can not reuse an object-id / user-id. The only way would be a sql command to alter the current admin. Either that, or change your usage of migration commands to always use one of the new admins

gggeek commented 5 years ago

ps: mig bundle uses 14 by default as there is no good heuristic (that I know of) to find the current 'admin', given that both the user, group and role might have been changed / renamed

jdcrecur commented 5 years ago

I understand and thank you for the advice.

I will attempt to simply assign another admin user with id 14 first.

jdcrecur commented 5 years ago

@gggeek OK, attempting to force another admin user to be contentobject id 14 did not work. I can only assume it will be heavily related to the content object tables.

How do I, or is there a doc on, instructing the migrations to run as another user id?

gggeek commented 5 years ago

If you run the commands with -h you should get the info

jdcrecur commented 5 years ago

Thanks for the help! Up and running again.