1- use sea_orm_migration:: { prelude:: * , schema :: * } ;
1+ use sea_orm_migration:: { prelude:: * } ;
22
33#[ derive( DeriveMigrationName ) ]
44pub struct Migration ;
@@ -8,8 +8,26 @@ impl MigrationTrait for Migration {
88 async fn up ( & self , manager : & SchemaManager ) -> Result < ( ) , DbErr > {
99 let statement = Query :: insert ( )
1010 . into_table ( "topics" )
11- . columns ( [ "id" , "title" , "description" ] )
12- . values_panic ( [ 0 . into ( ) , "memes" . into ( ) , "this is where the memes are" . into ( ) ] )
11+ . columns ( [ "title" , "description" , "id" ] )
12+ . values_panic ( [ "memes" . into ( ) , "this is where the memes are" . into ( ) , 0 . into ( ) ] )
13+ . to_owned ( ) ;
14+
15+ manager. exec_stmt ( statement) . await ?;
16+
17+
18+ let statement = Query :: insert ( )
19+ . into_table ( "topics" )
20+ . columns ( [ "title" , "description" , "id" ] )
21+ . values_panic ( [ "sad" . into ( ) , "this is where the sad are" . into ( ) , 1 . into ( ) ] )
22+ . to_owned ( ) ;
23+
24+ manager. exec_stmt ( statement) . await ?;
25+
26+
27+ let statement = Query :: insert ( )
28+ . into_table ( "topics" )
29+ . columns ( [ "title" , "description" , "id" ] )
30+ . values_panic ( [ "ponies" . into ( ) , "this is where the pony are" . into ( ) , 2 . into ( ) ] )
1331 . to_owned ( ) ;
1432
1533 manager. exec_stmt ( statement) . await ?;
@@ -19,6 +37,8 @@ impl MigrationTrait for Migration {
1937
2038 async fn down ( & self , manager : & SchemaManager ) -> Result < ( ) , DbErr > {
2139 let statement = Query :: delete ( ) . from_table ( "topics" ) . cond_where ( Cond :: any ( ) . add ( Expr :: col ( "id" ) . eq ( 0 ) ) ) . to_owned ( ) ;
40+ let statement = Query :: delete ( ) . from_table ( "topics" ) . cond_where ( Cond :: any ( ) . add ( Expr :: col ( "id" ) . eq ( 1 ) ) ) . to_owned ( ) ;
41+ let statement = Query :: delete ( ) . from_table ( "topics" ) . cond_where ( Cond :: any ( ) . add ( Expr :: col ( "id" ) . eq ( 2 ) ) ) . to_owned ( ) ;
2242
2343 manager. exec_stmt ( statement) . await ?;
2444
0 commit comments