Expand description
Diff SQL and a Postgres server to execute migrations
Example
ⓘ
let pool = sqlx::PgPool::connect(env::var(key)?.as_str()).await?;
let target_schema = include_str!("schema.sql");
declare_schema::migrate_from_string(&target_schema, &pool).await?;
Diff SQL and a Postgres server to generate migration statements
Example
ⓘ
let pool = sqlx::PgPool::connect(env::var(key)?.as_str()).await?;
let target_schema = include_str!("schema.sql");
let steps = declare_schema::generate_migrations_from_string(&target_schema, &pool).await?;
for step in steps {
println!("{}", step)
}
Modules§
- altertable
- Diff’ing of ASTs and statement generation
- schema
- str parsing to generate sqlparser ASTs
- source_
postgres - Postgres Server reading to generate sqlparser ASTs
Enums§
- Migration
Error - The common error type for migration errors
Functions§
- generate_
migrations_ from_ string - Diff a str with a DB and return SQL changes required to get the DB to match
str
- migrate_
from_ string - Diff a str with a DB and apply changes required to get the DB to match
str