Skip to content

Commit

Permalink
Add migration, add group and placeId to calendar item
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Apr 27, 2024
1 parent 80162db commit 84f465f
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 23 deletions.
11 changes: 10 additions & 1 deletion api/lib/models/event/item/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class CalendarItemDatabaseService extends CalendarItemService
description TEXT NOT NULL DEFAULT '',
location VARCHAR(100) NOT NULL DEFAULT '',
eventId BLOB(16),
groupId BLOB(16),
placeId BLOB(16),
start INTEGER,
end INTEGER,
status VARCHAR(20) NOT NULL DEFAULT 'confirmed',
Expand All @@ -42,7 +44,14 @@ class CalendarItemDatabaseService extends CalendarItemService
}

@override
FutureOr<void> migrate(Database db, int version) {}
Future<void> migrate(Database db, int version) async {
if (version < 3) {
await db.transaction((txn) async {
await txn.execute("ALTER TABLE calendarItems ADD groupId BLOB(16)");
await txn.execute("ALTER TABLE calendarItems ADD placeId BLOB(16)");
});
}
}

@override
Future<List<ConnectedModel<CalendarItem, Event?>>> getCalendarItems(
Expand Down
3 changes: 3 additions & 0 deletions api/lib/models/event/item/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CalendarItem with _$CalendarItem implements DescriptiveModel {
@Default('') String name,
@Default('') String description,
@Default('') String location,
@MultihashConverter() Multihash? groupId,
@MultihashConverter() Multihash? placeId,
@MultihashConverter() Multihash? eventId,
@Default(EventStatus.confirmed) EventStatus status,
Expand All @@ -31,6 +32,7 @@ class CalendarItem with _$CalendarItem implements DescriptiveModel {
@Default('') String name,
@Default('') String description,
@Default('') String location,
@MultihashConverter() Multihash? groupId,
@MultihashConverter() Multihash? placeId,
@MultihashConverter() Multihash? eventId,
@Default(EventStatus.confirmed) EventStatus status,
Expand All @@ -49,6 +51,7 @@ class CalendarItem with _$CalendarItem implements DescriptiveModel {
@Default('') String name,
@Default('') String description,
@Default('') String location,
@MultihashConverter() Multihash? groupId,
@MultihashConverter() Multihash? placeId,
@MultihashConverter() Multihash? eventId,
@Default(EventStatus.confirmed) EventStatus status,
Expand Down
Loading

0 comments on commit 84f465f

Please sign in to comment.