Skip to content

Commit

Permalink
Several small fixes:
Browse files Browse the repository at this point in the history
- Fix directory scanning
- Fix several messages
  • Loading branch information
jwdeitch committed Sep 26, 2017
1 parent 92e65c8 commit 7e281e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct fs_discovered_migrations *getMigrationsFromFs(const char *dir) {
exit(1);
}
*itr = 0;
listdir(".", 15);
listdir(dir, 15);
strcpy(file_names_arr[*itr].name, "\0");
return file_names_arr;

Expand Down
6 changes: 3 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ int main(int argc, char *argv[]) {
}

if (is_setup == 0) {
printf("ERROR: pg_migrate table not found in public schema\nRun `pg_migrate -H [host url] -g`\n");
return 2;
printf("ERROR: manifest table not found in pgmigrate schema\nRun `pg_migrate -H [host url] -g`\n");
return 1;
}

if (s) {
Expand Down Expand Up @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) {
realpath(file, path);
DIR *dir = opendir(path);
if (!dir) {
fprintf(stderr, "No valid directory provided %s\n", path);
fprintf(stderr, "No valid directory provided: %s\n", path);
exit(1);
}
closedir(dir);
Expand Down
8 changes: 7 additions & 1 deletion src/pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ void runMigrations(PGconn *connection, char **migrationsToBeRan, int should_simu
printf("Migrated: %s\n", migrationsToBeRan[i]);
free(fileContents);
} else {
printf("(simulated) Migrate: %s\n", migrationsToBeRan[i]);
if (fsize == 0) {
printf("(simulated) Skipping (file is empty): %s\n", migrationsToBeRan[i]);
}
printf("(simulated) Migrate: %s\n", migrationsToBeRan[i]);
}
i++;
}
Expand Down Expand Up @@ -320,6 +323,9 @@ void rollbackMigrations(PGconn *connection, int should_simulate) {
runRollbackFile(connection, upFilepath, downFilepath);
printf("Rolled back: %s\n", downFilepath);
} else {
if (fsize == 0) {
printf("(simulated) Skipping (file is empty): %s\n", downFilepath);
}
printf("(simulated) Roll back: %s\n", downFilepath);
}
}
Expand Down

0 comments on commit 7e281e7

Please sign in to comment.