# migrations

dir: embeddings_queue
filename: 00001-embeddings.sqlite.sql
hash: d3755dfd232be8e8301f4d7fcfb3a486
sql:
CREATE TABLE embeddings_queue (
    seq_id INTEGER PRIMARY KEY,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    operation INTEGER NOT NULL,
    topic TEXT NOT NULL,
    id TEXT NOT NULL,
    vector BLOB,
    encoding TEXT,
    metadata TEXT
);


dir: sysdb
filename: 00001-collections.sqlite.sql
hash: 38352d725ad1c16074fac420b22b4633
sql:
CREATE TABLE collections (
    id TEXT PRIMARY KEY,
    name TEXT NOT NULL,
    topic TEXT NOT NULL,
    UNIQUE (name)
);

CREATE TABLE collection_metadata (
    collection_id TEXT REFERENCES collections(id) ON DELETE CASCADE,
    key TEXT NOT NULL,
    str_value TEXT,
    int_value INTEGER,
    float_value REAL,
    PRIMARY KEY (collection_id, key)
);


dir: sysdb
filename: 00002-segments.sqlite.sql
hash: 2913cb6a503055a95f625448037e8912
sql:
CREATE TABLE segments (
    id TEXT PRIMARY KEY,
    type TEXT NOT NULL,
    scope TEXT NOT NULL,
    topic TEXT,
    collection TEXT REFERENCES collection(id)
);

CREATE TABLE segment_metadata (
    segment_id TEXT  REFERENCES segments(id) ON DELETE CASCADE,
    key TEXT NOT NULL,
    str_value TEXT,
    int_value INTEGER,
    float_value REAL,
    PRIMARY KEY (segment_id, key)
);


dir: sysdb
filename: 00004-tenants-databases.sqlite.sql
hash: 048867ce8fcdefe4023c7110e4433591
sql:
CREATE TABLE IF NOT EXISTS tenants (
    id TEXT PRIMARY KEY,
    UNIQUE (id)
);

CREATE TABLE IF NOT EXISTS databases (
    id TEXT PRIMARY KEY, -- unique globally
    name TEXT NOT NULL, -- unique per tenant
    tenant_id TEXT NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
    UNIQUE (tenant_id, name) -- Ensure that a tenant has only one database with a given name
);

CREATE TABLE IF NOT EXISTS collections_tmp (
    id TEXT PRIMARY KEY, -- unique globally
    name TEXT NOT NULL, -- unique per database
    topic TEXT NOT NULL,
    dimension INTEGER,
    database_id TEXT NOT NULL REFERENCES databases(id) ON DELETE CASCADE,
    UNIQUE (name, database_id)
);

-- Create default tenant and database
INSERT OR REPLACE INTO tenants (id) VALUES ('default_tenant'); -- The default tenant id is 'default_tenant' others are UUIDs
INSERT OR REPLACE INTO databases (id, name, tenant_id) VALUES ('00000000-0000-0000-0000-000000000000', 'default_database', 'default_tenant');

INSERT OR REPLACE INTO collections_tmp (id, name, topic, dimension, database_id)
    SELECT id, name, topic, dimension, '00000000-0000-0000-0000-000000000000' FROM collections;
DROP TABLE collections;
ALTER TABLE collections_tmp RENAME TO collections;


dir: sysdb
filename: 00005-remove-topic.sqlite.sql
hash: b1367c826b8fba5f96f27befdc1d42d2
sql:
-- Remove the topic column from the Collections and Segments tables

ALTER TABLE collections DROP COLUMN topic;
ALTER TABLE segments DROP COLUMN topic;


dir: metadb
filename: 00001-embedding-metadata.sqlite.sql
hash: 2b4cf52c4bb2676e21d6860a4409f856
sql:
CREATE TABLE embeddings (
    id INTEGER PRIMARY KEY,
    segment_id TEXT NOT NULL,
    embedding_id TEXT NOT NULL,
    seq_id BLOB NOT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (segment_id, embedding_id)
);

