I’ve been trying to replicate this, but haven’t been able to locally. Can I ask, please:
Which version of @datocms-cli you’re using? (I tried on 1.3.3 and it seems to work)
Was this the first time you generated a staging-copy and ran the migration generator? Or have you done this previously (and it worked)?
Is there more than one migration script in your repo? (./migrations/*.js)
Also, to help us troubleshoot, would you mind posting (or emailing support@datocms.com) with your project ID/URL so we can take a look and see if it’s something specific to your schema? With your permission, I’d like to fork your staging environment into a copy and a fork of that (like datocms-support-staging-copy and datocms-support-staging-copy-forked-for-migration) and try to do a migration on that, to see if I can locate the issue more specifically.
Any specific information you can provide would help track this down. Sorry, I haven’t been able to replicate the issue locally with my tests yet.
At the least, could you please send us your project ID/URL (either here or via email) so we can take a look and see if there’s something in your particular schema that’s causing this issue?
Yes this was the first migration for staging-copy (we didn’t have a schema_migration model yet).
Unfortunately, we’ve now applied the migration on our staging environment already, by removing the generated code that creates the schema_migration model.
So now, we can no longer reproduce this issue and we expect follow-up migrations to work.
This was the only migration script at the time in the ./migrations folder.
Do you think it’s still useful if we share the project ID/URL?
After editing the generated code and applying the migration, our staging environment looks as expected.
I did want to report this as it looks like a bug.
Do you mind doing so, please? If it’s OK with you, I’d like to clone your environment to new copies (so we don’t mess up your existing production/staging envs) and try to replicate this bug.
I’ve also requested the same of jay1. Hopefully, between the two, we can track down the actual bug here?
I did want to report this as it looks like a bug.
It sure sounds like one! But I’m having trouble replicating it with our example projects, so seeing the exact situation (i.e. your affected environments) could help us isolate the bug. Sorry for the hassle here!
If it’s too much trouble, I understand… since you already fixed the issue on your end, please don’t feel like you have to jump through hoops to help us track it down. But if you do have time, it might help us catch and fix the bug once and for all, both for other users and for the next time you want to do a new migration
We’ve further stumbled upon some issues, and while I can’t fully articulate them, I can hopefully give some pointers.
Somehow, we’ve ended up with a different recordID for the schema_migration models on staging and uat.
This is probably what’s causing the migration:new script to want to re-create the schema_migration model, even when it already exists.
I think we mixed updating our records by clicking in the web interface with creating them with migrations, and this is the root of what’s causing us major issues in using the migration tooling.
Thank you for sharing this! It sounds similar to jay1’s situation, where conflicting (human/UI) edits of the same model names causes the scripting to break.
We’ve filed a bug report about it internally, and will report back as soon as we have more information!