|
1
|
import { model } from "@medusajs/framework/utils" |
|
2
|
import { SearchIndexVersion } from "./search-index-version" |
|
3
|
|
|
4
|
export const SearchIndex = model |
|
5
|
.define("SearchIndex", { |
|
6
|
id: model.id({ prefix: "srhidx" }).primaryKey(), |
|
7
|
// The index name, as used in `query.search({ entity })`. |
|
8
|
// For now we expect the index and entity names to match. |
|
9
|
name: model.text(), |
|
10
|
// The version number of this index's version that serves reads. `null` |
|
11
|
// until the first version finishes seeding. |
|
12
|
active_version: model.number().nullable(), |
|
13
|
// Every physical index ever built for this logical index, in order. |
|
14
|
versions: model.hasMany(() => SearchIndexVersion, { |
|
15
|
mappedBy: "search_index", |
|
16
|
}), |
|
17
|
}) |
|
18
|
.indexes([ |
|
19
|
{ |
|
20
|
name: "IDX_search_index_name", |
|
21
|
on: ["name"], |
|
22
|
unique: true, |
|
23
|
where: "deleted_at IS NULL", |
|
24
|
}, |
|
25
|
]) |