Skip to content

Commit 107728f

Browse files
authored
Merge pull request #46 from adlnet/trialMysql
Deployment tenant auto-creation
2 parents 57f7e95 + 95f7147 commit 107728f

File tree

6 files changed

+18
-31
lines changed

6 files changed

+18
-31
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ player/.env
44
cts/.env
55
cts/var
66
lts/pkg/dist
7+
.DS_Store
8+
.idea

cts/Dockerfile

100644100755
File mode changed.

cts/docker-compose.client-dev.yml

100644100755
File mode changed.

player/docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ services:
3838
- DATABASE_USER=catapult
3939
- DATABASE_USER_PASSWORD=quartz
4040
- DATABASE_NAME=catapult_player
41+
- FIRST_TENANT_NAME
4142
rdbms:
42-
image: mysql:8.0.17
43+
image: mysql:8.0.31
4344
volumes:
4445
- catapult-player-data:/var/lib/mysql
45-
- ./init_db.sh:/docker-entrypoint-initdb.d/init_db.sh:ro
4646
environment:
4747
- MYSQL_RANDOM_ROOT_PASSWORD=yes
48-
- DATABASE_USER=catapult
49-
- DATABASE_USER_PASSWORD=quartz
50-
- DATABASE_NAME=catapult_player
48+
- MYSQL_USER=catapult
49+
- MYSQL_PASSWORD=quartz
50+
- MYSQL_DATABASE=catapult_player
5151
command: [
5252
"mysqld",
5353

player/init_db.sh

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

player/migrations/010-table-tenants.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
limitations under the License.
1515
*/
1616
const tableName = "tenants";
17+
const defaultTenantName = process.env.FIRST_TENANT_NAME;
1718

1819
exports.up = async (knex) => {
1920
await knex.schema.createTable(
@@ -25,5 +26,15 @@ exports.up = async (knex) => {
2526
table.string("code").notNullable().unique();
2627
}
2728
);
29+
//Check to see if there is a value in First_tenant_name
30+
if(defaultTenantName){
31+
//On creating new database, create new tenant, will automatically be '1'
32+
await knex(tableName).insert({code: defaultTenantName})
33+
.then( function (result) {
34+
console.log("First tenant created named " + defaultTenantName) });// respond back to request
35+
}
36+
else{
37+
console.log("There is no specified default tenant name. No default tenant created.")
38+
}
2839
};
2940
exports.down = (knex) => knex.schema.dropTable(tableName);

0 commit comments

Comments
 (0)