-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautonomy.ts
More file actions
58 lines (51 loc) · 1.86 KB
/
Copy pathautonomy.ts
File metadata and controls
58 lines (51 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* autonomy.ts - Autonomy schema (blueprint definition)
*
* Data* nodes: SearchUnified
*/
import {
type BlueprintDefinition,
M2M_JUNCTION_OPTS,
provisionBlueprint,
} from '../blueprint';
const definition: BlueprintDefinition = {
tables: [
{
ref: 'autonomy_records',
table_name: 'autonomy_records',
nodes: [
'DataId',
'DataTimestamps',
{ $type: 'SearchUnified', data: {
embedding: { source_fields: ['title', 'content'] },
bm25: { field_name: 'embedding_text' },
}},
],
fields: [
{ name: 'title', type: 'text', is_required: true },
{ name: 'record_type', type: 'text' },
{ name: 'content', type: 'text' },
{ name: 'status', type: 'text', default_value: "'active'" },
{ name: 'priority', type: 'int', default_value: '0' },
{ name: 'source', type: 'text' },
{ name: 'context', type: 'jsonb' },
{ name: 'tags', type: 'citext[]' },
],
},
],
relations: [
{ $type: 'RelationManyToMany', source_ref: 'autonomy_records', target_ref: 'autonomy_records', junction_table_name: 'autonomy_record_links', source_field_name: 'source_record_id', target_field_name: 'target_record_id', ...M2M_JUNCTION_OPTS },
],
indexes: [
{ table_ref: 'autonomy_records', column: 'tags', access_method: 'gin' },
{ table_ref: 'autonomy_records', column: 'context', access_method: 'gin' },
{ table_ref: 'autonomy_records', column: 'record_type', access_method: 'btree' },
{ table_ref: 'autonomy_records', column: 'status', access_method: 'btree' },
{ table_ref: 'autonomy_records', column: 'priority', access_method: 'btree' },
{ table_ref: 'autonomy_records', column: 'source', access_method: 'btree' },
],
};
async function main() {
await provisionBlueprint(definition, 'Autonomy Schema');
}
export { main as default };