Use create_post_table instead of SQL
This commit is contained in:
parent
f191645467
commit
380f2a0c04
@ -82,23 +82,10 @@ async fn destroy(conn: Connection<Db>) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn run_migrations(rocket: Rocket<Build>) -> fairing::Result {
|
async fn run_migrations(rocket: Rocket<Build>) -> fairing::Result {
|
||||||
let con = sea_orm::Database::connect("mysql://root:@localhost/rocket_example")
|
let conn = sea_orm::Database::connect("mysql://root:@localhost/rocket_example")
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let create_post_table = con
|
let create_post_table = setup::create_post_table(&conn);
|
||||||
.execute(Statement::from_string(
|
|
||||||
DatabaseBackend::MySql,
|
|
||||||
r#"
|
|
||||||
CREATE TABLE posts (
|
|
||||||
id int NOT NULL AUTO_INCREMENT,
|
|
||||||
title VARCHAR(255) NOT NULL,
|
|
||||||
text VARCHAR(255) NOT NULL,
|
|
||||||
PRIMARY KEY (id)
|
|
||||||
)"#
|
|
||||||
.to_owned(),
|
|
||||||
))
|
|
||||||
.await;
|
|
||||||
println!("create_post_table: {:#?}", create_post_table);
|
|
||||||
Ok(rocket)
|
Ok(rocket)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user