Desperately trying to migrate!

I’ve been desperately trying to migrate my db to a new server four hours now, and I stil didn’t succeed.
old db:
-v 11.13.2.
-sqLite
-Populated

target:
-v 11.13.2
-MariaDb
-Completely empty (apart from the admin user

I create a script based on the docs, and it works as expected but it fails when applying the diff

```
const diffUrl = `${TARGET_DIRECTUS_URL}/schema/diff?access_token=${TARGET_ACCESS_TOKEN}&force=true`;

    const diffResponse = await fetch(diffUrl, {

        method: 'POST',

        headers: { 'Content-Type': 'application/json' },

        body: JSON.stringify(snapshot)

    });

const applyUrl = \`${TARGET_DIRECTUS_URL}/schema/apply?access_token=${TARGET_ACCESS_TOKEN}\`;

    const applyResponse = await fetch(applyUrl, {

        method: 'POST',

        headers: { 'Content-Type': 'application/json' },

        body: JSON.stringify(diff)

    });

```

Most of the fields get create but it always fail with an error saying that " field already exist in the collection”. I deleted the problematic field, but the same error occurs with a new field every time.
I tried once to migrate to sqlite, but it also failed the same way

Is there anything I can do ? Any other way to do this ?

thanks in advance !

I’ve made some progress.
I wrote a new script that creates the collections and fields through the /collections, /fields, endpoints.

It works, but I get errors when creating the relations. I get an error saying

```
errno: 150 “Foreign key constraint is incorrectly formed”
```

I have more info:

after looking at the snapshot created after migration attempt, I see that the pattern is clear:

3 types or m2o fields:

1.pointing to system collection: :white_check_mark:Success
2.pointing to a custom collection where the PK is a munually entered string: :white_check_mark:Success
3.pointing to a custom collection where the PK is the default auto generated UUID: :cross_mark:Fail

After 30 hours of work, the db is migrated !

the problem:

I’m afraid it might have been a very dumb problem at first that lead to a huge work around.

a field called Detectors what getting the error “already exist” during classic schema migration.
The problem probably was that in the same collection, there was a “raw group” called detectors that might have be colliding, even with the spelling difference.

I ended up migrating by creating collecitons, fields and relations through the /collections, /fields, etc.
But, collecitons with .id as UUID did not have config for the type of that PK.
So MariaDb was creating it as **int unsigned as default. Collections with manually entered strings as PK had the needed config for the field.

I updated the script and it worked like a charm. except for detectors, witch I created manually.
**
I will open an issue for the spelling problem.