Skip to content

Commit

Permalink
feat: Add setIsArchiveDevice() method (#932)
Browse files Browse the repository at this point in the history
* feat: Add setIsArchiveDevice() method

Does not change sync at this time, but does persist setting.

* migrate deviceInfo column to nullable

* test migration of deviceInfo

* rename table in migration

* revert changes to mapeo manager

* Apply suggestions from code review

Co-authored-by: Evan Hahn <[email protected]>

* address PR review comments

* address one missing comment

* fix types test

---------

Co-authored-by: Evan Hahn <[email protected]>
  • Loading branch information
gmaclennan and EvanHahn authored Oct 22, 2024
1 parent f3d62c0 commit 5975e03
Show file tree
Hide file tree
Showing 11 changed files with 491 additions and 8 deletions.
12 changes: 12 additions & 0 deletions drizzle/client/0001_chubby_cargill.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Manually generated migration because SQLITE and Drizzle do not support
altering a column to be nullable.
*/
ALTER TABLE `localDeviceInfo` RENAME TO `deviceSettings`;--> statement-breakpoint
DROP INDEX IF EXISTS `localDeviceInfo_deviceId_unique`;--> statement-breakpoint
ALTER TABLE deviceSettings ADD `isArchiveDevice` integer;--> statement-breakpoint
ALTER TABLE deviceSettings RENAME COLUMN `deviceInfo` TO `deviceInfoOld`;--> statement-breakpoint
ALTER TABLE deviceSettings ADD `deviceInfo` text;--> statement-breakpoint
UPDATE deviceSettings SET `deviceInfo` = `deviceInfoOld`;--> statement-breakpoint
ALTER TABLE deviceSettings DROP COLUMN `deviceInfoOld`;--> statement-breakpoint
CREATE UNIQUE INDEX `deviceSettings_deviceId_unique` ON `deviceSettings` (`deviceId`);
208 changes: 208 additions & 0 deletions drizzle/client/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
{
"version": "5",
"dialect": "sqlite",
"id": "a80440f2-1097-40a6-ab81-3295f0a8c5c1",
"prevId": "e75103ab-bbcb-4ca9-a0c4-2d9095b63add",
"tables": {
"deviceSettings": {
"name": "deviceSettings",
"columns": {
"deviceId": {
"name": "deviceId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"deviceInfo": {
"name": "deviceInfo",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"isArchiveDevice": {
"name": "isArchiveDevice",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"deviceSettings_deviceId_unique": {
"name": "deviceSettings_deviceId_unique",
"columns": [
"deviceId"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"projectSettings_backlink": {
"name": "projectSettings_backlink",
"columns": {
"versionId": {
"name": "versionId",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"projectKeys": {
"name": "projectKeys",
"columns": {
"projectId": {
"name": "projectId",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"projectPublicId": {
"name": "projectPublicId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"projectInviteId": {
"name": "projectInviteId",
"type": "blob",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keysCipher": {
"name": "keysCipher",
"type": "blob",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"projectInfo": {
"name": "projectInfo",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'{}'"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"projectSettings": {
"name": "projectSettings",
"columns": {
"docId": {
"name": "docId",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"versionId": {
"name": "versionId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"originalVersionId": {
"name": "originalVersionId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"schemaName": {
"name": "schemaName",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updatedAt": {
"name": "updatedAt",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"links": {
"name": "links",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"deleted": {
"name": "deleted",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"defaultPresets": {
"name": "defaultPresets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"configMetadata": {
"name": "configMetadata",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"forks": {
"name": "forks",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {
"\"localDeviceInfo\"": "\"deviceSettings\""
},
"columns": {}
}
}
7 changes: 7 additions & 0 deletions drizzle/client/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
"when": 1726514276007,
"tag": "0000_bumpy_carnage",
"breakpoints": true
},
{
"idx": 1,
"version": "5",
"when": 1729605656745,
"tag": "0001_chubby_cargill",
"breakpoints": true
}
]
}
57 changes: 57 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"homepage": "https://github.com/digidem/comapeo-core#readme",
"devDependencies": {
"@bufbuild/buf": "^1.26.1",
"@comapeo/core2.0.1": "npm:@comapeo/[email protected]",
"@mapeo/default-config": "5.0.0",
"@mapeo/mock-data": "2.0.0",
"@sinonjs/fake-timers": "^10.0.2",
Expand Down
Loading

0 comments on commit 5975e03

Please sign in to comment.