Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
fix: remove duplicate schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlettau committed Jan 13, 2018
1 parent a20ef18 commit 056d58e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
11 changes: 6 additions & 5 deletions dist/commands/pull.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/commands/pull.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/commands/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ function scriptFiles(config: Config, results: sql.IResult<any>[]): void {
const indexes: IndexRecordSet[] = results[5].recordset;

// get unique schema names
const schemas: SchemaRecordSet[] = tables.map(item => {
return { name: item.schema, type: 'SCHEMA' };
});
const schemas: SchemaRecordSet[] = tables
.map(item => item.schema)
.filter((value, index, array) => array.indexOf(value) === index)
.map(value => ({ name: value, type: 'SCHEMA' }));

// write files for schemas
for (const item of schemas) {
Expand Down Expand Up @@ -183,7 +184,7 @@ function createFile(config: Config, item: any, file: string, content: string): s
content = script.idempotency(item, type) + content;

// create file
console.log(`Creating '${chalk.cyan(dir)}' ...`);
console.log(`Creating ${chalk.cyan(dir)} ...`);
fs.outputFileSync(dir, content.trim());

return dir;
Expand Down Expand Up @@ -229,7 +230,7 @@ function exclude(existing: string[], dir: string): void {
*/
function removeFiles(files: string[]): void {
for (const file of files) {
console.log(`Removing '${chalk.cyan(file)}' ...`);
console.log(`Removing ${chalk.cyan(file)} ...`);
fs.removeSync(file);
}
}

0 comments on commit 056d58e

Please sign in to comment.