Compare commits
No commits in common. "9bfe92f0d695d017c77593ac87475cedb15e99f2" and "bba7266adcffd5b77558b3986b1be4d7fdd69ab4" have entirely different histories.
9bfe92f0d6
...
bba7266adc
2 changed files with 1 additions and 77 deletions
|
@ -1,44 +0,0 @@
|
||||||
{
|
|
||||||
"db_name": "PostgreSQL",
|
|
||||||
"query": "SELECT * FROM users",
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"ordinal": 0,
|
|
||||||
"name": "id",
|
|
||||||
"type_info": "Int8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 1,
|
|
||||||
"name": "username",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 2,
|
|
||||||
"name": "password",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 3,
|
|
||||||
"name": "created_at",
|
|
||||||
"type_info": "Timestamp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 4,
|
|
||||||
"name": "updated_at",
|
|
||||||
"type_info": "Timestamp"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": []
|
|
||||||
},
|
|
||||||
"nullable": [
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"hash": "26e7e05427bc7dabcd7815d27764fda2baf4cfe60a2d2d6ee2a1f773dccbbce2"
|
|
||||||
}
|
|
|
@ -50,14 +50,10 @@ impl ServerState {
|
||||||
Some(u) => info!("Created default user {}", u.username),
|
Some(u) => info!("Created default user {}", u.username),
|
||||||
None => error!("Failed to create default user..."),
|
None => error!("Failed to create default user..."),
|
||||||
}
|
}
|
||||||
match crate::db::db_new_user("demouser".to_string(), "demopw".to_string(), &pool).await {
|
|
||||||
Some(u) => info!("Created default user {}", u.username),
|
|
||||||
None => error!("Failed to create default user..."),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
debug_setup(&pool).await.unwrap();
|
debug_setup(&pool).await.unwrap();
|
||||||
lipsum_setup(&pool).await.unwrap();
|
|
||||||
Self { pool }
|
Self { pool }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,31 +98,3 @@ async fn debug_setup(pool: &PgPool) -> Result<(), sqlx::Error> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn lipsum_setup(pool: &PgPool) -> Result<(), sqlx::Error> {
|
|
||||||
use lipsum::lipsum;
|
|
||||||
use rand::prelude::*;
|
|
||||||
use sqlx::query;
|
|
||||||
|
|
||||||
let user_exist = query!("SELECT * FROM users",)
|
|
||||||
.fetch_one(pool)
|
|
||||||
.await
|
|
||||||
.ok()
|
|
||||||
.is_none();
|
|
||||||
|
|
||||||
if user_exist {
|
|
||||||
let mut rng = rand::thread_rng();
|
|
||||||
|
|
||||||
// This requires that the user with id 1 exists in the user table
|
|
||||||
for _ in 0..100 {
|
|
||||||
query!(
|
|
||||||
"INSERT INTO posts (user_id, content) VALUES (1, $1)",
|
|
||||||
lipsum(rng.gen_range(10..100))
|
|
||||||
)
|
|
||||||
.execute(pool)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue