feat(pokemon): store official data identity separate from display ID
Add data_id and data_identifier to pokemon schema Use official data ID as internal route ID for non-event pokemon Prevent applying fetched data with mismatched ID to existing pokemon
This commit is contained in:
@@ -712,6 +712,8 @@ CREATE TABLE IF NOT EXISTS pokemon_types (
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pokemon (
|
||||
id integer PRIMARY KEY,
|
||||
data_id integer CHECK (data_id > 0),
|
||||
data_identifier text NOT NULL DEFAULT '',
|
||||
display_id integer NOT NULL CHECK (display_id > 0),
|
||||
name text NOT NULL UNIQUE,
|
||||
is_event_item boolean NOT NULL DEFAULT false,
|
||||
@@ -738,6 +740,10 @@ CREATE TABLE IF NOT EXISTS pokemon (
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
ALTER TABLE pokemon
|
||||
ADD COLUMN IF NOT EXISTS data_id integer CHECK (data_id > 0),
|
||||
ADD COLUMN IF NOT EXISTS data_identifier text NOT NULL DEFAULT '';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pokemon_pokemon_types (
|
||||
pokemon_id integer NOT NULL REFERENCES pokemon(id) ON DELETE CASCADE,
|
||||
type_id integer NOT NULL REFERENCES pokemon_types(id) ON DELETE CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user