pub struct ConstraintNames;
Implementations§
source§impl ConstraintNames
impl ConstraintNames
sourcepub fn primary_key_name(table_name: &str, connector: &dyn Connector) -> String
pub fn primary_key_name(table_name: &str, connector: &dyn Connector) -> String
Aligned with PG, to maximize the amount of times where we do not need to render names because they already align with our convention.
We always take the database names of entities. So if a model is remapped to a different name in the datamodel, the default name generation will still take the name of the table in the db as input. Same goes for fields / columns.
Postgres Naming conventions
Without column names {tablename}_{suffix} pkey for a Primary Key constraint
Including column names: {tablename}{columnname(s)}{suffix} column names are joined with an _ if there are multiple key for a Unique constraint idx for any other kind of index fkey for a Foreign key
additional for SQLServer: dflt for Default Constraint
not used for now: check for a Check constraint excl for an Exclusion constraint seq for sequences
pub fn unique_index_name( table_name: &str, column_names: &[&str], connector: &dyn Connector ) -> String
pub fn non_unique_index_name( table_name: &str, column_names: &[&str], connector: &dyn Connector ) -> String
pub fn default_name( table_name: &str, column_name: &str, connector: &dyn Connector ) -> String
sourcepub fn foreign_key_constraint_name(
table_name: &str,
column_names: &[&str],
connector: &dyn Connector
) -> String
pub fn foreign_key_constraint_name( table_name: &str, column_names: &[&str], connector: &dyn Connector ) -> String
Params:
- table_name: the name of the constrained/referencing table, not the referenced one.
- column names: the constrained column names