This commit is contained in:
parent
cbfcbdd046
commit
457edfa47c
4 changed files with 14913 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,3 +1,5 @@
|
||||||
_build
|
_build
|
||||||
data/secmod/*
|
data/secmod/*
|
||||||
!data/secmod/.gitkeep
|
!data/secmod/.gitkeep
|
||||||
|
|
||||||
|
dbinit_sql
|
||||||
|
|
|
||||||
38
dbinit_sql/drop.sql
Normal file
38
dbinit_sql/drop.sql
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
--
|
||||||
|
-- This file is part of TALER
|
||||||
|
-- Copyright (C) 2014--2022 Taler Systems SA
|
||||||
|
--
|
||||||
|
-- TALER is free software; you can redistribute it and/or modify it under the
|
||||||
|
-- terms of the GNU General Public License as published by the Free Software
|
||||||
|
-- Foundation; either version 3, or (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License along with
|
||||||
|
-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
--
|
||||||
|
|
||||||
|
-- Everything in one big transaction
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
WITH xpatches AS (
|
||||||
|
SELECT patch_name
|
||||||
|
FROM _v.patches
|
||||||
|
WHERE starts_with(patch_name,'exchange-')
|
||||||
|
)
|
||||||
|
SELECT _v.unregister_patch(xpatches.patch_name)
|
||||||
|
FROM xpatches;
|
||||||
|
|
||||||
|
WITH xpatches AS (
|
||||||
|
SELECT patch_name
|
||||||
|
FROM _v.patches
|
||||||
|
WHERE starts_with(patch_name,'auditor-triggers-')
|
||||||
|
)
|
||||||
|
SELECT _v.unregister_patch(xpatches.patch_name)
|
||||||
|
FROM xpatches;
|
||||||
|
|
||||||
|
DROP SCHEMA exchange CASCADE;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
14774
dbinit_sql/init.sql
Normal file
14774
dbinit_sql/init.sql
Normal file
File diff suppressed because it is too large
Load diff
99
tools/dbinit.sh
Executable file
99
tools/dbinit.sh
Executable file
|
|
@ -0,0 +1,99 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# TODO use specific commit
|
||||||
|
|
||||||
|
# usage:
|
||||||
|
# `create_database`
|
||||||
|
# create a `taler-exchange` database
|
||||||
|
# `fetch`
|
||||||
|
# fetch all *.sql and *.sql.in files from GNU Taler exchange repository (latest commit)
|
||||||
|
# `init`
|
||||||
|
# initialize taler-exchange database (create tables, ...)
|
||||||
|
# `taler-exchange` database must already be created
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
taler_repo_url="https://git-www.taler.net/exchange.git/"
|
||||||
|
|
||||||
|
tmp_dir="/tmp/taler_exchange"
|
||||||
|
out_dir="./dbinit_sql"
|
||||||
|
init_sql="${out_dir}/init.sql"
|
||||||
|
drop_sql="${out_dir}/drop.sql"
|
||||||
|
|
||||||
|
# psql parameter
|
||||||
|
host="localhost"
|
||||||
|
port=5432
|
||||||
|
username="mte"
|
||||||
|
dbname="taler-exchange"
|
||||||
|
|
||||||
|
fetch() {
|
||||||
|
git clone --depth 1 $taler_repo_url $tmp_dir
|
||||||
|
}
|
||||||
|
|
||||||
|
process() {
|
||||||
|
source_dir="${tmp_dir}/src/exchangedb"
|
||||||
|
sql_in_files=(
|
||||||
|
"procedures.sql"
|
||||||
|
"exchange-0002.sql"
|
||||||
|
"exchange-0003.sql"
|
||||||
|
"exchange-0004.sql"
|
||||||
|
)
|
||||||
|
for file in "${sql_in_files[@]}"; do
|
||||||
|
file_in="${source_dir}/${file}.in"
|
||||||
|
file_out="${source_dir}/${file}"
|
||||||
|
gcc -E -P -undef -I "$source_dir" - < "$file_in" \
|
||||||
|
2>/dev/null \
|
||||||
|
> "$file_out"
|
||||||
|
done
|
||||||
|
# order is important
|
||||||
|
files=(
|
||||||
|
"versioning.sql"
|
||||||
|
"exchange-0001.sql"
|
||||||
|
"exchange-0002.sql"
|
||||||
|
"exchange-0003.sql"
|
||||||
|
"exchange-0004.sql"
|
||||||
|
"exchange-0005.sql"
|
||||||
|
"procedures.sql"
|
||||||
|
)
|
||||||
|
mkdir -p "$out_dir"
|
||||||
|
cat "${source_dir}/drop.sql" > "$drop_sql"
|
||||||
|
echo "" > "$init_sql"
|
||||||
|
for file in "${files[@]}"; do
|
||||||
|
cat "${source_dir}/${file}" >> "$init_sql"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# ? "NOTICE: function xxx() does not exist, skipping"
|
||||||
|
init() {
|
||||||
|
psql --host=$host --port=$port --username=$username --password --dbname=$dbname --file=$init_sql
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_schema() {
|
||||||
|
psql --host=$host --port=$port --username=$username --password --dbname=$dbname --file=$drop_sql
|
||||||
|
}
|
||||||
|
|
||||||
|
create_database() {
|
||||||
|
createdb --host=$host --port=$port --username=$username --password $dbname
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_database() {
|
||||||
|
dropdb --host=$host --port=$port --username=$username --password $dbname
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
|
echo "no argument" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmd=$1
|
||||||
|
case "$cmd" in
|
||||||
|
fetch) fetch "$@"; exit 0;;
|
||||||
|
process) process "$@"; exit 0;;
|
||||||
|
init) init "$@"; exit 0;;
|
||||||
|
drop_schema) drop_schema "$@"; exit 0;;
|
||||||
|
create_database) create_database "$@"; exit 0;;
|
||||||
|
drop_database) drop_database "$@"; exit 0;;
|
||||||
|
*) echo "Unknown command: $cmd" >&2; exit 1;;
|
||||||
|
esac
|
||||||
Loading…
Add table
Add a link
Reference in a new issue