mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-01 13:51:10 +00:00
stuff
This commit is contained in:
parent
70530a8ad2
commit
4fe1dd9af4
5 changed files with 28 additions and 15 deletions
|
@ -96,16 +96,18 @@ impl LocalUserLanguage {
|
|||
.execute(conn)
|
||||
.await?;
|
||||
|
||||
for l in lang_ids {
|
||||
let form = LocalUserLanguageForm {
|
||||
let forms = lang_ids
|
||||
.into_iter()
|
||||
.map(|l| LocalUserLanguageForm {
|
||||
local_user_id: for_local_user_id,
|
||||
language_id: l,
|
||||
};
|
||||
insert_into(local_user_language)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await?;
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
insert_into(local_user_language)
|
||||
.values(forms)
|
||||
.execute(conn)
|
||||
.await?;
|
||||
Ok(())
|
||||
}) as _
|
||||
})
|
||||
|
|
|
@ -15,9 +15,11 @@ use diesel::{
|
|||
pg::Pg,
|
||||
result::{ConnectionError, ConnectionResult, Error as DieselError, Error::QueryBuilderError},
|
||||
serialize::{Output, ToSql},
|
||||
sql_query,
|
||||
sql_types::{Text, Timestamptz},
|
||||
IntoSql,
|
||||
PgConnection,
|
||||
RunQueryDsl,
|
||||
};
|
||||
use diesel_async::{
|
||||
pg::AsyncPgConnection,
|
||||
|
@ -280,6 +282,12 @@ fn run_migrations(db_url: &str) {
|
|||
// Needs to be a sync connection
|
||||
let mut conn =
|
||||
PgConnection::establish(db_url).unwrap_or_else(|e| panic!("Error connecting to {db_url}: {e}"));
|
||||
|
||||
// Disable auto_explain output for migrations
|
||||
sql_query("SET auto_explain.log_min_duration = -1")
|
||||
.execute(&mut conn)
|
||||
.expect("failed to disable auto_explain");
|
||||
|
||||
info!("Running Database migrations (This may take a long time)...");
|
||||
let _ = &mut conn
|
||||
.run_pending_migrations(MIGRATIONS)
|
||||
|
|
|
@ -1433,7 +1433,7 @@ mod tests {
|
|||
let inserted_community = Community::create(pool, &community_form).await.unwrap();
|
||||
|
||||
let mut inserted_post_ids = vec![];
|
||||
let mut inserted_comment_ids = vec![];
|
||||
let mut comment_forms = vec![];
|
||||
|
||||
// Create 150 posts with varying non-correlating values for publish date, number of comments, and featured
|
||||
for comments in 0..10 {
|
||||
|
|
|
@ -5,11 +5,15 @@ export PGHOST=$PWD
|
|||
export LEMMY_DATABASE_URL="postgresql://lemmy:password@/lemmy?host=$PWD"
|
||||
|
||||
# If cluster exists, stop the server and delete the cluster
|
||||
if [ -d $PGDATA ]
|
||||
if [[ -d $PGDATA ]]
|
||||
then
|
||||
# Prevent `stop` from failing if server already stopped
|
||||
pg_ctl restart > /dev/null
|
||||
pg_ctl stop
|
||||
# Only stop server if it is running
|
||||
(pg_ctl status > /dev/null) || pg_status_exit_code=$?
|
||||
if [[ ${pg_status_exit_code} -ne 3 ]]
|
||||
then
|
||||
pg_ctl stop
|
||||
fi
|
||||
|
||||
rm -rf $PGDATA
|
||||
fi
|
||||
|
||||
|
@ -17,7 +21,7 @@ fi
|
|||
initdb --username=postgres --auth=trust --no-instructions
|
||||
|
||||
# Start server that only listens to socket in current directory
|
||||
pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$PWD" > /dev/null
|
||||
pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$PWD -c logging_collector=on -c session_preload_libraries=auto_explain -c auto_explain.log_min_duration=0 -c auto_explain.log_parameter_max_length=0 -c auto_explain.log_analyze=on -c enable_seqscan=off" > /dev/null
|
||||
|
||||
# Setup database
|
||||
psql -c "CREATE USER lemmy WITH PASSWORD 'password' SUPERUSER;" -U postgres
|
||||
|
|
|
@ -28,4 +28,3 @@ cargo test -p lemmy_utils --all-features --no-fail-fast
|
|||
# Add this to do printlns: -- --nocapture
|
||||
|
||||
pg_ctl stop
|
||||
rm -rf $PGDATA
|
||||
|
|
Loading…
Reference in a new issue