Skip to content

Commit

Permalink
Fix migration
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Mar 5, 2025
1 parent e7c8899 commit 8f2cd2a
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 64 deletions.
38 changes: 30 additions & 8 deletions api/lib/services/migration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,57 @@ Future<void> migrateDatabase(DatabaseService service, Database db,
await service.userGroup.create(db);
await db.execute("ALTER TABLE places RENAME TO resources");
await db.execute("PRAGMA foreign_keys=off");

// Migrate events
await db.transaction((txn) async {
await service.event.create(txn, 'events_temp');
await txn.execute(
"INSERT INTO events_temp SELECT id, parentId, blocked, name, description, location, extra FROM events");
"INSERT INTO events_temp SELECT id, parentId, blocked, name, description, location, extra FROM events",
);
await txn.execute(
"INSERT INTO eventResources(eventId, resourceId) SELECT id, placeId FROM events");
"INSERT INTO eventResources(eventId, resourceId) "
"SELECT id, placeId FROM events WHERE placeId IS NOT NULL",
);
await txn.execute(
"INSERT INTO eventGroups(eventId, groupId) SELECT id, groupId FROM events");
"INSERT INTO eventGroups(eventId, groupId) "
"SELECT id, groupId FROM events WHERE groupId IS NOT NULL",
);
await txn.execute("DROP TABLE events");
await txn.execute("ALTER TABLE events_temp RENAME TO events");
});

// Migrate calendarItems
await db.transaction((txn) async {
await service.calendarItem.create(txn, 'calendarItems_temp');
await txn.execute(
"INSERT INTO calendarItems_temp SELECT id, parentId, blocked, name, description, location, extra FROM calendarItems");
"INSERT INTO calendarItems_temp "
"SELECT id, parentId, blocked, name, description, location, extra "
"FROM calendarItems",
);
await txn.execute(
"INSERT INTO calendarItemResources(itemId, resourceId) SELECT id, placeId FROM calendarItems");
"INSERT INTO calendarItemResources(itemId, resourceId) "
"SELECT id, placeId FROM calendarItems WHERE placeId IS NOT NULL",
);
await txn.execute(
"INSERT INTO calendarItemGroups(itemId, groupId) SELECT id, groupId FROM calendarItems");
"INSERT INTO calendarItemGroups(itemId, groupId) "
"SELECT id, groupId FROM calendarItems WHERE groupId IS NOT NULL",
);
await txn.execute("DROP TABLE calendarItems");
await txn
.execute("ALTER TABLE calendarItems_temp RENAME TO calendarItems");
});

// Migrate users
await db.transaction((txn) async {
await service.user.create(txn, 'users_temp');
await txn.execute(
"INSERT INTO users_temp SELECT id, name, email, description, phone, image FROM users");
"INSERT INTO users_temp "
"SELECT id, name, email, description, phone, image FROM users",
);
await txn.execute(
"INSERT INTO userGroups(userId, groupId) SELECT id, groupId FROM users");
"INSERT INTO userGroups(userId, groupId) "
"SELECT id, groupId FROM users WHERE groupId IS NOT NULL",
);
await txn.execute("DROP TABLE users");
await txn.execute("ALTER TABLE users_temp RENAME TO users");
});
Expand Down
2 changes: 1 addition & 1 deletion app/lib/pages/events/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class EventDialog extends StatelessWidget {
title: Text(create
? AppLocalizations.of(context).createEvent
: AppLocalizations.of(context).editEvent),
constraints: const BoxConstraints(maxWidth: 600, maxHeight: 800),
constraints: const BoxConstraints(maxWidth: 600, maxHeight: 600),
content: DefaultTabController(
length: tabs ? 5 : 1,
child: Column(
Expand Down
8 changes: 4 additions & 4 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ packages:
dependency: transitive
description:
name: dev_build
sha256: f658f2fbf601b40d103fb9cb8db277da0a2022173950aa2aadf0f8cbcdf7c8c3
sha256: "6e5251015d8fd2f5597615cef58c9f7e69035085520de97fd055c02ecfa5afa6"
url: "https://pub.dev"
source: hosted
version: "1.1.2+5"
version: "1.1.2+6"
dynamic_color:
dependency: "direct main"
description:
Expand Down Expand Up @@ -876,10 +876,10 @@ packages:
dependency: transitive
description:
name: process_run
sha256: "01a48e04fbb489d1e4610ed361f6b3f21aea0966dfa0ff9227e9c4095cd6d3fb"
sha256: "6ec839cdd3e6de4685318e7686cd4abb523c3d3a55af0e8d32a12ae19bc66622"
url: "https://pub.dev"
source: hosted
version: "1.2.3"
version: "1.2.4"
provider:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@phosphor-icons/react": "^2.1.7",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"astro": "^5.4.1",
"astro": "^5.4.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"remark-gemoji": "^8.0.0",
Expand Down
Loading

0 comments on commit 8f2cd2a

Please sign in to comment.