Skip to content

Commit 6ad4856

Browse files
committed
simplify running
1 parent 25dd72f commit 6ad4856

File tree

6 files changed

+21
-29
lines changed

6 files changed

+21
-29
lines changed

.github/workflows/openmis-module-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'DROP DATABASE IF EXISTS imis_1_4_2'
5555
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'CREATE DATABASE imis_1_4_2'
5656
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_1_4_2 -i 1.42/openIMIS_ONLINE.sql | grep . | uniq -c
57-
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_1_4_2 -i "new/output/fullMigrationScipt.sql" | grep . | uniq -c
57+
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_1_4_2 -i "new/output/fullMigrationScript.sql" | grep . | uniq -c
5858
env:
5959
SA_PASSWORD: GitHub999
6060
ACCEPT_EULA: Y
@@ -73,7 +73,7 @@ jobs:
7373
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'DROP DATABASE IF EXISTS imis_main'
7474
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'CREATE DATABASE imis_main'
7575
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_main -i "oldMain/output/fullDemoDatabase.sql" | grep . | uniq -cc
76-
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_main -i "new/output/fullMigrationScipt.sql" | grep . | uniq -c
76+
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_main -i "new/output/fullMigrationScript.sql" | grep . | uniq -c
7777
7878
7979
env:

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ENV SA_PASSWORD=IMISuserP@s
66
ENV DB_USER_PASSWORD=IMISuserP@s
77
ENV DB_NAME=IMIS
88
ENV DB_USER=IMISUser
9-
ENV INIT_MODE=empty
109
RUN mkdir -p /app
1110
COPY script/* /app/
1211
COPY sql /app/sql

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ git clone https://github.com/openimis/database_ms_sqlserver
2626

2727
* create a new database (i.e. openIMIS.X.Y.Z where X.Y.Z is the openIMIS database version)
2828

29-
* Execute the initial database creation script fullEmpytDatabase.sql or fullDemoDatabase.sql (see "creating SQL script" section on how to get them)
29+
* Execute the initial database creation script fullEmptyDatabase.sql or fullDemoDatabase.sql (see "creating SQL script" section on how to get them)
3030

3131
### Upgrading
3232

33-
In order to upgrade from the previous version of openIMIS database (see [Versioning](#versioning) section), execute the migration script (fullMigrationSript), see "creating SQL script" to get it
33+
In order to upgrade from the previous version of openIMIS database (see [Versioning](#versioning) section), execute the migration script (fullMigrationScript), see "creating SQL script" to get it
3434

3535
## Deployment
3636

@@ -43,7 +43,7 @@ Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c6
4343

4444
### Creating SQL script
4545

46-
SQL files for initialisaiton or update are created using bash script concatenate_files.sh or by downloading the sql-file zip from the latest release https://github.com/openimis/database_ms_sqlserver/releases/latest
46+
SQL files for initialisation or update are created using bash script concatenate_files.sh or by downloading the sql-file zip from the latest release https://github.com/openimis/database_ms_sqlserver/releases/latest
4747

4848
## openIMIS dockerized database
4949

@@ -56,13 +56,13 @@ Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c6
5656

5757
### ENV
5858

59-
- INIT_MODE if set to demo will init the database to demo (works only if not yet init)
59+
- DEMO_DATASET if set to true will init the database to demo (works only if not yet init) otherwise comment it out
6060
- SQL_SCRIPT_URL url to init scripts
6161
- **ACCEPT_EULA** must be set to Y to accept MS SQL EULA
6262
- SA_PASSWORD default: IMISuserP@s
63-
- DB_USER_PASSWORD defautl: IMISuserP@s
64-
- DB_NAMEdefautl: IMIS
65-
- DB_USER defautl: IMISUser
63+
- DB_USER_PASSWORD default: IMISuserP@s
64+
- DB_NAME default: IMIS
65+
- DB_USER default: IMISUser
6666

6767

6868
### gettingstarted
@@ -79,15 +79,15 @@ docker build \
7979
-t openimis-db
8080
```
8181

82-
optinnaly
82+
optional
8383
```
8484
--build-arg SQL_SCRIPT_URL=<url to the sql script to create the database> \
8585
--build-arg DB_USER_PASSWORD=StrongPassword
8686
--build-arg DB_USER=IMISUser
8787
--build-arg DB_NAME=IMIS
8888
```
8989
***Notes***:
90-
* by setting the ACCEPT_EULA=Y, you explicitely accept [Microsoft EULA](https://go.microsoft.com/fwlink/?linkid=857698) for the dockerized SQL Server 2017. Please ensure you read it and use the provided software according to the terms of that license.
90+
* by setting the ACCEPT_EULA=Y, you explicitly accept [Microsoft EULA](https://go.microsoft.com/fwlink/?linkid=857698) for the dockerized SQL Server 2017. Please ensure you read it and use the provided software according to the terms of that license.
9191
* choose a strong password (at least 8 chars,...)... or SQL Server will complain
9292

9393

@@ -97,13 +97,13 @@ To restore the backup inside the container:
9797

9898

9999
***Note:***
100-
the container will check if the database exist, if it doesnot it will take the latest demo release version and deploy it , SQL_SCRIPT_URL is per defautl set to "https://github.com/openimis/database_ms_sqlserver/releases/latest/download/sql-files.zip"
101-
to have data retention when container are recreated volums need to be configured as microsoft docs suggest
100+
The container will check if the database exist. If it does not, it will take the latest demo release version and deploy it, SQL_SCRIPT_URL is by default set to "https://github.com/openimis/database_ms_sqlserver/releases/latest/download/sql-files.zip"
101+
To ensure data retention when containers are recreated, volumes need to be configured as suggested in the Microsoft documentation.
102102
* <host directory>/data:/var/opt/mssql/data : database files
103103
* <host directory>/log:/var/opt/mssql/log : logs files
104104
* <host directory>/secrets:/var/opt/mssql/secrets : secrets
105105

106-
The database is writen within the container. If you want to keep your data between container execution, stop/start the container via `docker stop <CONTAINER ID>` / `docker start <CONTAINER ID>` (using `docker run ... ` recreates a new container from the image... thus without any data)
106+
The database is written within the container. If you want to keep your data between container execution, stop/start the container via `docker stop <CONTAINER ID>` / `docker start <CONTAINER ID>` (using `docker run ... ` recreates a new container from the image, thus without any data)
107107

108108

109109

concatenate_files.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

script/concatenate_files.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/bash
22

33
mkdir output
4-
cat sql/migrations/1_migration_latest.sql sql/stored_procedures/*.sql > output/fullMigrationScipt.sql
4+
cat sql/migrations/1_migration_latest.sql sql/stored_procedures/*.sql > output/fullMigrationScript.sql
55
cat sql/base/*.sql sql/stored_procedures/*.sql > output/fullEmptyDatabase.sql
6-
cat sql/base/*.sql sql/stored_procedures/*.sql sql/demo/*.sql> output/fullDemoDatabase.sql
6+
cat sql/base/*.sql sql/stored_procedures/*.sql sql/demo/*.sql > output/fullDemoDatabase.sql
7+
cat sql/demo/*.sql > output/DemoDataset.sql
78
cat sql/base/*.sql sql/stored_procedures/*.sql sql/offline/central.sql > output/fullOfflineCentralDatabase.sql
89
cat sql/base/*.sql sql/stored_procedures/*.sql sql/offline/hf.sql > output/fullOfflineHFDatabase.sql

script/run-initialization.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
sleep 60s
66

77

8-
# DATABSE initialisation
8+
# DATABASE initialisation
99

10-
echo "Database initialisaton"
11-
# if the table does not exsit it will create the table
10+
echo "Database initialisation"
11+
# if the table does not exist it will create the table
1212

1313
# get "1" if the database exist : tr get only the integer, cut only the first integer (the second is the number of row affected)
1414
data=$(/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "SELECT COUNT(*) FROM master.dbo.sysdatabases WHERE name = N'$DB_NAME'" | tr -dc '0-9'| cut -c1 )
@@ -22,7 +22,7 @@ if [ ${data} -eq "0" ]; then
2222
#/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "DROP DATABASE IF EXISTS $DB_NAME"
2323
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "CREATE DATABASE $DB_NAME"
2424

25-
if [ "$INIT_MODE" = "demo" ]; then
25+
if [ "$DEMO_DATASET" ]; then
2626
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -i output/fullDemoDatabase.sql -d $DB_NAME | grep . | uniq -c
2727
else
2828
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -i output/fullEmptyDatabase.sql -d $DB_NAME | grep . | uniq -c

0 commit comments

Comments
 (0)