forked from MostroP2P/mostro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_db.sh
More file actions
executable file
·33 lines (31 loc) · 811 Bytes
/
init_db.sh
File metadata and controls
executable file
·33 lines (31 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
echo "Clean project"
if ls sqlx-data.json 1> /dev/null 2>&1; then
echo "Deleting old sqlx-data.json"
rm ./sqlx-data.json
fi
echo "Reading database URL from settings.toml..."
DATABASE_URL=$(awk -F'"' '/url *= */ {print $2}' settings.tpl.toml)
export DATABASE_URL
echo "Database URL is: $DATABASE_URL"
if ls mostro.db* 1> /dev/null 2>&1; then
echo "Deleting old database files..."
rm mostro.db*
else
echo "No old database files found."
fi
echo "Creating new database..."
sqlx database create
echo "Running migrations..."
sqlx migrate run
echo "Preparing offline file for CI on github!"
cargo sqlx prepare
echo "Check json db file is ok!"
if cargo sqlx prepare --check
then
echo "Success: sqlx-json is correct"
exit 0
else
echo "Failure: sqlx-json has issues" >&2
exit 1
fi