Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/strapi-connector-bookshelf/lib/utils/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
// Public node modules
const inquirer = require('inquirer');
const hasResults = rows => {
if (!rows || rows.length === 0) return true;
return false;
};
const checkDatabaseIsEmpty = {
postgres: client =>
client
.select('tablename')
.from('pg_tables')
.where('schemaname', 'public')
.then(hasResults),
mysql: (client, { database }) =>
client
.select()
.from('information_schema.tables')
.where('table_schema', database)
.then(hasResults),
sqlite: client =>
client
.select()
.from('sqlite_master')
.then(hasResults),
};
module.exports = async ({ scope, connection }) => {
const knex = require('knex');
const { settings } = connection;
const client = knex({
client: settings.client,
connection: Object.assign({}, settings, {
user: settings.username,
}),
useNullAsDefault: true,
});
const destroyClientAndThrow = err => {
return client.destroy().then(
() => {
throw err;
},
() => {
throw err;
}
);
};
await client.raw('select 1+1 as result').catch(destroyClientAndThrow);
return checkDatabaseIsEmpty[settings.client](client, settings)
.then(isEmpty => {
if (isEmpty) return;
if (scope.dbforce) return;
console.log();
console.error(
'It seems that your database is not empty.\nStrapi automatically creates tables and columns which might corrupt the data already present in your database.'
);
return inquirer
.prompt([
{
type: 'confirm',
name: 'confirm',
message: `Are you sure you want to continue with the ${settings.database} database:`,
},
])
.then(({ confirm }) => {
// send restart flag to retry
if (!confirm) return { shouldRetry: true };
});
})
.then(res => client.destroy().then(() => res))
.catch(destroyClientAndThrow);
};
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0615 ]-- |