From 94249d2c72f981fbdd84b2e8bd5f3e9072a41f32 Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 6 May 2021 00:08:56 +0200 Subject: [PATCH] Import database creation script the first time --- mysql.nix | 4 +++- postgresql.nix | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mysql.nix b/mysql.nix index 1a49154..dd1a266 100644 --- a/mysql.nix +++ b/mysql.nix @@ -21,7 +21,9 @@ in mkShell { mysqld --datadir="${data_dir}" --socket="${socket}" --skip-networking --skip-mysqlx & sleep 1 - mysql --socket="${socket}" -u root < ${sql_file} + if [ ! -d ${data_dir} ]; then + mysql --socket="${socket}" -u root < ${sql_file} + fi alias mysql='mysql --socket="${socket}" -u root' alias nuke='rm -rf ${data_dir}' diff --git a/postgresql.nix b/postgresql.nix index aec4a61..02bbed1 100644 --- a/postgresql.nix +++ b/postgresql.nix @@ -22,7 +22,10 @@ in mkShell { pg_ctl start -o "--unix_socket_directories=${data_dir} --listen_addresses='''" fi - psql -d postgres -f ${sql_file} + if [ ! -d ${data_dir} ]; then + psql -d postgres -f ${sql_file} + fi + alias psql='psql -d postgres' alias nuke='rm -rf ${data_dir}' '';