Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

update backend scripts

appflowye1ed027b9cd6
diff --git a/backend/scripts/Makefile b/backend/scripts/Makefile
index 40d616d2c3..1e44f51383 100644
--- a/backend/scripts/Makefile
+++ b/backend/scripts/Makefile
@@ -1,11 +1,10 @@
-.EXPORT_ALL_VARIABLES:
-export DB_USER=postgres
-export DB_PASSWORD=password
-export DB_NAME=flowy
-export DB_PORT=5433
-export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}
-export ROOT = "./scripts/database"
-export DB_HOST = "localhost"
+#.EXPORT_ALL_VARIABLES:
+#export DB_USER=postgres
+#export DB_PASSWORD=password
+#export DB_NAME=flowy
+#export DB_PORT=5433
+#export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}
+#export DB_HOST = "localhost"
init_database:
${ROOT}/init_database.sh
diff --git a/backend/scripts/init_database.sh b/backend/scripts/init_database.sh
index 06ac0c8878..d1ed0f10f0 100755
--- a/backend/scripts/init_database.sh
+++ b/backend/scripts/init_database.sh
@@ -13,11 +13,17 @@ fi
if ! [ -x "$(command -v sqlx)" ]; then
echo >&2 "Error: `sqlx` is not installed."
echo >&2 "Use:"
- echo >&2 " cargo install --version=^0.5.6 sqlx-cli --no-default-features --features postgres"
+ echo >&2 " cargo install --version=^0.5.7 sqlx-cli --no-default-features --features postgres"
echo >&2 "to install it."
exit 1
fi
+DB_USER="${POSTGRES_USER:=postgres}"
+DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
+DB_PORT="${POSTGRES_PORT:=5433}"
+DB_HOST="${POSTGRES_HOST:=localhost}"
+DB_NAME="${POSTGRES_DB:=flowy}"
+
if [[ -z "${SKIP_DOCKER}" ]]
then
RUNNING_POSTGRES_CONTAINER=$(docker ps --filter 'name=postgres' --format '{{.ID}}')
@@ -28,12 +34,12 @@ then
fi
docker run \
- --name="flowy" \
-e POSTGRES_USER=${DB_USER} \
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
- -e POSTGRES_DB=${DB_NAME} \
+ -e POSTGRES_DB="${DB_NAME}" \
-p "${DB_PORT}":5432 \
-d postgres \
+ --name "postgres_$(date '+%s')" \
postgres -N 1000
fi