Skip to content

Commit

Permalink
Merge branch 'release/3.23.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
msqr committed Jun 27, 2024
2 parents 8d695f1 + 9d719f9 commit 9118203
Show file tree
Hide file tree
Showing 146 changed files with 8,939 additions and 225 deletions.
10 changes: 5 additions & 5 deletions solarnet-db-setup/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ only version 12 has been extensively tested, but newer versions may work fine.
* **uuid-ossp** extension (from contrib)
* [timescaledb](https://docs.timescale.com/) extension
* [aggs_for_vecs](https://github.com/pjungwir/aggs_for_vecs) extension

# macOS setup

On macOS, Postgres can be easily installed via the [Postgres.app](https://postgresapp.com/) or
Expand All @@ -37,7 +37,7 @@ git clone https://github.com/timescale/timescaledb.git

# checkout version tag
cd timescaledb
git checkout 2.5.1 # or some other release
git checkout 2.11.2 # or some other release
```

Then, build and install according to the TimescaleDB documentation. On macOS, for example:
Expand Down Expand Up @@ -72,7 +72,7 @@ make && sudo make install
make PG_CONFIG=/Applications/Postgres.app/Contents/Versions/12/bin/pg_config
make install PG_CONFIG=/Applications/Postgres.app/Contents/Versions/12/bin/pg_config
```


# Create database

Expand All @@ -83,7 +83,7 @@ To create a database **solarnetwork** and database user **solarnet** for develop
./bin/setup-db.sh -mrv -u solarnet -d solarnetwork
```

To create a database **solarnet_unittest** and database user **solarnet_test** for testing,
To create a database **solarnetwork_test** and database user **solartest** for testing,
the defaults can be used:

```sh
Expand All @@ -103,7 +103,7 @@ The `postgres-create.sql` script can be used to

1. Create a **solarnet** database user.
2. Create a **solarnetwork** database, owned by the **solarnet** user.
3. Install the **citext**, **pgcrypto**, **uuid-ossp**, **[timescaledb][timescaledb]**, and
3. Install the **citext**, **pgcrypto**, **uuid-ossp**, **[timescaledb][timescaledb]**, and
**[aggs_for_vecs][aggs_for_vecs]** extensions.

This script should be run as a database superuser, for example **postgres**.
Expand Down
46 changes: 40 additions & 6 deletions solarnet-db-setup/postgres/bin/setup-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Script for creating or re-creating the SolarNetwork database in its default form.
# The resulting database is suitable for development and unit testing.
#
# To create a database 'solarnet_unittest' and database user 'solarnet_test' for testing:
# To create a database 'solarnetwork_unittest' and database user 'solartest' for testing:
#
# ./bin/setup-db.sh -mrv
#
Expand All @@ -17,8 +17,8 @@
# ./bin/setup-db.sh -mrv -c '-p 5496 -h postgres96.example.com'

PSQL_CONN_ARGS=""
PG_USER="solarnet_test"
PG_DB="solarnet_unittest"
PG_USER="solartest"
PG_DB="solarnetwork_unittest"
PG_ADMIN_USER="postgres"
PG_ADMIN_DB="postgres"
PG_TEMPLATE_DB="template0"
Expand All @@ -27,20 +27,54 @@ CREATE_USER=""
DRY_RUN=""
VERBOSE=""

while getopts ":c:d:D:mrtT:u:U:v" opt; do
do_help () {
cat 1>&2 <<EOF
Usage: $0 <arguments>
-c <args> - extra arguments to pass to psql
-d <db name> - the database name; defaults to 'solarnetwork_unittest'
-D <admin db> - the Postgres admin database name; defaults to 'postgres'
-m - create the Postgres database user
-r - recreate the database (drop and create again)
-t - dry run
-T <db name> - the Postgres template database name to use; defaults to
'template0'
-u <db user> - the Postgres database user to use; defaults to 'solartest'
-U <admin user> - the Postgres admin user to use; defaults to 'postgres'
-v - increase verbosity
Example that creates the test database and user for the first time:
./bin/setup-db.sh -m
To connect to a different Postgres port:
./bin/setup-db.sh -c '-p 5412'
To recreate the database (drop and create):
./bin/setup-db.sh -r
EOF
}

while getopts ":c:d:D:hmrtT:u:U:v" opt; do
case $opt in
c) PSQL_CONN_ARGS="${OPTARG}";;
d) PG_DB="${OPTARG}";;
D) PG_ADMIN_DB="${OPTARG}";;
h) do_help
exit 0
;;
m) CREATE_USER='TRUE';;
r) RECREATE_DB='TRUE';;
t) DRY_RUN='TRUE';;
T) PG_TEMPLATE_DB="${OPTARG}";;
u) PG_USER="${OPTARG}";;
U) PG_ADMIN_USER="${OPTARG}";;
v) VERBOSE='TRUE';;
?)
echo "Unknown argument ${OPTARG}"
*) echo "Unknown argument ${OPTARG}"
do_help
exit 1
esac
done
Expand Down
3 changes: 3 additions & 0 deletions solarnet-db-setup/postgres/migrations/migrate-20240621.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Run this script from the parent directory, e.g. psql -f migrations/migrate-20240621.sql

\i updates/NET-382-http-sessions.sql
3 changes: 3 additions & 0 deletions solarnet-db-setup/postgres/migrations/migrate-20240627.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Run this script from the parent directory, e.g. psql -f migrations/migrate-20240627.sql

\i updates/NET-379-solarflux-agg-pub-settings.sql
6 changes: 6 additions & 0 deletions solarnet-db-setup/postgres/postgres-init-billing-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE SCHEMA IF NOT EXISTS solarbill;

ALTER DEFAULT PRIVILEGES IN SCHEMA solarbill REVOKE ALL ON TABLES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA solarbill REVOKE ALL ON SEQUENCES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA solarbill REVOKE ALL ON FUNCTIONS FROM PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA solarbill REVOKE ALL ON TYPES FROM PUBLIC;
Loading

0 comments on commit 9118203

Please sign in to comment.