Skip to content

Commit 942914e

Browse files
committed
feat!: remove rocrate column from Entity table
BREAKING CHANGE: The rocrate JSON column has been removed from the Entity table. RO-Crate metadata is now served exclusively via the roCrateHandler from external sources (filesystem, S3, etc.) rather than being stored in the database. Changes: - Remove rocrate column from Prisma schema - Add migration to drop the column - Update seed script and loadEntities to not store rocrate - Remove rocrate from OpenSearch index mapping - Update all test files to remove rocrate from mock data - Update documentation to clarify rocrate is not stored in DB The /entity/:id/rocrate endpoint continues to work using the configured roCrateHandler to serve RO-Crate data from external storage.
1 parent f2cae2a commit 942914e

File tree

13 files changed

+16
-98
lines changed

13 files changed

+16
-98
lines changed

CLAUDE.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,36 +1386,7 @@ type HeadRoCrateHandler = (
13861386

13871387
#### RO-Crate Handler Examples
13881388

1389-
**Stream from Database**:
1390-
1391-
```typescript
1392-
roCrateHandler: {
1393-
get: async (entity) => {
1394-
const rocrate = entity.rocrate;
1395-
const jsonString = JSON.stringify(rocrate, null, 2);
1396-
1397-
return {
1398-
type: 'stream',
1399-
stream: Readable.from([jsonString]),
1400-
metadata: {
1401-
contentType: 'application/ld+json',
1402-
contentLength: Buffer.byteLength(jsonString),
1403-
etag: `"${entity.id}-rocrate"`,
1404-
lastModified: entity.updatedAt,
1405-
},
1406-
};
1407-
},
1408-
head: async (entity) => {
1409-
const jsonString = JSON.stringify(entity.rocrate);
1410-
return {
1411-
contentType: 'application/ld+json',
1412-
contentLength: Buffer.byteLength(jsonString),
1413-
etag: `"${entity.id}-rocrate"`,
1414-
lastModified: entity.updatedAt,
1415-
};
1416-
},
1417-
}
1418-
```
1389+
**Note**: RO-Crate metadata is NOT stored in the database. The `roCrateHandler` must serve RO-Crate data from external sources (filesystem, S3, etc.).
14191390

14201391
**Serve from Filesystem**:
14211392

example/data/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ Entities are stored in the `Entity` table with:
277277
- `rootCollection`: Top-level collection reference
278278
- `metadataLicenseId`: License for metadata
279279
- `contentLicenseId`: License for content
280-
- `rocrate`: Full RO-Crate metadata (JSON)
280+
- `meta`: Storage metadata (JSON, optional)
281+
282+
Note: RO-Crate metadata is served via the `/entity/:id/rocrate` endpoint using the configured `roCrateHandler`, not stored in the database.
281283

282284
### OpenSearch Mappings
283285

example/data/seed.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const processCollection = async (
7474
collectionRoot.contentLicense?.['@id'] ||
7575
collectionRoot.license?.['@id'] ||
7676
'https://creativecommons.org/licenses/by/4.0/',
77-
rocrate: collectionCrate,
7877
meta: {
7978
storagePath: collectionPath,
8079
},
@@ -115,7 +114,6 @@ const processItem = async (
115114
itemRoot.metadataLicense?.['@id'] || itemRoot.license?.['@id'] || 'https://creativecommons.org/licenses/by/4.0/',
116115
contentLicenseId:
117116
itemRoot.contentLicense?.['@id'] || itemRoot.license?.['@id'] || 'https://creativecommons.org/licenses/by/4.0/',
118-
rocrate: itemCrate,
119117
meta: {
120118
storagePath: itemPath,
121119
},
@@ -167,7 +165,6 @@ const processItem = async (
167165
itemRoot.contentLicense?.['@id'] ||
168166
itemRoot.license?.['@id'] ||
169167
'https://creativecommons.org/licenses/by/4.0/',
170-
rocrate: fileNode,
171168
meta: {
172169
remapRootTo: fileRocrateId,
173170
storagePath: itemPath,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `rocrate` on the `Entity` table. All the data in the column will be lost.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE `Entity` DROP COLUMN `rocrate`;

prisma/models/entity.prisma

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ model Entity {
1313
contentLicenseId String @db.VarChar(2048)
1414
fileId String? @db.VarChar(2048)
1515
16-
rocrate Json
1716
meta Json?
1817
1918
createdAt DateTime @default(now())

scripts/loadEntities.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,6 @@ const fetchEntities = async (limit: number, offset: number) => {
4848
return result;
4949
};
5050

51-
const fetchEntityRocrate = async (entityId: string) => {
52-
const url = `${API_URL}/entity/${encodeURIComponent(entityId)}`;
53-
console.log(`Fetching ROCrate for ${entityId}`);
54-
55-
const response = await fetch(url);
56-
if (!response.ok) {
57-
throw new Error(`ROCrate API request failed with status ${response.status} for entity ${entityId}`);
58-
}
59-
60-
const rocrate = await response.json();
61-
return rocrate;
62-
};
63-
6451
const generateDummyData = () => {
6552
const languages = ['English', 'Japanese', 'French', 'Spanish', 'German', 'Italian'];
6653
const mediaTypes = ['audio/wav', 'audio/mp3', 'video/mp4', 'text/plain', 'image/jpeg'];
@@ -114,7 +101,6 @@ const createIndex = async () => {
114101
location: { type: 'geo_point' },
115102
createdAt: { type: 'date' },
116103
updatedAt: { type: 'date' },
117-
rocrate: { type: 'text' },
118104
},
119105
},
120106
},
@@ -129,7 +115,7 @@ const createIndex = async () => {
129115

130116
// Index entity to OpenSearch
131117
// biome-ignore lint/suspicious/noExplicitAny: FIXME
132-
const indexEntity = async (entity: any, dummyData: any, rocrate: any) => {
118+
const indexEntity = async (entity: any, dummyData: any) => {
133119
const document = {
134120
rocrateId: entity.id,
135121
name: entity.name,
@@ -144,7 +130,6 @@ const indexEntity = async (entity: any, dummyData: any, rocrate: any) => {
144130
location: dummyData.location,
145131
createdAt: new Date().toISOString(),
146132
updatedAt: new Date().toISOString(),
147-
rocrate: JSON.stringify(rocrate),
148133
};
149134

150135
await opensearch.index({
@@ -174,9 +159,6 @@ const loadEntities = async (): Promise<void> => {
174159
for (const entity of data.entities) {
175160
const dummyData = generateDummyData();
176161

177-
// Fetch ROCrate data for this entity
178-
const rocrate = await fetchEntityRocrate(entity.id);
179-
180162
await prisma.entity.create({
181163
data: {
182164
rocrateId: entity.id,
@@ -185,11 +167,12 @@ const loadEntities = async (): Promise<void> => {
185167
entityType: entity.entityType,
186168
memberOf: entity.memberOf || null,
187169
rootCollection: entity.root || null,
188-
rocrate: rocrate,
170+
metadataLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
171+
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
189172
},
190173
});
191174

192-
await indexEntity(entity, dummyData, rocrate);
175+
await indexEntity(entity, dummyData);
193176
}
194177

195178
processedCount += data.entities.length;

src/routes/crate.test.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,6 @@ describe('Crate Route', () => {
3939
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
4040
createdAt: new Date(),
4141
updatedAt: new Date(),
42-
rocrate: {
43-
'@context': 'https://w3id.org/ro/crate/1.1/context',
44-
'@graph': [
45-
{
46-
'@id': 'ro-crate-metadata.json',
47-
'@type': 'CreativeWork',
48-
conformsTo: { '@id': 'https://w3id.org/ro/crate/1.1' },
49-
about: { '@id': './' },
50-
},
51-
{
52-
'@id': './',
53-
'@type': 'Dataset',
54-
name: 'Test RO-Crate',
55-
},
56-
],
57-
},
5842
meta: {},
5943
};
6044

src/routes/entities.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ describe('Entities Route', () => {
3030
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
3131
createdAt: new Date(),
3232
updatedAt: new Date(),
33-
rocrate: {},
3433
meta: {},
3534
},
3635
{
@@ -46,7 +45,6 @@ describe('Entities Route', () => {
4645
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
4746
createdAt: new Date(),
4847
updatedAt: new Date(),
49-
rocrate: {},
5048
meta: {},
5149
},
5250
];
@@ -296,7 +294,6 @@ describe('Entities Route', () => {
296294
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
297295
createdAt: new Date(),
298296
updatedAt: new Date(),
299-
rocrate: {},
300297
meta: {},
301298
},
302299
];

src/routes/entity.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ describe('Entity Route', () => {
3030
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
3131
createdAt: new Date(),
3232
updatedAt: new Date(),
33-
rocrate: {},
3433
meta: {},
3534
};
3635

@@ -143,7 +142,6 @@ describe('Entity Route', () => {
143142
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
144143
createdAt: new Date(),
145144
updatedAt: new Date(),
146-
rocrate: {},
147145
meta: {},
148146
};
149147

src/routes/search.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,6 @@ describe('Search Route', () => {
810810
id: 1,
811811
fileId: null,
812812
meta: {},
813-
rocrate: '',
814813
rocrateId: 'http://example.com/entity/1',
815814
name: 'Test Entity 1',
816815
description: 'Entity with missing parent',

0 commit comments

Comments
 (0)