#postgresql #migration #sql #alter #ast #schema #diff

bin+lib declare_schema

CLI / Library for Postgres schema migrations

4 releases

0.0.4 Aug 3, 2024
0.0.3 Aug 3, 2024
0.0.2 Aug 3, 2024
0.0.1 Jul 9, 2024

#1780 in Database interfaces

Download history 221/week @ 2024-07-07 87/week @ 2024-07-14 99/week @ 2024-07-21 184/week @ 2024-07-28 256/week @ 2024-08-04 194/week @ 2024-08-11 132/week @ 2024-08-18 47/week @ 2024-08-25 28/week @ 2024-09-01 30/week @ 2024-09-08

257 downloads per month

Apache-2.0

60KB
1.5K SLoC

declare-schema

Experiments with Rust declarative schemas

Use sqlparser-rs for SQL -> AST, then diff ASTs to generate ALTER ASTs, then output SQL.

WARNING: Alpha software, you will likely lose data with this library.

Goal

In application

Include database schema management in to Rust applications without the need for migration steps.

As a CLI

Provide a CLI tool that can generate diffs of schemas and the required ALTER statements for review to detect schema drift.

Easy development experience

When embedded in an application or with a CLI tool keep an easy SQL -> DB flow that is clear to developers with an easy to modify schema.

Current State

Limitations

CREATE EXTENSION - Can be created by name only. Cannot be DROPed.

Dependencies

~17–29MB
~468K SLoC