From fa09e4a39cd31c6cda0a06d8fa501d55fadcf49b Mon Sep 17 00:00:00 2001 From: Houmgaor Date: Fri, 27 Feb 2026 18:19:57 +0100 Subject: [PATCH] fix(migrations): drop unused data column from distribution table (#169) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- CHANGELOG.md | 4 ++++ server/channelserver/repo_distribution_test.go | 6 +++--- server/migrations/seed/DistributionDemo.sql | 4 ++-- server/migrations/sql/0001_init.sql | 1 - server/migrations/sql/0005_distribution_drop_data.sql | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 server/migrations/sql/0005_distribution_drop_data.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index fe0936a68..c16f08375 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Distribution table: remove unused `data bytea NOT NULL` column that prevented seed data from matching Go code expectations (#169) + ### Added - API: Standardized JSON error responses (`{"error":"...","message":"..."}`) across all endpoints via `writeError` helper diff --git a/server/channelserver/repo_distribution_test.go b/server/channelserver/repo_distribution_test.go index 72240436a..fc2286142 100644 --- a/server/channelserver/repo_distribution_test.go +++ b/server/channelserver/repo_distribution_test.go @@ -20,9 +20,9 @@ func createDistribution(t *testing.T, db *sqlx.DB, charID *uint32, distType int, t.Helper() var id uint32 err := db.QueryRow( - `INSERT INTO distribution (character_id, type, event_name, description, data, times_acceptable) - VALUES ($1, $2, $3, $4, $5, 1) RETURNING id`, - charID, distType, eventName, description, []byte{0x00}, + `INSERT INTO distribution (character_id, type, event_name, description, times_acceptable) + VALUES ($1, $2, $3, $4, 1) RETURNING id`, + charID, distType, eventName, description, ).Scan(&id) if err != nil { t.Fatalf("Failed to create distribution: %v", err) diff --git a/server/migrations/seed/DistributionDemo.sql b/server/migrations/seed/DistributionDemo.sql index c37a16a57..d5da8688e 100644 --- a/server/migrations/seed/DistributionDemo.sql +++ b/server/migrations/seed/DistributionDemo.sql @@ -1,11 +1,11 @@ BEGIN; -- 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); -- 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); END; \ No newline at end of file diff --git a/server/migrations/sql/0001_init.sql b/server/migrations/sql/0001_init.sql index c5ac2b225..3f15fdd23 100644 --- a/server/migrations/sql/0001_init.sql +++ b/server/migrations/sql/0001_init.sql @@ -264,7 +264,6 @@ CREATE TABLE public.distribution ( max_sr integer, min_gr integer, max_gr integer, - data bytea NOT NULL, rights integer, selection boolean ); diff --git a/server/migrations/sql/0005_distribution_drop_data.sql b/server/migrations/sql/0005_distribution_drop_data.sql new file mode 100644 index 000000000..1113b877e --- /dev/null +++ b/server/migrations/sql/0005_distribution_drop_data.sql @@ -0,0 +1 @@ +ALTER TABLE public.distribution DROP COLUMN IF EXISTS data;