Skip to content

Commit

Permalink
Add more fixture data.
Browse files Browse the repository at this point in the history
This adds three DeletionMarkers for folders that are a part of the box
that's a member of that project, 10 events, and 10 scanned resources.
  • Loading branch information
tpendragon committed Jul 18, 2024
1 parent ca826dc commit 07e02e8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 24 additions & 1 deletion figgy-fixture-container/create-fixture-exports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Women Life Freedom Movement: Iran 2022
PROJECT_ID=2961c153-54ab-4c6a-b5cd-aa992f4c349b
# First box in Women Life Freedom Movement
BOX_ID=82624edb-c360-4d8a-b202-f103ee639e8e

# Export the project
ssh [email protected] "cd /opt/figgy/current && PGPASSWORD=\$FIGGY_DB_RO_PASSWORD psql -d \$FIGGY_DB -U \$FIGGY_DB_RO_USERNAME -h \$FIGGY_DB_HOST -c \"\\copy (select * from orm_resources WHERE id = '$PROJECT_ID') TO '/tmp/project-export.binary' BINARY\""
Expand Down Expand Up @@ -36,7 +38,28 @@ END

ssh [email protected] "cd /opt/figgy/current && PGPASSWORD=\$FIGGY_DB_RO_PASSWORD psql -d \$FIGGY_DB -U \$FIGGY_DB_RO_USERNAME -h \$FIGGY_DB_HOST -c \"\\copy ($VOCABULARY_QUERY) TO '/tmp/project-vocabulary-export.binary' BINARY\""

# Get deletion markers for any Folders deleted from the project's box.
DELETION_MARKERS_QUERY=$(cat <<-END
select * FROM orm_resources WHERE internal_resource='DeletionMarker' AND metadata @> '{\"parent_id\": [{\"id\": \"$BOX_ID\"}]}'
END
)

ssh [email protected] "cd /opt/figgy/current && PGPASSWORD=\$FIGGY_DB_RO_PASSWORD psql -d \$FIGGY_DB -U \$FIGGY_DB_RO_USERNAME -h \$FIGGY_DB_HOST -c \"\\copy ($DELETION_MARKERS_QUERY) TO '/tmp/project-dm-export.binary' BINARY\""

# Get a few resources we don't want to index in Phase 1-3
IGNORABLE_RESOURCES_QUERY=$(cat <<-END
select * from orm_resources WHERE internal_resource = 'Event' LIMIT 10
END
)
IGNORABLE_RESOURCES_QUERY_2=$(cat <<-END
select * from orm_resources WHERE internal_resource = 'ScannedResource' LIMIT 10
END
)

ssh [email protected] "cd /opt/figgy/current && PGPASSWORD=\$FIGGY_DB_RO_PASSWORD psql -d \$FIGGY_DB -U \$FIGGY_DB_RO_USERNAME -h \$FIGGY_DB_HOST -c \"\\copy ($IGNORABLE_RESOURCES_QUERY) TO '/tmp/project-ignore-export.binary' BINARY\""
ssh [email protected] "cd /opt/figgy/current && PGPASSWORD=\$FIGGY_DB_RO_PASSWORD psql -d \$FIGGY_DB -U \$FIGGY_DB_RO_USERNAME -h \$FIGGY_DB_HOST -c \"\\copy ($IGNORABLE_RESOURCES_QUERY_2) TO '/tmp/project-ignore2-export.binary' BINARY\""

# Get the DB schema
ssh [email protected] "cd /opt/figgy/current && PGPASSWORD=\$FIGGY_DB_RO_PASSWORD pg_dump -Fc -U \$FIGGY_DB_RO_USERNAME -h \$FIGGY_DB_HOST -f /tmp/db-schema.sql --schema-only \$FIGGY_DB"

scp [email protected]:/tmp/\{db-schema.sql,project-vocabulary-export.binary,project-members-export.binary,project-export.binary\} fixture-exports/
scp [email protected]:/tmp/\{db-schema.sql,*-export.binary\} fixture-exports/
3 changes: 3 additions & 0 deletions figgy-fixture-container/import-container-fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ pg_restore -d "$POSTGRES_DB" --no-owner --no-privileges --role=$POSTGRES_USER /t
psql -d "$POSTGRES_DB" -U $POSTGRES_USER -c "\copy orm_resources FROM /tmp/fixture-exports/project-export.binary BINARY"
psql -d "$POSTGRES_DB" -U $POSTGRES_USER -c "\copy orm_resources FROM /tmp/fixture-exports/project-members-export.binary BINARY"
psql -d "$POSTGRES_DB" -U $POSTGRES_USER -c "\copy orm_resources FROM /tmp/fixture-exports/project-vocabulary-export.binary BINARY"
psql -d "$POSTGRES_DB" -U $POSTGRES_USER -c "\copy orm_resources FROM /tmp/fixture-exports/project-dm-export.binary BINARY"
psql -d "$POSTGRES_DB" -U $POSTGRES_USER -c "\copy orm_resources FROM /tmp/fixture-exports/project-ignore-export.binary BINARY"
psql -d "$POSTGRES_DB" -U $POSTGRES_USER -c "\copy orm_resources FROM /tmp/fixture-exports/project-ignore2-export.binary BINARY"

0 comments on commit 07e02e8

Please sign in to comment.