pub struct PrimaryKey {
pub schema: Cow<'static, str>,
pub table: Cow<'static, str>,
pub name: Cow<'static, str>,
pub name_explicit: bool,
pub columns: Cow<'static, [Cow<'static, str>]>,
}Expand description
A primary key, as stored in migration snapshots.
Fields§
§schema: Cow<'static, str>Schema name
table: Cow<'static, str>Parent table name
name: Cow<'static, str>Constraint name
name_explicit: boolWhether the constraint name was explicitly specified
columns: Cow<'static, [Cow<'static, str>]>Columns in the primary key
Implementations§
Source§impl PrimaryKey
impl PrimaryKey
Sourcepub fn new(
schema: impl Into<Cow<'static, str>>,
table: impl Into<Cow<'static, str>>,
name: impl Into<Cow<'static, str>>,
columns: impl Into<Cow<'static, [Cow<'static, str>]>>,
) -> Self
pub fn new( schema: impl Into<Cow<'static, str>>, table: impl Into<Cow<'static, str>>, name: impl Into<Cow<'static, str>>, columns: impl Into<Cow<'static, [Cow<'static, str>]>>, ) -> Self
Creates a primary key.
Sourcepub fn from_strings(
schema: String,
table: String,
name: String,
columns: Vec<String>,
) -> Self
pub fn from_strings( schema: String, table: String, name: String, columns: Vec<String>, ) -> Self
Creates a primary key from owned strings.
Sourcepub const fn explicit_name(self) -> Self
pub const fn explicit_name(self) -> Self
Mark the name as explicitly specified
Source§impl PrimaryKey
impl PrimaryKey
Sourcepub fn to_constraint_sql(&self) -> String
pub fn to_constraint_sql(&self) -> String
Renders CONSTRAINT name PRIMARY KEY(...).
Sourcepub fn add_pk_sql(&self) -> String
pub fn add_pk_sql(&self) -> String
Renders ALTER TABLE ... ADD CONSTRAINT ... PRIMARY KEY(...);.
Sourcepub fn drop_pk_sql(&self) -> String
pub fn drop_pk_sql(&self) -> String
Renders ALTER TABLE ... DROP CONSTRAINT ...;.
Trait Implementations§
Source§impl Clone for PrimaryKey
impl Clone for PrimaryKey
Source§impl Debug for PrimaryKey
impl Debug for PrimaryKey
Source§impl Default for PrimaryKey
impl Default for PrimaryKey
impl Eq for PrimaryKey
Source§impl From<PrimaryKeyDef> for PrimaryKey
impl From<PrimaryKeyDef> for PrimaryKey
Source§fn from(def: PrimaryKeyDef) -> Self
fn from(def: PrimaryKeyDef) -> Self
Converts to this type from the input type.
Source§impl PartialEq for PrimaryKey
impl PartialEq for PrimaryKey
impl StructuralPartialEq for PrimaryKey
Auto Trait Implementations§
impl Freeze for PrimaryKey
impl RefUnwindSafe for PrimaryKey
impl Send for PrimaryKey
impl Sync for PrimaryKey
impl Unpin for PrimaryKey
impl UnsafeUnpin for PrimaryKey
impl UnwindSafe for PrimaryKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more