Skip to content

Commit

Permalink
Sekä pub että stg -skeemojen kaikkien taulujen siirtäminen
Browse files Browse the repository at this point in the history
  • Loading branch information
augustk committed Dec 19, 2024
1 parent 4178784 commit bcde60b
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions lampi-siirtaja-container/lampi-siirtaja/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const copyFileToLampi = async (sourceKey: string): Promise<ManifestItem> => {
);

console.log(
`Successfully copied ${ovaraLampiSiirtajaBucket}/${sourceKey} to ${lampiS3Bucket}/${destinationKey}`,
`Siirretty ${ovaraLampiSiirtajaBucket}/${sourceKey} => ${lampiS3Bucket}/${destinationKey}`,
);

console.log(`putObjectCommandOutput: ${JSON.stringify(putObjectCommandOutput, null, 4)}`);
Expand All @@ -110,18 +110,30 @@ const uploadManifestToLampi = async (manifest: ManifestItem[]) => {

const main = async () => {
validateParameters();
console.log(`Tietokanta-URI: ${dbUri}`.replace(dbPassword, '*****'));
const schemaName = 'pub';
const tableNames: string[] = getTableNames(schemaName).slice(0, 2);
console.log(`Table names: ${tableNames}`);
console.log(`Aloitetaan Ovaran tietojen kopiointi Lampeen`);
console.log(`Tietokannan konfiguraatio: ${dbUri}`.replace(dbPassword, '*****'));
const schemaNames = ['pub', 'stg'];
const manifest: ManifestItem[] = [];
for (const tableName of tableNames) {
copyTableToS3(schemaName, tableName);
const sourceKey = `${schemaName}.${tableName}.csv`;
const manifestItem = await copyFileToLampi(sourceKey);
manifest.push(manifestItem);
for (const schemaName of schemaNames) {
console.log(`Aloitetaan skeeman "${schemaName}" taulujen siirtäminen Lampeen`);
//const tableNames: string[] = getTableNames(schemaName).slice(0, 2);
const tableNames: string[] = getTableNames(schemaName);
console.log(`Table names: ${tableNames}`);
for (const tableName of tableNames) {
console.log(`Aloitetaan skeeman "${schemaName}" taulun "${tableName}" siirtäminen Ovaran S3-ämpäriin`);
copyTableToS3(schemaName, tableName);
console.log(`Skeeman "${schemaName}" taulun "${tableName}" siirtäminen Ovaran S3-ämpäriin valmistui`);
const sourceKey = `${schemaName}.${tableName}.csv`;
console.log(`Aloitetaan skeeman "${schemaName}" taulun "${tableName}" siirtäminen Ovaran S3-ämpäristä Lammen S3-ämpäriin (key: "${sourceKey}")`);
const manifestItem = await copyFileToLampi(sourceKey);
console.log(`Aloitetaan skeeman "${schemaName}" taulun "${tableName}" siirtäminen Ovaran S3-ämpäristä Lammen S3-ämpäriin valmistui (key: "${sourceKey}")`);
manifest.push(manifestItem);
}
console.log(`Aloitetaan skeeman "${schemaName}" taulujen siirtäminen Lampeen valmistui`);
}
console.log(`Aloitetaan manifest-tiedoston siirtäminen Lampeen`)
await uploadManifestToLampi(manifest);
console.log(`Aloitetaan manifest-tiedoston siirtäminen Lampeen valmistui`)
}

main().then(() => console.log('Ovaran tietojen siirtäminen Lampeen valmistui'));

0 comments on commit bcde60b

Please sign in to comment.