pub struct PhinxTable { /* private fields */ }Expand description
Phinx 风格表构建器
提供链式 API 构建 CREATE TABLE / ALTER TABLE 语句
Implementations§
Source§impl PhinxTable
impl PhinxTable
Sourcepub fn add_column<F>(
self,
name: impl Into<String>,
col_type: ColumnType,
options_fn: F,
) -> Self
pub fn add_column<F>( self, name: impl Into<String>, col_type: ColumnType, options_fn: F, ) -> Self
Sourcepub fn add_foreign_key<F>(
self,
column: impl Into<String>,
referenced_table: impl Into<String>,
referenced_column: impl Into<String>,
options_fn: F,
) -> Self
pub fn add_foreign_key<F>( self, column: impl Into<String>, referenced_table: impl Into<String>, referenced_column: impl Into<String>, options_fn: F, ) -> Self
添加外键(Phinx addForeignKey 等价物)
Sourcepub fn set_primary_key(self, columns: Vec<String>) -> Self
pub fn set_primary_key(self, columns: Vec<String>) -> Self
设置主键(Phinx 风格,可复合主键)
Sourcepub fn if_not_exists(self) -> Self
pub fn if_not_exists(self) -> Self
设置 IF NOT EXISTS
Sourcepub fn create(&self, db_type: DbType) -> Result<String, DbError>
pub fn create(&self, db_type: DbType) -> Result<String, DbError>
生成 CREATE TABLE SQL(Phinx create() 等价物)
Sourcepub fn add_columns_sql(&self, db_type: DbType) -> String
pub fn add_columns_sql(&self, db_type: DbType) -> String
生成 ALTER TABLE 添加列 SQL(Phinx change() 等价物的一部分)
Sourcepub fn drop_column_sql(&self, column: &str) -> String
pub fn drop_column_sql(&self, column: &str) -> String
生成 DROP COLUMN SQL(Phinx removeColumn 等价物)
Sourcepub fn rename_column_sql(&self, old_name: &str, new_name: &str) -> String
pub fn rename_column_sql(&self, old_name: &str, new_name: &str) -> String
生成 RENAME COLUMN SQL(Phinx renameColumn 等价物)
Sourcepub fn change_column_sql(
&self,
column: &str,
new_type: ColumnType,
db_type: DbType,
) -> String
pub fn change_column_sql( &self, column: &str, new_type: ColumnType, db_type: DbType, ) -> String
生成 CHANGE COLUMN SQL(Phinx changeColumn 等价物)
Sourcepub fn truncate_sql(&self) -> String
pub fn truncate_sql(&self) -> String
生成 TRUNCATE SQL(Phinx truncate() 等价物)
Auto Trait Implementations§
impl Freeze for PhinxTable
impl RefUnwindSafe for PhinxTable
impl Send for PhinxTable
impl Sync for PhinxTable
impl Unpin for PhinxTable
impl UnsafeUnpin for PhinxTable
impl UnwindSafe for PhinxTable
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