Integrated db-migrate package
This commit is contained in:
@@ -5,8 +5,6 @@ DB_DATABASE=
|
|||||||
DB_USERNAME=
|
DB_USERNAME=
|
||||||
DB_PASSWORD=
|
DB_PASSWORD=
|
||||||
|
|
||||||
DB_MIGRATION_HOST= # Target address for migration script
|
|
||||||
|
|
||||||
# AUTH SETTINGS
|
# AUTH SETTINGS
|
||||||
AUTH_DOMAIN=
|
AUTH_DOMAIN=
|
||||||
AUTH_ISSUER=
|
AUTH_ISSUER=
|
||||||
|
|||||||
2
api/.gitignore
vendored
2
api/.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
built
|
built
|
||||||
|
|
||||||
!migrations/*.sql
|
!migrations/*/*.sql
|
||||||
20
api/database.json
Normal file
20
api/database.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"dev": {
|
||||||
|
"driver": "mysql",
|
||||||
|
"user": "root",
|
||||||
|
"password": "root",
|
||||||
|
"host": "localhost",
|
||||||
|
"database": "ranger_unit_tracker",
|
||||||
|
"port": "3306",
|
||||||
|
"multipleStatements": true
|
||||||
|
},
|
||||||
|
"prod": {
|
||||||
|
"driver": "mysql",
|
||||||
|
"user": {"ENV" : "DB_USERNAME"},
|
||||||
|
"password": {"ENV" : "DB_PASSWORD"},
|
||||||
|
"host": {"ENV" : "DB_HOST"},
|
||||||
|
"database": {"ENV" : "DB_DATABASE"},
|
||||||
|
"port": {"ENV" : "DB_PORT"},
|
||||||
|
"multipleStatements": true
|
||||||
|
}
|
||||||
|
}
|
||||||
53
api/migrations/20260201154439-initial.js
Normal file
53
api/migrations/20260201154439-initial.js
Normal file
@@ -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', '20260201154439-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', '20260201154439-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
|
||||||
|
};
|
||||||
210038
api/migrations/seed.sql
210038
api/migrations/seed.sql
File diff suppressed because it is too large
Load Diff
1
api/migrations/sqls/20260201154439-initial-down.sql
Normal file
1
api/migrations/sqls/20260201154439-initial-down.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/* Replace with your SQL commands */
|
||||||
File diff suppressed because it is too large
Load Diff
779
api/package-lock.json
generated
779
api/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,17 +11,16 @@
|
|||||||
"dev": "tsc && tsc-alias && node ./built/api/src/index.js",
|
"dev": "tsc && tsc-alias && node ./built/api/src/index.js",
|
||||||
"prod": "tsc && tsc-alias && node ./built/api/src/index.js",
|
"prod": "tsc && tsc-alias && node ./built/api/src/index.js",
|
||||||
"build": "tsc && tsc-alias",
|
"build": "tsc && tsc-alias",
|
||||||
"migrate": "node ./scripts/migrate.js",
|
"seed": "node ./scripts/seed.js"
|
||||||
"migrate:create": "npm run migrate -- create -ext sql -dir /migrations",
|
|
||||||
"migrate:seed": "node ./scripts/seed.js",
|
|
||||||
"migrate:up": "npm run migrate -- up",
|
|
||||||
"migrate:down": "npm run migrate -- down 1"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@rsol/hashmig": "^1.0.7",
|
||||||
"@sentry/node": "^10.27.0",
|
"@sentry/node": "^10.27.0",
|
||||||
"@types/express-session": "^1.18.2",
|
"@types/express-session": "^1.18.2",
|
||||||
"connect-sqlite3": "^0.9.16",
|
"connect-sqlite3": "^0.9.16",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
"db-migrate": "^0.11.14",
|
||||||
|
"db-migrate-mysql": "^3.0.0",
|
||||||
"dotenv": "16.6.1",
|
"dotenv": "16.6.1",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"express-session": "^1.18.2",
|
"express-session": "^1.18.2",
|
||||||
@@ -40,4 +39,4 @@
|
|||||||
"tsc-alias": "^1.8.16",
|
"tsc-alias": "^1.8.16",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user