# 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: 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-03-22 05:04:16
topic: persistent://default/default/123fcb6e-ab0d-4d21-8ceb-c8b480755d13
id: 9ff3d348-e809-11ee-b82b-066dd1d05bb5
encoding: FLOAT32
metadata:
{"chroma:document": "wfcc-account\ndecoupled-terraform-mktg-clarative\nmlplats-keypass\nwayfairquickview\ncrm-consumers\ncdse-supplier-preferred-service\ndriver-app-updates-consumer-descartes\nmarketing-bidding-util-service\ncm-wpp-analytics-ui\nph-payment-terms-adapter\noac-php-symfony-release-test\ndserrao-consumer-test-sandbox\nwcs-transportation-consumer\nsemantic-model-index-service-v2\nwfnfa\njanus-pre-enroll-model-server\nbq-visualizer\nwaypi-po-consumer\njaimik-ml-test\ncsrt-egress-relay\nwkshop-ttewari-part3\nadtech-adverts-searchinterp-rq-gen\nflagger-ml-java-test\nistio-feature-stats\npricing-target-price-competitor-price-qa01\nbi-merch-dflow-checker\nsweetwater-theia-ca-v2\nsearchtech-pipeline-property-model-job\ntanvi-test-roomba\nfraudo-order-check\nfinance-ar-utility\nyashcloudruntest\npricing-inputs-liteship-orchestrator\nartemis-scheduled-solr\nsupplier-ops-trigger-service\nsupplier-dropship-offer-service\npricing-supplier-promo-change-consumer-staging\nanalytics-streaming-service-v2\nghway23-bostonteam2-env\nhomebase-docs"}


created_at: 2024-03-22 05:04:16
topic: persistent://default/default/123fcb6e-ab0d-4d21-8ceb-c8b480755d13
id: 9ff3d398-e809-11ee-b82b-066dd1d05bb5
encoding: FLOAT32
metadata:
{"chroma:document": "slack-bot-test\nsqlissueyashtestrepo\ncldrnwrkshp0045-part1\nsendtogcs\nallocation-plan-evaluator\ngstdea-aerospike-poc\nds-service\ncontent-product-attributes-export-excel-creator\ntest-vatan\npartner-home-user-data-service\nwarranty-python\nproduct-transformation-uber-loader\nterraform-google-cloudsql-import\ntestowner2\ntesting-buildkite-hooks\ndemand-forecast-service\nmriyadh-cloudrun\nscribe-websocket\nfactory-management\norder-access-data-module\nb2b-pride-vertex\ncomp-img-pub-sub\nimage-embedding\ngbq-wrapper-svc\njpapanicholas-test-react-profiling-2\nsf-promos-promocodes-cron\nfirst-mamba-app-test\ncldrnwrkshp0016-part1\nwfcc-capone-com-srv-access-token-refresh-buildkite-plugin\ngstdea-supplier-onboarding-cdl\nanalytics-slack-internal-worker\nwcp-trackingevents-projector\nproduct-similarity-platform-evaluation-and-testing\ncolin-byod-test-delete-me\ncldrnwrkshp0046-part1\nspring-boot-tekton-demo-spring-batch\nb2c-vfs-features-pipelines\ncloud-functions-buildkite-plugin\nmartech-gap-pla-bing-ads-systems"}


created_at: 2024-03-22 05:04:16
topic: persistent://default/default/123fcb6e-ab0d-4d21-8ceb-c8b480755d13
id: 9ff3d3ac-e809-11ee-b82b-066dd1d05bb5
encoding: FLOAT32
metadata:
{"chroma:document": "email-service-priority\ncatalog-material-desc-consolidation\ncfop-discovery\nwayfairhuman-readable-context\nhappiness-survey\nnet-core-buildkite-gen-test2\npricing-strategy-grpc-service-test3\ntrackingclient\nfeature-reservations-client-php\nwkshop-bsahu2-part1\nfps-requests-batch-reactor\ncustomer-platforms-terraform\ngst-hackaway23-hermes-consumer\ncsdf-dev-tool\nlegacy-supplier-entities-adapter-unified\nfinance-revenue-order-payment\nwgcp-srs-unmatched-scan-handler\nsales-product-api\npre-checks-kafka\ngst-hackathon23-merchant-lens-iac\nsf-devcon\nserveng-service-eng-order-access-gql-federation"}


# embedding_metadata

key: chroma:document
string_value:
wfcc-account
decoupled-terraform-mktg-clarative
mlplats-keypass
wayfairquickview
crm-consumers
cdse-supplier-preferred-service
driver-app-updates-consumer-descartes
marketing-bidding-util-service
cm-wpp-analytics-ui
ph-payment-terms-adapter
oac-php-symfony-release-test
dserrao-consumer-test-sandbox
wcs-transportation-consumer
semantic-model-index-service-v2
wfnfa
janus-pre-enroll-model-server
bq-visualizer
waypi-po-consumer
jaimik-ml-test
csrt-egress-relay
wkshop-ttewari-part3
adtech-adverts-searchinterp-rq-gen
flagger-ml-java-test
istio-feature-stats
pricing-target-price-competitor-price-qa01
bi-merch-dflow-checker
sweetwater-theia-ca-v2
searchtech-pipeline-property-model-job
tanvi-test-roomba
fraudo-order-check
finance-ar-utility
yashcloudruntest
pricing-inputs-liteship-orchestrator
artemis-scheduled-solr
supplier-ops-trigger-service
supplier-dropship-offer-service
pricing-supplier-promo-change-consumer-staging
analytics-streaming-service-v2
ghway23-bostonteam2-env
homebase-docs


key: chroma:document
string_value:
slack-bot-test
sqlissueyashtestrepo
cldrnwrkshp0045-part1
sendtogcs
allocation-plan-evaluator
gstdea-aerospike-poc
ds-service
content-product-attributes-export-excel-creator
test-vatan
partner-home-user-data-service
warranty-python
product-transformation-uber-loader
terraform-google-cloudsql-import
testowner2
testing-buildkite-hooks
demand-forecast-service
mriyadh-cloudrun
scribe-websocket
factory-management
order-access-data-module
b2b-pride-vertex
comp-img-pub-sub
image-embedding
gbq-wrapper-svc
jpapanicholas-test-react-profiling-2
sf-promos-promocodes-cron
first-mamba-app-test
cldrnwrkshp0016-part1
wfcc-capone-com-srv-access-token-refresh-buildkite-plugin
gstdea-supplier-onboarding-cdl
analytics-slack-internal-worker
wcp-trackingevents-projector
product-similarity-platform-evaluation-and-testing
colin-byod-test-delete-me
cldrnwrkshp0046-part1
spring-boot-tekton-demo-spring-batch
b2c-vfs-features-pipelines
cloud-functions-buildkite-plugin
martech-gap-pla-bing-ads-systems


key: chroma:document
string_value:
email-service-priority
catalog-material-desc-consolidation
cfop-discovery
wayfairhuman-readable-context
happiness-survey
net-core-buildkite-gen-test2
pricing-strategy-grpc-service-test3
trackingclient
feature-reservations-client-php
wkshop-bsahu2-part1
fps-requests-batch-reactor
customer-platforms-terraform
gst-hackaway23-hermes-consumer
csdf-dev-tool
legacy-supplier-entities-adapter-unified
finance-revenue-order-payment
wgcp-srs-unmatched-scan-handler
sales-product-api
pre-checks-kafka
gst-hackathon23-merchant-lens-iac
sf-devcon
serveng-service-eng-order-access-gql-federation


