hockey-blast-common-lib 0.1.16__py3-none-any.whl → 0.1.18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hockey_blast_common_lib/dump_sample_db.sh +24 -0
- hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
- hockey_blast_common_lib/restore_sample_db.sh +37 -0
- {hockey_blast_common_lib-0.1.16.dist-info → hockey_blast_common_lib-0.1.18.dist-info}/METADATA +1 -1
- {hockey_blast_common_lib-0.1.16.dist-info → hockey_blast_common_lib-0.1.18.dist-info}/RECORD +7 -4
- {hockey_blast_common_lib-0.1.16.dist-info → hockey_blast_common_lib-0.1.18.dist-info}/WHEEL +0 -0
- {hockey_blast_common_lib-0.1.16.dist-info → hockey_blast_common_lib-0.1.18.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/bin/zsh
|
2
|
+
|
3
|
+
# Database credentials from environment variables
|
4
|
+
DB_USER=${DB_USER:-"frontend_user"}
|
5
|
+
DB_PASSWORD=${DB_PASSWORD:-"hockey-blast"}
|
6
|
+
DB_NAME=${DB_NAME:-"hockey_blast_sample"}
|
7
|
+
DB_HOST=${DB_HOST:-"localhost"}
|
8
|
+
DB_PORT=${DB_PORT:-"5432"}
|
9
|
+
DUMP_FILE="hockey_blast_sample_backup.sql"
|
10
|
+
COMPRESSED_DUMP_FILE="hockey_blast_sample_backup.sql.gz"
|
11
|
+
|
12
|
+
# Export PGPASSWORD to avoid password prompt
|
13
|
+
export PGPASSWORD=$DB_PASSWORD
|
14
|
+
|
15
|
+
# Dump the database schema and data
|
16
|
+
pg_dump --username=$DB_USER --host=$DB_HOST --port=$DB_PORT --format=custom --file=$DUMP_FILE $DB_NAME
|
17
|
+
|
18
|
+
# Compress the backup file
|
19
|
+
gzip -c $DUMP_FILE > $COMPRESSED_DUMP_FILE
|
20
|
+
|
21
|
+
# Remove the uncompressed backup file
|
22
|
+
rm $DUMP_FILE
|
23
|
+
|
24
|
+
echo "Database dump completed: $COMPRESSED_DUMP_FILE"
|
Binary file
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/bin/zsh
|
2
|
+
|
3
|
+
# Database credentials from environment variables
|
4
|
+
DB_USER=${DB_USER:-"frontend_user"}
|
5
|
+
DB_PASSWORD=${DB_PASSWORD:-"hockey-blast"}
|
6
|
+
DB_NAME=${DB_NAME:-"hockey_blast_sample"}
|
7
|
+
DB_HOST=${DB_HOST:-"localhost"}
|
8
|
+
DB_PORT=${DB_PORT:-"5432"}
|
9
|
+
COMPRESSED_DUMP_FILE="hockey_blast_sample_backup.sql.gz"
|
10
|
+
|
11
|
+
# Superuser credentials
|
12
|
+
SUPERUSER="your_superuser"
|
13
|
+
SUPERUSER_PASSWORD="your_superuser_password"
|
14
|
+
|
15
|
+
# Export PGPASSWORD to avoid password prompt
|
16
|
+
export PGPASSWORD=$SUPERUSER_PASSWORD
|
17
|
+
|
18
|
+
# Drop the existing database if it exists
|
19
|
+
psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT -d postgres --command="SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$DB_NAME' AND pid <> pg_backend_pid();"
|
20
|
+
psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT -d postgres --command="DROP DATABASE IF EXISTS $DB_NAME"
|
21
|
+
|
22
|
+
# Create a new database
|
23
|
+
psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT -d postgres --command="CREATE DATABASE $DB_NAME OWNER $SUPERUSER"
|
24
|
+
|
25
|
+
# Export PGPASSWORD for frontend_user user
|
26
|
+
export PGPASSWORD=$DB_PASSWORD
|
27
|
+
|
28
|
+
# Restore the database from the dump file with --no-owner option
|
29
|
+
gunzip -c $COMPRESSED_DUMP_FILE | pg_restore --username=$DB_USER --host=$DB_HOST --port=$DB_PORT --dbname=$DB_NAME --format=custom --no-owner
|
30
|
+
|
31
|
+
# Create the frontend_user if it does not exist
|
32
|
+
psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT --dbname=$DB_NAME --command="DO \$\$ BEGIN IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'frontend_user') THEN CREATE ROLE frontend_user LOGIN PASSWORD '$DB_PASSWORD'; END IF; END \$\$;"
|
33
|
+
|
34
|
+
# Grant necessary permissions to the user
|
35
|
+
psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT --dbname=$DB_NAME --command="GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO frontend_user"
|
36
|
+
|
37
|
+
echo "Database restore completed: $DB_NAME"
|
{hockey_blast_common_lib-0.1.16.dist-info → hockey_blast_common_lib-0.1.18.dist-info}/RECORD
RENAMED
@@ -4,12 +4,15 @@ hockey_blast_common_lib/aggregate_human_stats.py,sha256=88OMhTgQjzc9xIakf6kW9_lZ
|
|
4
4
|
hockey_blast_common_lib/aggregate_referee_stats.py,sha256=A0PTyEbPUjqfXxlJCDOVioFaQk9AyjjhiWEuRuu35v0,11036
|
5
5
|
hockey_blast_common_lib/aggregate_skater_stats.py,sha256=37fhgej9trukr8cGaK7DT1HoxBcp95qwsypYCCziqqc,15563
|
6
6
|
hockey_blast_common_lib/db_connection.py,sha256=8XWa4R0tBR1bCe1gZeBCOkvIrM25lzEUxtn1HGTsyX4,1181
|
7
|
+
hockey_blast_common_lib/dump_sample_db.sh,sha256=MHPA-Ciod7wsvAlMbRtXFiyajgnEqU1xR59sJQ9UWR0,738
|
8
|
+
hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=JIk9FeWrEqHvmTLeueJtSkK2mNpg_xtonAMHDKlYe-4,1033693
|
7
9
|
hockey_blast_common_lib/models.py,sha256=GqQIGpanmFub97BoYCuaqDov2MxM4LMesUTxZ2edpvw,15393
|
8
10
|
hockey_blast_common_lib/options.py,sha256=-LtEX8duw5Pl3CSpjFlLM5FPvrZuTAxTfSlDPa7H6mQ,761
|
11
|
+
hockey_blast_common_lib/restore_sample_db.sh,sha256=u2zKazC6vNMULkpYzI64nlneCWaGUtDHPBAU-gWgRbw,1861
|
9
12
|
hockey_blast_common_lib/stats_models.py,sha256=PI-mL1jmjCHLAvaATxSsjHEn05g9L_reA_YpsITPWjQ,21047
|
10
13
|
hockey_blast_common_lib/utils.py,sha256=OmeLVJSsjoBrE---w9MwXPKD3-UMZ9HB6a4YtsGDj30,3765
|
11
14
|
hockey_blast_common_lib/wsgi.py,sha256=wl1gf3KtaGSnYbCF5Z2xWwRXNSTQp43HoyhCAKJibI4,750
|
12
|
-
hockey_blast_common_lib-0.1.
|
13
|
-
hockey_blast_common_lib-0.1.
|
14
|
-
hockey_blast_common_lib-0.1.
|
15
|
-
hockey_blast_common_lib-0.1.
|
15
|
+
hockey_blast_common_lib-0.1.18.dist-info/METADATA,sha256=si_lUPVo7SKOdtn6pjbsEi8fIPppgRPMuf17Ndzbmcs,318
|
16
|
+
hockey_blast_common_lib-0.1.18.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
17
|
+
hockey_blast_common_lib-0.1.18.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
|
18
|
+
hockey_blast_common_lib-0.1.18.dist-info/RECORD,,
|
File without changes
|
{hockey_blast_common_lib-0.1.16.dist-info → hockey_blast_common_lib-0.1.18.dist-info}/top_level.txt
RENAMED
File without changes
|