fix(migrations): drop unused data column from distribution table (#169)

The distribution table had a `data bytea NOT NULL` column that was never
read by the Go code — item data is stored in distribution_items instead.
The NOT NULL constraint forced dummy values in seed data and test inserts.

Remove the column from the baseline schema, seed data, and tests, and
add migration 0005 to drop it from existing databases.
This commit is contained in:
Houmgaor
2026-02-27 18:19:57 +01:00
parent 21f9a79b62
commit fa09e4a39c
5 changed files with 10 additions and 6 deletions

View File

@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Fixed
- Distribution table: remove unused `data bytea NOT NULL` column that prevented seed data from matching Go code expectations (#169)
### Added ### Added
- API: Standardized JSON error responses (`{"error":"...","message":"..."}`) across all endpoints via `writeError` helper - API: Standardized JSON error responses (`{"error":"...","message":"..."}`) across all endpoints via `writeError` helper

View File

@@ -20,9 +20,9 @@ func createDistribution(t *testing.T, db *sqlx.DB, charID *uint32, distType int,
t.Helper() t.Helper()
var id uint32 var id uint32
err := db.QueryRow( err := db.QueryRow(
`INSERT INTO distribution (character_id, type, event_name, description, data, times_acceptable) `INSERT INTO distribution (character_id, type, event_name, description, times_acceptable)
VALUES ($1, $2, $3, $4, $5, 1) RETURNING id`, VALUES ($1, $2, $3, $4, 1) RETURNING id`,
charID, distType, eventName, description, []byte{0x00}, charID, distType, eventName, description,
).Scan(&id) ).Scan(&id)
if err != nil { if err != nil {
t.Fatalf("Failed to create distribution: %v", err) t.Fatalf("Failed to create distribution: %v", err)

View File

@@ -1,11 +1,11 @@
BEGIN; BEGIN;
-- Adds a Distribution that can be accepted up to 20 times that gives one of Item Type 30 (Item Box extra page) -- Adds a Distribution that can be accepted up to 20 times that gives one of Item Type 30 (Item Box extra page)
INSERT INTO distribution (type, event_name, description, times_acceptable, data) VALUES (1, 'Extra Item Storage', '~C05Adds one new page to your Item Box.', 20, ''::bytea); INSERT INTO distribution (type, event_name, description, times_acceptable) VALUES (1, 'Extra Item Storage', '~C05Adds one new page to your Item Box.', 20);
INSERT INTO distribution_items (distribution_id, item_type, quantity) VALUES ((SELECT id FROM distribution ORDER BY id DESC LIMIT 1), 30, 1); INSERT INTO distribution_items (distribution_id, item_type, quantity) VALUES ((SELECT id FROM distribution ORDER BY id DESC LIMIT 1), 30, 1);
-- Adds a Distribution that can be accepted up to 20 times that gives one of Item Type 31 (Equipment Box extra page) -- Adds a Distribution that can be accepted up to 20 times that gives one of Item Type 31 (Equipment Box extra page)
INSERT INTO distribution (type, event_name, description, times_acceptable, data) VALUES (1, 'Extra Equipment Storage', '~C05Adds one new page to your Equipment Box.', 20, ''::bytea); INSERT INTO distribution (type, event_name, description, times_acceptable) VALUES (1, 'Extra Equipment Storage', '~C05Adds one new page to your Equipment Box.', 20);
INSERT INTO distribution_items (distribution_id, item_type, quantity) VALUES ((SELECT id FROM distribution ORDER BY id DESC LIMIT 1), 31, 1); INSERT INTO distribution_items (distribution_id, item_type, quantity) VALUES ((SELECT id FROM distribution ORDER BY id DESC LIMIT 1), 31, 1);
END; END;

View File

@@ -264,7 +264,6 @@ CREATE TABLE public.distribution (
max_sr integer, max_sr integer,
min_gr integer, min_gr integer,
max_gr integer, max_gr integer,
data bytea NOT NULL,
rights integer, rights integer,
selection boolean selection boolean
); );

View File

@@ -0,0 +1 @@
ALTER TABLE public.distribution DROP COLUMN IF EXISTS data;