schema-migration-generator 0.7.1

A set of tools to manage relational database schemas
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use schema_sql_generator::common::constraint_naming::hashed_constraint_name;

const DF_PREFIX: &str = "df_";

/// The `df_<table>_<column>_<hash>` name the full `CREATE TABLE` generator would give this
/// column's default constraint (see `DefaultConstraintNaming::NamedWithHash` in
/// `schema-sql-generator`'s `DefaultColumnGenerator`) - kept in sync so a migration-generated
/// constraint matches what a fresh install would produce, and so `DropColumn` can target it by
/// a computed name rather than inspecting the live database.
pub fn constraint_name(table_name: &str, column_name: &str) -> String {
    hashed_constraint_name(DF_PREFIX, table_name, column_name)
}