Skip to content

Commit

Permalink
chore: removed register model from the standalone model helpers
Browse files Browse the repository at this point in the history
- This will ensure that the database singleton will be incharge
  of migrating the local database independently
  • Loading branch information
IamMuuo committed Jun 27, 2024
1 parent 20ab1b8 commit 44b4dfc
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 100 deletions.
13 changes: 0 additions & 13 deletions lib/models/core/course/course_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ class CourseModelHelper implements DatabaseOperations {
static final CourseModelHelper _instance = CourseModelHelper._internal();

factory CourseModelHelper() {
// Ensure the table is created when the factory constructor is called
DatabaseHelper().registerModel("""
CREATE TABLE IF NOT EXISTS courses (
unit TEXT PRIMARY KEY,
section TEXT NOT NULL,
day_of_the_week TEXT NOT NULL,
period TEXT NOT NULL,
campus TEXT NOT NULL,
room TEXT NOT NULL,
lecturer TEXT NOT NULL
);
""");

return _instance;
}

Expand Down
10 changes: 0 additions & 10 deletions lib/models/core/reward/reward_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ class RewardModelHelper implements DatabaseOperations {
static final RewardModelHelper _instance = RewardModelHelper._internal();

factory RewardModelHelper() {
DatabaseHelper().registerModel('''
CREATE TABLE IF NOT EXISTS rewards (
id TEXT PRIMARY KEY,
student_id TEXT NOT NULL,
points INTEGER NOT NULL,
reason TEXT NOT NULL,
awarded_at TEXT NOT NULL
)
''');

return _instance;
}

Expand Down
23 changes: 0 additions & 23 deletions lib/models/core/user/user_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,6 @@ class UserModelHelper implements DatabaseOperations {
static final UserModelHelper _instance = UserModelHelper._internal();

factory UserModelHelper() {
DatabaseHelper().registerModel("""
CREATE TABLE IF NOT EXISTS users (
id TEXT PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
admission_number TEXT UNIQUE,
national_id TEXT UNIQUE,
gender TEXT,
address TEXT,
email TEXT UNIQUE,
date_of_birth TEXT,
campus TEXT,
profile_url TEXT,
password TEXT,
active INTEGER,
vibe_points INTEGER,
point_transactions TEXT,
date_created TEXT,
date_updated TEXT
);
""");

return _instance;
}

Expand Down
17 changes: 0 additions & 17 deletions lib/storage/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,4 @@ class DatabaseHelper {
await db.execute(value);
});
}

/// [registerModel]
/// The register model creates a table to represent the model
/// in a relational sql format.
///
/// By default the [table] and [schema] are trimmed off whitespaces
/// and converted to lowercase for uniformity:
///
/// The schema should be like:
/// 'id integer primary key, name text, email text'
/// notice that there are no brakets
Future<void> registerModel(String schema) async {
// final db = await database;
// await db.execute(
// schema,
// );
}
}
11 changes: 0 additions & 11 deletions lib/tools/stories/models/core/organization_model_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ class OrganizationModelHelper implements DatabaseOperations {
OrganizationModelHelper._internal();

factory OrganizationModelHelper() {
DatabaseHelper().registerModel("""
CREATE TABLE IF NOT EXISTS organizations (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
phone TEXT,
email TEXT,
description TEXT,
profile TEXT,
date_added TEXT
);
""");
return _instance;
}

Expand Down
13 changes: 0 additions & 13 deletions lib/tools/stories/models/core/story_model_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ class StoryModelHelper implements DatabaseOperations {
static final StoryModelHelper _instance = StoryModelHelper._internal();

factory StoryModelHelper() {
DatabaseHelper().registerModel("""
CREATE TABLE IF NOT EXISTS stories (
id TEXT PRIMARY KEY,
organization TEXT NOT NULL,
hex_code TEXT,
text TEXT,
media TEXT,
viewed INTEGER,
date_added TEXT,
date_of_expiry TEXT
);
""");

return _instance;
}

Expand Down
13 changes: 0 additions & 13 deletions lib/tools/todo/models/todo_model_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ class TodoModelHelper implements DatabaseOperations {
static final TodoModelHelper _instance = TodoModelHelper._internal();

factory TodoModelHelper() {
DatabaseHelper().registerModel("""
CREATE TABLE IF NOT EXISTS todos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
color INTEGER NOT NULL,
complete INTEGER NOT NULL,
description TEXT NOT NULL,
due TEXT NOT NULL,
dateAdded TEXT NOT NULL,
dateCompleted TEXT
);
""");

return _instance;
}

Expand Down

0 comments on commit 44b4dfc

Please sign in to comment.