- custom_cards migration + CRUD API with catalog twin sync so designs appear in My Cards, lists, and decks via normal card joins - artwork upload to MinIO under card-art/ - /designer page: form-driven live preview, 4 starter frames, PNG export - /my-designs gallery with edit/delete - Designer nav entry in sidebar + mobile drawer
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
/**
|
|
* Custom card designs (card designer feature).
|
|
*
|
|
* One row per user-designed card. Designer-specific fields live here
|
|
* (frame, artwork, actions); on save we also upsert a matching catalog
|
|
* row in `cards` (game='Custom') + a `user_cards` row so designed cards
|
|
* appear in My Cards, lists, and decks through the normal joins.
|
|
*/
|
|
export const up = (pgm) => {
|
|
pgm.sql(`
|
|
CREATE TABLE IF NOT EXISTS custom_cards (
|
|
id SERIAL PRIMARY KEY,
|
|
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
card_id INTEGER REFERENCES cards(id) ON DELETE SET NULL,
|
|
name VARCHAR(255) NOT NULL,
|
|
mana_cost VARCHAR(50),
|
|
card_type VARCHAR(255),
|
|
rarity VARCHAR(50),
|
|
rules_text TEXT,
|
|
actions TEXT,
|
|
power VARCHAR(10),
|
|
toughness VARCHAR(10),
|
|
frame_id VARCHAR(50) DEFAULT 'classic',
|
|
artwork_url TEXT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
)
|
|
`);
|
|
|
|
pgm.sql(`
|
|
CREATE INDEX IF NOT EXISTS idx_custom_cards_user_id
|
|
ON custom_cards(user_id)
|
|
`);
|
|
|
|
pgm.sql(`
|
|
CREATE INDEX IF NOT EXISTS idx_custom_cards_card_id
|
|
ON custom_cards(card_id)
|
|
`);
|
|
};
|
|
|
|
export const down = (pgm) => {
|
|
pgm.sql(`DROP TABLE IF EXISTS custom_cards CASCADE`);
|
|
};
|