Changing note/card id (e.g. creation time)

Hi,

Is there any way to change creation time of a note, or create a new note with a specified creation time (e.g. id) ? The only thing I could think of would be making a direct request to the database, which is not really beautiful. I don’t know whether it would break anything to do so, I don’t know why on rust, the features does not allow to flush card when the id is not already in the database, whether it’s only a check feature, or whether it ensure that some logic is maintened.

This would be useful at least for the add-on copy card, which can’t copy creation date anymore. (Technically, it never copied it, since ids are unique. But a difference of a few milliseconds is more acceptable than a difference of days or years)

1 Like

There’s an add-on for changing the card creation date, it might be helpful: Change Card Creation Times - AnkiWeb

2 Likes

Distinguishing between “add” and “update” is necessary to catch cards accidentally being added when the intention was to update them - which can happen if some code tries to flush a card object which has already been deleted on the DB end. This could have been done with separate functions rather than an id of 0, but using a zero id was the easiest way to integrate into the existing code at the time IIRC.

For now you can just use sql to replace the id after a new card is added - provided you do it before the user has a chance to review or sync, it should not cause problems.

Hello,
Is there any new dedicated way to do this ? I’m trying to update my addon (Transfer scheduling data from one card to another) which is broken seemingly since Anki 23.10. I used to do

mw.col.db.execute("update cards set id = ? where id = ?", cid1, cid2)

As suggested here but this is not undoable anymore without checkpoint(). So I wanted to use a collectionOp :

card2.id = something
mw.col.update_card(card2)

but it’s not working. Thanks for your help !

1 Like

Hello! I wanted to use your add-on so I forked it, but I just updated Qt5 so I don’t know how to solve that problem.(I’m not good with databases.)
This may have something to do with that.
Add-on porting notes for Anki 2.1.45 : Undo/Redo

Hello @Shigeyuki, Thanks for the quick update so that users could still use it ! I’m trying to find back the full features (undo which is critical, and stay focused on the same card after the transfer) but I struggle eheh
I also read the Add-on porting notes for Anki 2.1.45 : Undo/Redo but could not find a solution

1 Like

Hi there, I’m still looking for a solution to update card id with a collectionOp. Any help appreciated, thanks ! :slight_smile:

1 Like