Skip to content

Atlas driver support for YDB#3682

Open
kprokopenko wants to merge 6 commits into
ariga:masterfrom
ydb-platform:ydb-develop
Open

Atlas driver support for YDB#3682
kprokopenko wants to merge 6 commits into
ariga:masterfrom
ydb-platform:ydb-develop

Conversation

@kprokopenko

Copy link
Copy Markdown

Hello there! @LostImagin4tion is currently working on adding support for YDB to ent. Atlas migration support for YDB is a prerequisite for completing the ent integration, as ent relies on Atlas for its schema migration engine.

This PR introduces Atlas driver support for YDB, including schema inspection, diffing, and migration planning/applying. The implementation follows the same patterns used by existing drivers (postgres, mysql, sqlite).

What's included

Core driver (sql/ydb/):

File Description
driver.go Atlas' driver implementation for YDB
types.go YDB type constants and custom schema types
inspect.go Schema inspection via native YDB Scheme and Table APIs. Inspects columns, primary keys, and secondary indexes
diff.go Schema diffing via sqlx.Diff with a YDB-specific DiffDriver. Handles table, column, and index changes. No foreign key support (YDB limitation)
migrate.go Migration planning and applying. Supports CREATE TABLE, DROP TABLE, RENAME TABLE, ADD/DROP COLUMN, ADD/DROP/RENAME INDEX. All plans are non-transactional
convert.go Bidirectional type conversion covering all YDB types
attributes.go IndexAttributes for YDB-specific index properties

YDB-specific design decisions

  • Database path as schema - YDB's database path (e.g. /local/dir1/table1) maps to Atlas's schema concept. Tables can live in subdirectories
  • ydb.Unwrap - using Unwrap() method to extract the native YDB driver from *sql.DB, which gives access to native Scheme and Table APIs for database inspection
  • Non-transactional DDL: YDB DDL is not transactional, so all migration plans set Transactional: false
  • No foreign keys: YDB does not support foreign keys; the differ explicitly skips FK-related logic

New Dependencies

  • github.com/ydb-platform/ydb-go-sdk/v3 v3.125.4
  • github.com/ydb-platform/ydb-go-genproto (indirect, for YDB protobuf types)

@a8m

a8m commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution, @kprokopenko. Unfortunately, we don't accept external contribution at this stage to Atlas drivers, as I wrote in the past here: #3057 (comment)

If the YDB team is interested in having this database supported in Atlas, we would be more than happy to partner with them. However, development and maintenance for these databases happen in a separate repository. If this is relevant, feel free to drop me a message on our Discord and we can take it from there. Cheers!

@LostImagin4tion

Copy link
Copy Markdown

If the YDB team is interested in having this database supported in Atlas, we would be more than happy to partner with them. However, development and maintenance for these databases happen in a separate repository. If this is relevant, feel free to drop me a message on our Discord and we can take it from there. Cheers!

Hello! Thank you for replying so quickly.
Do you plan to implement some kind of plugin system? In order to make adding new driver would be not so invasive

@LostImagin4tion LostImagin4tion force-pushed the ydb-develop branch 2 times, most recently from 0ec3773 to bf7848c Compare March 3, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants