@@ -759,6 +759,126 @@ mod tests {
759759 DatabaseBackend :: Sqlite ,
760760 & [ "CREATE TABLE \" users\" ( \" id\" integer )" ]
761761 ) ]
762+ #[ case:: create_table_with_default_postgres(
763+ "create_table_with_default_postgres" ,
764+ MigrationAction :: CreateTable {
765+ table: "users" . into( ) ,
766+ columns: vec![ ColumnDef {
767+ name: "status" . into( ) ,
768+ r#type: ColumnType :: Simple ( SimpleColumnType :: Text ) ,
769+ nullable: true ,
770+ default : Some ( "'active'" . into( ) ) ,
771+ comment: None ,
772+ primary_key: None ,
773+ unique: None ,
774+ index: None ,
775+ foreign_key: None ,
776+ } ] ,
777+ constraints: vec![ ] ,
778+ } ,
779+ DatabaseBackend :: Postgres ,
780+ & [ "DEFAULT" , "'active'" ]
781+ ) ]
782+ #[ case:: create_table_with_default_mysql(
783+ "create_table_with_default_mysql" ,
784+ MigrationAction :: CreateTable {
785+ table: "users" . into( ) ,
786+ columns: vec![ ColumnDef {
787+ name: "status" . into( ) ,
788+ r#type: ColumnType :: Simple ( SimpleColumnType :: Text ) ,
789+ nullable: true ,
790+ default : Some ( "'active'" . into( ) ) ,
791+ comment: None ,
792+ primary_key: None ,
793+ unique: None ,
794+ index: None ,
795+ foreign_key: None ,
796+ } ] ,
797+ constraints: vec![ ] ,
798+ } ,
799+ DatabaseBackend :: MySql ,
800+ & [ "DEFAULT 'active'" ]
801+ ) ]
802+ #[ case:: create_table_with_default_sqlite(
803+ "create_table_with_default_sqlite" ,
804+ MigrationAction :: CreateTable {
805+ table: "users" . into( ) ,
806+ columns: vec![ ColumnDef {
807+ name: "status" . into( ) ,
808+ r#type: ColumnType :: Simple ( SimpleColumnType :: Text ) ,
809+ nullable: true ,
810+ default : Some ( "'active'" . into( ) ) ,
811+ comment: None ,
812+ primary_key: None ,
813+ unique: None ,
814+ index: None ,
815+ foreign_key: None ,
816+ } ] ,
817+ constraints: vec![ ] ,
818+ } ,
819+ DatabaseBackend :: Sqlite ,
820+ & [ "DEFAULT 'active'" ]
821+ ) ]
822+ #[ case:: create_table_with_inline_primary_key_postgres(
823+ "create_table_with_inline_primary_key_postgres" ,
824+ MigrationAction :: CreateTable {
825+ table: "users" . into( ) ,
826+ columns: vec![ ColumnDef {
827+ name: "id" . into( ) ,
828+ r#type: ColumnType :: Simple ( SimpleColumnType :: Integer ) ,
829+ nullable: false ,
830+ default : None ,
831+ comment: None ,
832+ primary_key: Some ( PrimaryKeySyntax :: Bool ( true ) ) ,
833+ unique: None ,
834+ index: None ,
835+ foreign_key: None ,
836+ } ] ,
837+ constraints: vec![ ] ,
838+ } ,
839+ DatabaseBackend :: Postgres ,
840+ & [ "PRIMARY KEY" ]
841+ ) ]
842+ #[ case:: create_table_with_inline_primary_key_mysql(
843+ "create_table_with_inline_primary_key_mysql" ,
844+ MigrationAction :: CreateTable {
845+ table: "users" . into( ) ,
846+ columns: vec![ ColumnDef {
847+ name: "id" . into( ) ,
848+ r#type: ColumnType :: Simple ( SimpleColumnType :: Integer ) ,
849+ nullable: false ,
850+ default : None ,
851+ comment: None ,
852+ primary_key: Some ( PrimaryKeySyntax :: Bool ( true ) ) ,
853+ unique: None ,
854+ index: None ,
855+ foreign_key: None ,
856+ } ] ,
857+ constraints: vec![ ] ,
858+ } ,
859+ DatabaseBackend :: MySql ,
860+ & [ "PRIMARY KEY" ]
861+ ) ]
862+ #[ case:: create_table_with_inline_primary_key_sqlite(
863+ "create_table_with_inline_primary_key_sqlite" ,
864+ MigrationAction :: CreateTable {
865+ table: "users" . into( ) ,
866+ columns: vec![ ColumnDef {
867+ name: "id" . into( ) ,
868+ r#type: ColumnType :: Simple ( SimpleColumnType :: Integer ) ,
869+ nullable: false ,
870+ default : None ,
871+ comment: None ,
872+ primary_key: Some ( PrimaryKeySyntax :: Bool ( true ) ) ,
873+ unique: None ,
874+ index: None ,
875+ foreign_key: None ,
876+ } ] ,
877+ constraints: vec![ ] ,
878+ } ,
879+ DatabaseBackend :: Sqlite ,
880+ & [ "PRIMARY KEY" ]
881+ ) ]
762882 #[ case:: create_table_with_inline_constraints_postgres(
763883 "create_table_with_inline_constraints_postgres" ,
764884 MigrationAction :: CreateTable {
0 commit comments