# Migrating to Ghost: How to generate primary ID for posts and other entities?

**URL:** <https://forum.ghost.org/t/migrating-to-ghost-how-to-generate-primary-id-for-posts-and-other-entities/29655>\
**Category:** Migrations\
**Created:** [April 19, 2022, 8:51pm UTC](https://forum.ghost.org/t/migrating-to-ghost-how-to-generate-primary-id-for-posts-and-other-entities/29655 "2022-04-19T20:51:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jan-zablodil](https://avatars.discourse-cdn.com/v4/letter/j/439d5e/32.png) [@jan-zablodil](https://forum.ghost.org/u/jan-zablodil)\
**Post date:** [April 19, 2022, 8:51pm UTC](https://forum.ghost.org/t/migrating-to-ghost-how-to-generate-primary-id-for-posts-and-other-entities/29655/1 "2022-04-19T20:51:23Z")

</div>

Hi,

I am migrating to Ghost from database with integer auto-increment IDs (1,2,3,…). I see ghost uses IDs like 625f1cb98b49f500010f1903. What type of ID is that and how can I generate it?

Thanks

---

<div class="post-metadata">

**Author:** ![timtiret](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/timtiret/32/35118_2.png) [@timtiret](https://forum.ghost.org/u/timtiret)\
**Post date:** [March 2, 2025, 5:40pm UTC](https://forum.ghost.org/t/migrating-to-ghost-how-to-generate-primary-id-for-posts-and-other-entities/29655/2 "2025-03-02T17:40:56Z")

</div>

With NodeJS and UUID library installed you can do something like this :

```auto
import { v4 } from 'uuid';
const ghostId = v4().replace(/-/g, '').slice(0, 24);

```

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [March 2, 2025, 6:43pm UTC](https://forum.ghost.org/t/migrating-to-ghost-how-to-generate-primary-id-for-posts-and-other-entities/29655/3 "2025-03-02T18:43:17Z")

</div>

It’s a “BSON ObjectID”. Ghost uses [bson-objectid](https://www.npmjs.com/package/bson-objectid) to generate them.
