Skip to content

Commit b971f54

Browse files
committed
fix(api): fully align headlines schema and seeder with model
The `headlines` table schema incorrectly contained a `content` column not present in the `Headline` model. Additionally, the seeder logic was not robustly handling all nullable fields (like `image_url`), causing a "Missing variable" crash. This change removes the `content` column from the schema and `INSERT` statement. It also updates the seeder to ensure all optional fields from the model are present in the parameter map. This fully aligns the database layer with the data model and resolves the final startup error.
1 parent 970fced commit b971f54

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/src/services/database_seeding_service.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ class DatabaseSeedingService {
111111
url TEXT,
112112
published_at TIMESTAMPTZ,
113113
description TEXT,
114-
content TEXT,
115114
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
116115
updated_at TIMESTAMPTZ,
117116
status TEXT,
@@ -275,16 +274,18 @@ class DatabaseSeedingService {
275274

276275
// Ensure optional fields exist for the postgres driver.
277276
params.putIfAbsent('description', () => null);
278-
params.putIfAbsent('content', () => null);
279277
params.putIfAbsent('updated_at', () => null);
278+
params.putIfAbsent('image_url', () => null);
279+
params.putIfAbsent('url', () => null);
280+
params.putIfAbsent('published_at', () => null);
280281

281282
await _connection.execute(
282283
Sql.named(
283284
'INSERT INTO headlines (id, title, source_id, category_id, '
284-
'image_url, url, published_at, description, content, status, '
285+
'image_url, url, published_at, description, status, '
285286
'type, created_at, updated_at) VALUES (@id, @title, @source_id, '
286287
'@category_id, @image_url, @url, @published_at, @description, '
287-
'@content, @status, @type, @created_at, @updated_at) '
288+
'@status, @type, @created_at, @updated_at) '
288289
'ON CONFLICT (id) DO NOTHING',
289290
),
290291
parameters: params,

0 commit comments

Comments
 (0)