CREATE TABLE embedding_metadata (
    id INTEGER REFERENCES embeddings(id),
    key TEXT NOT NULL,
    string_value TEXT,
    int_value INTEGER,
    float_value REAL,
    PRIMARY KEY (id, key)
);

CREATE TABLE max_seq_id (
    segment_id TEXT PRIMARY KEY,
    seq_id BLOB NOT NULL
);

CREATE VIRTUAL TABLE embedding_fulltext USING fts5(id, string_value);


dir: metadb
filename: 00002-embedding-metadata.sqlite.sql
hash: 12a570f7121b3a8ce750a2a7c36da20f
sql:
-- SQLite does not support adding check with alter table, as a result, adding a check
-- involve creating a new table and copying the data over. It is over kill with adding
-- a boolean type column. The application write to the table needs to ensure the data
-- integrity.
ALTER TABLE embedding_metadata ADD COLUMN bool_value INTEGER


dir: metadb
filename: 00003-full-text-tokenize.sqlite.sql
hash: f97ad6334aeaa8f419f01110b648b97a
sql:
CREATE VIRTUAL TABLE embedding_fulltext_search USING fts5(string_value, tokenize='trigram');
INSERT INTO embedding_fulltext_search (rowid, string_value) SELECT rowid, string_value FROM embedding_metadata;
DROP TABLE embedding_fulltext;


# embeddings_queue

created_at: 2024-06-30 07:10:45
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: bcd43e91
encoding: FLOAT32
metadata:
{"chroma:document": "The probe accommodates the transmission of the multitude of signals across the\nboundary between the rotary and stationary components of the probe. These\nadvanced transducer technologies offer the potential for increased bandwidth,\nimproved beam profiles, better signal to noise ratio, reduced manufacturing\ncosts and advanced tissue characterization algorithms."}


created_at: 2024-06-30 07:10:52
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: d7e83d23
encoding: FLOAT32
metadata:
{"chroma:document": "Nozzle for use with two different fire fighting agents, these being a ball valve\nand an exit tube for each agent. Nozzle can also be used with a variety of other\nfire-fighting agents, such as water, smoke, and carbon monoxide."}


created_at: 2024-06-30 07:10:59
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: f0a94b66
encoding: FLOAT32
metadata:
{"chroma:document": "summarize: There is provided a skin rejuvenation composition which comprises at\nleast one oxidant. At least one healing factor chosen from hyaluronic acid,\nglucosamine and allantoin, in association with a pharmaceutically acceptable\ncarrier."}


created_at: 2024-06-30 07:11:09
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: 3bd10433
encoding: FLOAT32
metadata:
{"chroma:document": "A device for optical examination of human skin and its pigmentation comprises a\ncylindrical housing in which are arranged an optical observation device and a\nvertical illumination device. The housing is delimited by a plate made of\ntransparent plastics or glass, which is applied to a skin site to be examined\nwithout introducing an immersion fluid."}


created_at: 2024-06-30 07:11:16
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: 1e76332b
encoding: FLOAT32
metadata:
{"chroma:document": "A golf ball marker and holder includes a clip that is sized for attachment to a\nshoe. A marker having a solid face is also provided and is removably attached to\nsaid clip. One of the holder and the marker includes a ferrous portion, while\nthe other includes a magnetic portion."}


created_at: 2024-06-30 07:11:24
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: 9fcbc458
encoding: FLOAT32
metadata:
{"chroma:document": "Vehicle body restraint systems include buckles for latching and retaining latch\nplates. Latching mechanisms have oppositely oriented release mechanisms. Any\nforce applied to one release mechanism which would act to release a latch plate\ncreates an increased force on the opposing release mechanism to retain the latch\nplate in a locked position."}


created_at: 2024-06-30 07:11:30
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: 6907cd6b
encoding: FLOAT32
metadata:
{"chroma:document": "A combination treatment of N-(phenylethyl)succinamic acid or its salts and a\nplant growth regulator applied as a seed treatment or applied directly on or\nnear the root zone of the seedling or growing plant promotes plant growth."}


