From 409d0c4ffd5cf8c1aeae3ab4e3b0df35a6dd4051 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Wed, 22 Jun 2022 13:53:01 +0700 Subject: [PATCH] refactor: relocate db scripts --- .gitignore | 2 -- database/db.js => controllers/utils/initDatabase.js | 6 +++--- package.json | 2 +- database/migration.js => scripts/migrate.js | 0 4 files changed, 4 insertions(+), 6 deletions(-) rename database/db.js => controllers/utils/initDatabase.js (92%) rename database/migration.js => scripts/migrate.js (100%) diff --git a/.gitignore b/.gitignore index 2019e1f..3182035 100644 --- a/.gitignore +++ b/.gitignore @@ -62,8 +62,6 @@ package-lock.json .node-version .nvmrc !.gitkeep -/start.json -/migrate.js # User directories (renders) /public/render/**/original diff --git a/database/db.js b/controllers/utils/initDatabase.js similarity index 92% rename from database/db.js rename to controllers/utils/initDatabase.js index 9b08e9f..0d0f963 100644 --- a/database/db.js +++ b/controllers/utils/initDatabase.js @@ -1,4 +1,4 @@ -const init = async db => { +const initDatabase = async db => { // Create the tables we need to store galleries and files await db.schema.hasTable('albums').then(exists => { if (!exists) { @@ -63,10 +63,10 @@ const init = async db => { password: hash, token: require('randomstring').generate(64), timestamp, - permission: require('./../controllers/permissionController').permissions.superadmin, + permission: require('./../permissionController').permissions.superadmin, registration: timestamp }) } } -module.exports = init +module.exports = initDatabase diff --git a/package.json b/package.json index 0d8b40d..d967ebd 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "watch": "gulp watch", "develop": "env NODE_ENV=development gulp watch", "dev": "env NODE_ENV=development gulp watch", - "migrate": "node ./database/migration.js", + "migrate": "node ./scripts/migrate.js", "bump-versions": "node ./scripts/bump-versions.js", "cf-purge": "node ./scripts/cf-purge.js", "clean-up": "node ./scripts/clean-up.js", diff --git a/database/migration.js b/scripts/migrate.js similarity index 100% rename from database/migration.js rename to scripts/migrate.js