Exec psql commands in batches

This commit is contained in:
Daniel García Aubert 2019-11-28 18:07:44 +01:00
parent 3498fceb6a
commit ab66ad83fd

View File

@ -65,24 +65,22 @@ async function populateDatabase () {
'ported/populated_places_simple_reduced', 'ported/populated_places_simple_reduced',
'cdb_analysis_check', 'cdb_analysis_check',
'cdb_invalidate_varnish' 'cdb_invalidate_varnish'
]; ].map(filename => `${__dirname}/support/sql/${filename}.sql`);
for (const filename of filenames) { const populateDatabaseCmd = `
const populateDatabaseCmd = ` cat ${filenames.join(' ')} |
cat ${__dirname}/support/sql/${filename}.sql | sed -e "s/:PUBLICUSER/${PUBLIC_USER}/g" |
sed -e "s/:PUBLICUSER/${PUBLIC_USER}/g" | sed -e "s/:PUBLICPASS/${PUBLIC_USER_PASSWORD}/g" |
sed -e "s/:PUBLICPASS/${PUBLIC_USER_PASSWORD}/g" | sed -e "s/:TESTUSER/${TEST_USER}/g" |
sed -e "s/:TESTUSER/${TEST_USER}/g" | sed -e "s/:TESTPASS/${TEST_PASSWORD}/g" |
sed -e "s/:TESTPASS/${TEST_PASSWORD}/g" | PGOPTIONS='--client-min-messages=WARNING' psql -q -v ON_ERROR_STOP=1 ${TEST_DB}
PGOPTIONS='--client-min-messages=WARNING' psql -q -v ON_ERROR_STOP=1 ${TEST_DB} `;
`;
await exec(populateDatabaseCmd, { await exec(populateDatabaseCmd, {
env: { env: {
PGUSER: 'postgres' PGUSER: 'postgres'
} }
}); });
}
} }
async function populateRedis () { async function populateRedis () {