created_at: 2024-06-30 07:11:37
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: 327f181b
encoding: FLOAT32
metadata:
{"chroma:document": "A device for retarding hair loss and for stimulating its regrowth. Electrical\npulse generator connected to at least one electrically conducting cable (2, 20)\napplied to a person&#39;s skull. The device can also be used to stimulate hair\nregrowth in the scalp."}


created_at: 2024-06-30 07:11:47
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: c015baf7
encoding: FLOAT32
metadata:
{"chroma:document": "The invention is concerned with a method of producing hydrogen gas. The method\ncomprises the steps of: providing in a reaction container a composition\nincluding respective quantities of particulate elemental magnesium, particulates\nelemental iron, an additional elemental metal selected from the group and an\nalkali metal salt and water. causing said composition to react in said container\nto generate hydrogen gas; and recovering said evolved hydrogen Gas."}


created_at: 2024-06-30 07:11:54
topic: persistent://default/default/2fc21d37-1703-483a-8fa8-3a6cd9ec0f2e
id: e3c01889
encoding: FLOAT32
metadata:
{"chroma:document": "A bushing residing in each of a plurality of through holes has a bottom edge\nthat aligns with a protrusion on a screw head. The bottom edge aligning with the\nprotrusion inhibits reverse threading or backing out of the bone screw."}


# embedding_metadata

key: chroma:document
string_value:
The probe accommodates the transmission of the multitude of signals across the
boundary between the rotary and stationary components of the probe. These
advanced transducer technologies offer the potential for increased bandwidth,
improved beam profiles, better signal to noise ratio, reduced manufacturing
costs and advanced tissue characterization algorithms.


key: chroma:document
string_value:
Nozzle for use with two different fire fighting agents, these being a ball valve
and an exit tube for each agent. Nozzle can also be used with a variety of other
fire-fighting agents, such as water, smoke, and carbon monoxide.


key: chroma:document
string_value:
summarize: There is provided a skin rejuvenation composition which comprises at
least one oxidant. At least one healing factor chosen from hyaluronic acid,
glucosamine and allantoin, in association with a pharmaceutically acceptable
carrier.


key: chroma:document
string_value:
A device for optical examination of human skin and its pigmentation comprises a
cylindrical housing in which are arranged an optical observation device and a
vertical illumination device. The housing is delimited by a plate made of
transparent plastics or glass, which is applied to a skin site to be examined
without introducing an immersion fluid.


key: chroma:document
string_value:
A golf ball marker and holder includes a clip that is sized for attachment to a
shoe. A marker having a solid face is also provided and is removably attached to
said clip. One of the holder and the marker includes a ferrous portion, while
the other includes a magnetic portion.


key: chroma:document
string_value:
Vehicle body restraint systems include buckles for latching and retaining latch
plates. Latching mechanisms have oppositely oriented release mechanisms. Any
force applied to one release mechanism which would act to release a latch plate
creates an increased force on the opposing release mechanism to retain the latch
plate in a locked position.


key: chroma:document
string_value:
A combination treatment of N-(phenylethyl)succinamic acid or its salts and a
plant growth regulator applied as a seed treatment or applied directly on or
near the root zone of the seedling or growing plant promotes plant growth.


key: chroma:document
string_value:
A device for retarding hair loss and for stimulating its regrowth. Electrical
pulse generator connected to at least one electrically conducting cable (2, 20)
applied to a person&#39;s skull. The device can also be used to stimulate hair
regrowth in the scalp.


key: chroma:document
string_value:
The invention is concerned with a method of producing hydrogen gas. The method
comprises the steps of: providing in a reaction container a composition
including respective quantities of particulate elemental magnesium, particulates
elemental iron, an additional elemental metal selected from the group and an
alkali metal salt and water. causing said composition to react in said container
to generate hydrogen gas; and recovering said evolved hydrogen Gas.


key: chroma:document
string_value:
A bushing residing in each of a plurality of through holes has a bottom edge
that aligns with a protrusion on a screw head. The bottom edge aligning with the
protrusion inhibits reverse threading or backing out of the bone screw.


