Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dynamic Exposure
Global Dynamic Exposure
database-gdetiles
Commits
7e6872e0
Commit
7e6872e0
authored
Oct 25, 2021
by
Felix Delattre
Browse files
Removed run-migrations script and shell linters
parent
79ba75a7
Changes
3
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
7e6872e0
image
:
debian:bookworm-slim
before_script
:
-
apt update -y
-
apt install -y git make shellcheck golang-go postgresql -y -qq
-
export GOPATH="$HOME/go"
-
export PATH="$PATH:$GOPATH/bin"
-
go get -u mvdan.cc/sh/v3/cmd/shfmt
linters
:
script
:
-
make check
test
:
services
:
-
name
:
$CI_REGISTRY/dynamicexposure/server-components/containers/docker-obm-database:master
...
...
Makefile
deleted
100644 → 0
View file @
79ba75a7
SOURCES
=
./run-migrations.sh
check
:
$(SOURCES)
shellcheck
--external-sources
$^
shfmt
-i
2
-d
$^
format
:
$(SOURCES)
shfmt
-i
2
-w
$^
run-migrations.sh
deleted
100755 → 0
View file @
79ba75a7
#!/bin/bash
#
# Deletes current `gde_tiles` database and sets it up anew by running
# all SQL scripts in the migrations folder in ascending order.
# Run: script_name [db_user]
# May provide the database user as an argument (default: postgres).
# Copyright (C) 2021:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program 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 Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
sql_scripts_dir
=
'migrations'
db_name
=
'gde_tiles'
db_user
=
'postgres'
# Test for argument from the command line (now only one argument: database user)
if
[[
-z
${
1
+x
}
]]
;
then
# First parameter is the database user
printf
'Running %s with default database user %s\n'
"
$(
basename
"
$0
"
)
"
"
${
db_user
}
"
else
db_user
=
${
1
}
printf
'Running %s with database user %s\n'
"
$(
basename
"
$0
"
)
"
"
${
db_user
}
"
fi
# Delete current `gde_tiles` database if exists and create anew
if
psql
-lqt
|
cut
-d
\|
-f
1 |
grep
-qw
${
db_name
}
;
then
# Database exists
printf
'Database %s exists, deleting.\n'
${
db_name
}
dropdb
${
db_name
}
printf
'Creating %s\n'
${
db_name
}
createdb
${
db_name
}
else
createdb
${
db_name
}
fi
# Run the SQL scripts in the migrations folder in ascending order
for
file
in
"
${
sql_scripts_dir
}
"
/
*
.sql
;
do
f_base
=
$(
basename
"
${
file
}
"
.sql
)
printf
'Running script %s\n'
"
${
f_base
}
"
psql
--username
"
${
db_user
}
"
\
--dbname
"
${
db_name
}
"
\
--echo-all
--file
"
${
file
}
"
done
printf
'Done.\n'
exit
0
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment