Skip to content

Commit f2af724

Browse files
committed
refactor(api): remove slug from categories table and seeder
The `slug` field is not used by the client applications and was causing a mismatch between the `Category` data model and the database schema, leading to a server crash on startup. This change removes the `slug` column from the `categories` table definition and updates the database seeder to no longer attempt to insert a slug. The `ON CONFLICT` clause for seeding has been updated to use the primary key `id` to ensure idempotency.
1 parent 3704dda commit f2af724

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/src/services/database_seeding_service.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class DatabaseSeedingService {
6060
CREATE TABLE IF NOT EXISTS categories (
6161
id TEXT PRIMARY KEY,
6262
name TEXT NOT NULL,
63-
slug TEXT NOT NULL UNIQUE,
6463
description TEXT,
6564
status TEXT,
6665
type TEXT,
@@ -164,10 +163,10 @@ class DatabaseSeedingService {
164163
final category = Category.fromJson(data);
165164
await _connection.execute(
166165
Sql.named(
167-
'INSERT INTO categories (id, name, slug, description, status, '
168-
'type, created_at, updated_at) VALUES (@id, @name, @slug, '
166+
'INSERT INTO categories (id, name, description, status, '
167+
'type, created_at, updated_at) VALUES (@id, @name, '
169168
'@description, @status, @type, @created_at, @updated_at) '
170-
'ON CONFLICT (slug) DO NOTHING',
169+
'ON CONFLICT (id) DO NOTHING',
171170
),
172171
parameters: category.toJson(),
173172
);

0 commit comments

Comments
 (0)