Browse Source

Add script for preparing the DB for convenience

no-contract-setup-message
Daniel Karzel 3 years ago
parent
commit
1b792751cb
No known key found for this signature in database GPG Key ID: 30C3FC2E438ADB6E
  1. 18
      daemon/prepare_db.sh

18
daemon/prepare_db.sh

@ -0,0 +1,18 @@
#!/bin/bash
DAEMON_DIR=daemon
TEMPDB=tempdb
# make sure to fail early in case something goes wrong
set -e
# create temporary DB
DATABASE_URL=sqlite:$TEMPDB cargo sqlx database create
# make sure we remove the tempdb when exiting even if one of the following commands fails
trap 'rm -f $TEMPDB' EXIT
# run the migration scripts to create the tables
DATABASE_URL=sqlite:$TEMPDB cargo sqlx migrate run
# prepare the sqlx-data.json rust mappings
DATABASE_URL=sqlite:./$DAEMON_DIR/$TEMPDB cargo sqlx prepare -- --bin taker
Loading…
Cancel
Save