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