-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from AbsaOSS/wallet/mysql
Wallet/mysql
- Loading branch information
Showing
70 changed files
with
7,461 additions
and
2,174 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '3.5' | ||
|
||
services: | ||
mysql: | ||
container_name: mysql | ||
image: mysql:5.7.35 | ||
environment: | ||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-mysecretpassword} | ||
networks: | ||
- absadocker | ||
ports: | ||
- "3306:3306" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"dev": { | ||
"driver": "mysql", | ||
"multipleStatements": true, | ||
"user": { "ENV": "MYSQL_USER" }, | ||
"password": { "ENV": "MYSQL_PASSWORD" }, | ||
"host": { "ENV": "MYSQL_HOST" }, | ||
"port": { "ENV": "MYSQL_PORT" }, | ||
"database": { "ENV": "MYSQL_DATABASE" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export MYSQL_USER=root | ||
export MYSQL_PASSWORD=mysecretpassword | ||
export MYSQL_HOST=localhost | ||
export MYSQL_PORT=3306 | ||
|
||
MYSQL_DATABASE=agency_wallets npm run schema:migrate:wallet | ||
MYSQL_DATABASE=agency_store npm run schema:migrate:app |
53 changes: 53 additions & 0 deletions
53
dbutils/migrations_scheme_application/20210914135739-create-tables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function(options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20210914135739-create-tables-up.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20210914135739-create-tables-down.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
"version": 1 | ||
}; |
53 changes: 53 additions & 0 deletions
53
dbutils/migrations_scheme_application/20210914135810-create-indices.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function(options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20210914135810-create-indices-up.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20210914135810-create-indices-down.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
"version": 1 | ||
}; |
1 change: 1 addition & 0 deletions
1
dbutils/migrations_scheme_application/sqls/20210914135739-create-tables-down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Replace with your SQL commands */ |
29 changes: 29 additions & 0 deletions
29
dbutils/migrations_scheme_application/sqls/20210914135739-create-tables-up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CREATE TABLE entities ( | ||
id SERIAL PRIMARY KEY, | ||
entity_did VARCHAR (50), | ||
entity_verkey VARCHAR (50), | ||
entity_record json NOT NULL, | ||
UNIQUE(entity_did), | ||
UNIQUE(entity_verkey) | ||
); | ||
|
||
CREATE TABLE messages ( | ||
id SERIAL PRIMARY KEY, | ||
agent_did VARCHAR (50), | ||
agent_connection_did VARCHAR (50), | ||
uid VARCHAR (50), | ||
status_code VARCHAR (50), | ||
payload BLOB | ||
); | ||
|
||
CREATE TABLE agents ( | ||
agent_did VARCHAR (50) PRIMARY KEY, | ||
webhook_url VARCHAR (512), | ||
has_new_message BOOL | ||
); | ||
|
||
CREATE TABLE agent_connections ( | ||
agent_connection_did VARCHAR (50) PRIMARY KEY, | ||
user_pw_did VARCHAR (50), | ||
agent_did VARCHAR (50) | ||
); |
1 change: 1 addition & 0 deletions
1
dbutils/migrations_scheme_application/sqls/20210914135810-create-indices-down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Replace with your SQL commands */ |
2 changes: 2 additions & 0 deletions
2
dbutils/migrations_scheme_application/sqls/20210914135810-create-indices-up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CREATE INDEX messages_agent_did ON messages (agent_did); | ||
CREATE INDEX messages_agent_did_agent_conn_did ON messages (agent_did, agent_connection_did); |
53 changes: 53 additions & 0 deletions
53
dbutils/migrations_scheme_wallets/20210910105243-create-all-initial.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function(options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20210910105243-create-all-initial-up.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20210910105243-create-all-initial-down.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
"version": 1 | ||
}; |
1 change: 1 addition & 0 deletions
1
dbutils/migrations_scheme_wallets/sqls/20210910105243-create-all-initial-down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Replace with your SQL commands */ |
15 changes: 15 additions & 0 deletions
15
dbutils/migrations_scheme_wallets/sqls/20210910105243-create-all-initial-up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE TABLE items ( | ||
wallet_id int NOT NULL, | ||
type varchar(256) NOT NULL, | ||
name varchar(256) NOT NULL, | ||
value blob NOT NULL, | ||
tags varchar(256) DEFAULT NULL, | ||
PRIMARY KEY (wallet_id, type, name) | ||
); | ||
|
||
CREATE TABLE wallets ( | ||
id int NOT NULL AUTO_INCREMENT, | ||
name varchar(64) NOT NULL, | ||
metadata varchar(4096) DEFAULT NULL, | ||
PRIMARY KEY (id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "dbutils", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"dev:schema:drop:wallet": "MYSQL_DATABASE=agency_wallets node scripts/drop-schema.js", | ||
"dev:schema:drop:app": "MYSQL_DATABASE=agency_application node scripts/drop-schema.js", | ||
"dev:schema:drop:all": "npm run dev:schema:drop:wallet && npm run dev:schema:drop:app", | ||
"dev:schema:migrate:all": "npm run dev:schema:migrate:wallet && npm run dev:schema:migrate:app", | ||
"dev:schema:migrate:wallet": "MYSQL_DATABASE=agency_wallets MYSQL_USER=root MYSQL_PASSWORD=mysecretpassword MYSQL_HOST=localhost MYSQL_PORT=3306 npm run schema:migrate:wallet", | ||
"dev:schema:migrate:app": "MYSQL_DATABASE=agency_application MYSQL_USER=root MYSQL_PASSWORD=mysecretpassword MYSQL_HOST=localhost MYSQL_PORT=3306 npm run schema:migrate:app", | ||
"schema:migrate:wallet": "node scripts/assure-schema.js && db-migrate --migrations-dir migrations_scheme_wallets up", | ||
"schema:migrate:app": "node scripts/assure-schema.js && db-migrate --migrations-dir migrations_scheme_application up", | ||
|
||
"migrate:script": "node src/migration.js", | ||
|
||
"test": "jest --runInBand ./test" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"db-migrate": "^0.11.12", | ||
"db-migrate-mysql": "^2.1.2", | ||
"jest": "^27.1.1", | ||
"mysql": "^2.18.1", | ||
"uuid": "^8.3.2" | ||
}, | ||
"devDependencies": { | ||
"sleep-promise": "^8.0.1" | ||
} | ||
} |
Oops, something went wrong.