Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude orphaned_time when copying data #604

Merged
merged 3 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,12 @@ gvmd (int argc, char** argv)

if (osp_vt_update)
osp_update_socket = osp_vt_update;
else
{
g_critical ("%s: --osp-vt-update required for now",
__FUNCTION__);
return EXIT_FAILURE;
}

if (backup_database)
{
Expand Down
11 changes: 9 additions & 2 deletions tools/gvm-migrate-to-postgres.in
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,13 @@ cleanup_sqlite_db () {
# table lying around.
sqlite "DROP TABLE IF EXISTS escalator_condition_data_trash;"
test_sql_exit "Failed to remove escalator_condition_data_trash"

HAVE_CACHE=`sqlite "SELECT EXISTS (SELECT FROM sqlite_master WHERE type='table' AND name='permissions_get_tasks');"`
if [ "$HAVE_CACHE" != "0" ]
then
sqlite "UPDATE permissions_get_tasks SET has_permission = 1 WHERE has_permission != '0';"
test_sql_exit "Failed to clean permission_get_tasks"
fi
}

# Replace the value of a column if the cast does not work
Expand Down Expand Up @@ -1147,7 +1154,7 @@ copy_data () {
# database.
#
log_info "Copying SQLite3 data: copying table $TABLE"
COLS=`pg "SELECT string_agg ('\"' || column_name || '\"', ',') from (select column_name from information_schema.columns where table_schema = 'public' and table_name = '$TABLE' order by ordinal_position) as sub;"`
COLS=`pg "SELECT string_agg ('\"' || column_name || '\"', ',') FROM (SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '$TABLE' AND column_name != 'orphaned_time' order by ordinal_position) as sub;"`
log_debug "COLS: $COLS"
# Pipe SQLite CSV output into Postgres COPY FROM.
$SQLITE3 -csv $SQLITE_DB "SELECT $COLS FROM $TABLE;" | pg "COPY $TABLE ($COLS) FROM STDIN DELIMITER ',' CSV";
Expand Down Expand Up @@ -2999,7 +3006,7 @@ create () {
;;

*)
log_notice "Database version not supported: " $DB_VERSION
log_notice "Database version not supported: $DB_VERSION"
exit 1
esac
}
Expand Down