How to write migration block for this situation?

Please help me , I don’t how to write migration block for my purpose

Before Migration

class Deck : Object {

    @objc dynamic var name : String = ""

    var cards = List<Card>()

}

class Card : Object {

    @objc dynamic var text = ""

    var parentCategory = LinkingObjects(fromType: Deck.self, property: "cards")

}

After Migration

class Deck : Object {

    @objc dynamic var name : String = ""

    let cards = LinkingObjects(fromType: Card.self, property: "owner")

}
class Card : Object {


    @objc dynamic var text = ""

    @objc dynamic var owner : Deck?


}

In a new version of app when I’m making a new card , I’m setting parent like this :

let decks = realm.objects(Deck.self)
owner = decks[index]

This is a cross post to the SO question

How to perform migration of LinkingObject?

where there is an answer.