Skip to content

Commit 1ddc3a4

Browse files
committed
fix(api): align user_app_settings schema with model
The `user_app_settings` table incorrectly defined the `language` column as `JSONB`, while the `UserAppSettings` model correctly defines it as a `String`. This caused a crash during database seeding when trying to call `.toJson()` on a String. This change corrects the `language` column type to `TEXT` in the schema and updates the seeding logic to pass the language as a simple string, aligning the database with the data model and resolving the startup error.
1 parent 2ed4fbf commit 1ddc3a4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/src/services/database_seeding_service.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ class DatabaseSeedingService {
119119
CREATE TABLE IF NOT EXISTS user_app_settings (
120120
id TEXT PRIMARY KEY,
121121
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
122-
display_settings JSONB NOT NULL,
123-
language JSONB NOT NULL,
122+
display_settings JSONB NOT NULL, -- Nested object, stored as JSON
123+
language TEXT NOT NULL, -- Simple string, stored as TEXT
124124
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
125125
updated_at TIMESTAMPTZ
126126
);
@@ -337,8 +337,10 @@ class DatabaseSeedingService {
337337
parameters: {
338338
'id': adminSettings.id,
339339
'user_id': adminUser.id,
340-
'display_settings': adminSettings.displaySettings.toJson(),
341-
'language': adminSettings.language.toJson(),
340+
'display_settings':
341+
adminSettings.displaySettings.toJson(), // This is a complex object
342+
'language':
343+
adminSettings.language, // This is a simple String
342344
},
343345
);
344346

0 commit comments

Comments
 (0)