Stable Unique Card ID System #65

Open
opened 2025-07-09 06:57:44 -07:00 by waifu · 0 comments
Owner

Right now, cards in the gacha game are identified by local database IDs that depend on import order. This creates inconsistency across servers or deployments. For example, assuming we have import packs, importing "Waifu Pack 2" before "Waifu Pack 1" changes the IDs of the cards depending on insertion order.

To solve this, we could introduce a stable, deterministic global_id for each card based on its metadata. This will ensure that the same card always has the same identifier, no matter when or where it's imported.

Proposed Solution:

Add a global_id field to the cards table, generated using UUID version 5 with the pack name as a namespace and the card name as the key.

import uuid

def generate_card_id(pack_name, card_name):
    namespace = uuid.uuid5(uuid.NAMESPACE_DNS, pack_name)
    return uuid.uuid5(namespace, card_name)

Database Schema Example

ALTER TABLE cards ADD COLUMN global_id TEXT UNIQUE NOT NULL;

This field would be used as the canonical identifier for importing/exporting cards between servers or databases.

Right now, cards in the gacha game are identified by local database IDs that depend on import order. This creates inconsistency across servers or deployments. For example, assuming we have import packs, importing "Waifu Pack 2" before "Waifu Pack 1" changes the IDs of the cards depending on insertion order. To solve this, we could introduce a stable, deterministic global_id for each card based on its metadata. This will ensure that the same card always has the same identifier, no matter when or where it's imported. ## Proposed Solution: Add a global_id field to the cards table, generated using UUID version 5 with the pack name as a namespace and the card name as the key. ``` import uuid def generate_card_id(pack_name, card_name): namespace = uuid.uuid5(uuid.NAMESPACE_DNS, pack_name) return uuid.uuid5(namespace, card_name) ``` Database Schema Example ``` ALTER TABLE cards ADD COLUMN global_id TEXT UNIQUE NOT NULL; ``` This field would be used as the canonical identifier for importing/exporting cards between servers or databases.
waifu added the
Feature
Feedback Wanted
labels 2025-07-09 06:57:44 -07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: waifu/kemoverse#65
No description provided.