You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns the DDL needed to recreate the collection's table and metadata index, suitable for pasting into Alembic / sqitch / raw migration files. Sample output for create_collection(name="docs", dimension=3):
create extension if not exists vector;
createschemaif not exists vecs;
CREATETABLEIF NOT EXISTS vecs.docs (
id VARCHARNOT NULL,
vec VECTOR(3) NOT NULL,
metadata JSONB DEFAULT '{}'::jsonb NOT NULL,
PRIMARY KEY (id)
);
createindexif not exists ix_meta_docs
on vecs."docs" using gin (metadata jsonb_path_ops);
Two design choices I'd like to confirm before I open a PR:
Index naming._create currently uses ix_meta_<uuid> for the metadata GIN index to avoid collisions. For a migration this needs to be deterministic, so I'd switch to ix_meta_<collection_name>. Sound right, or would you prefer the caller pass an explicit name?
Vector indexes excluded.create_index picks n_lists from the current row count and chooses HNSW vs IVFFlat from the live pgvector version, so I'd leave it out of export_migration. Users would still call collection.create_index() after data is loaded. Agree, or do you want a separate export_index_migration(method=..., n_lists=...)?
I have an implementation + tests ready locally; happy to push as soon as you ack the approach. PR will follow the Conventional Commits format (feat(collection): add export_migration for SQL DDL export) and link back to this issue.
Activity
TemaDeveloper commentedon Apr 20, 2026
Hi @olirice — happy to take this. Proposed API per the issue body:
Returns the DDL needed to recreate the collection's table and metadata index, suitable for pasting into Alembic / sqitch / raw migration files. Sample output for
create_collection(name="docs", dimension=3):Two design choices I'd like to confirm before I open a PR:
_createcurrently usesix_meta_<uuid>for the metadata GIN index to avoid collisions. For a migration this needs to be deterministic, so I'd switch toix_meta_<collection_name>. Sound right, or would you prefer the caller pass an explicit name?create_indexpicksn_listsfrom the current row count and chooses HNSW vs IVFFlat from the live pgvector version, so I'd leave it out ofexport_migration. Users would still callcollection.create_index()after data is loaded. Agree, or do you want a separateexport_index_migration(method=..., n_lists=...)?I have an implementation + tests ready locally; happy to push as soon as you ack the approach. PR will follow the Conventional Commits format (
feat(collection): add export_migration for SQL DDL export) and link back to this issue.