You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* use poetry
* add push to github docker registry
* fix release.yml formatting error
* add .dockerignore file
* remove docker/make files that are not used anymore
* split pypgstac code to migrate.py load.py to help organize, add migration path logic for multi-step incremental migrations
* add pydocstyle comments
* add new scripts to enable a staging process for sql migrations
* use scripts/stageversion to add steps between all versions
* use scripts/stageversion to add steps between all versions
* Add documentation on release process to README
PyPGStac will get the database connection settings from the standard PG environment variables. It can also take a DSN database url "postgresql://..." via the --dsn flag.
23
+
- PGHOST
24
+
- PGPORT
25
+
- PGUSER
26
+
- PGDATABASE
27
+
- PGPASSWORD
28
+
29
+
## Making Changes to SQL
30
+
All changes to SQL should only be made in the sql directory. SQL Files will be run in alphabetical order.
31
+
32
+
## Adding Tests
33
+
PGStac uses PGTap to test SQL. Tests can be found in tests/pgtap.sql and are run using `scripts/test`
34
+
22
35
23
36
## Migrations
24
-
To install the latest version of pgstac on an empty database, you can directly load the primary source code.
25
-
```
26
-
psql -f pgstac.sql
27
-
```
28
-
Which calls the main SQL files in the sql directory.
37
+
PyPGStac has a utility to help apply migrations to an existing PGStac instance to bring it up to date.
29
38
30
-
All development should take place on these files.
39
+
Migrations are stored in pypgstac/pypgstac/migrations and are distributed with the PyPGStac package. There are two types of migrations.
40
+
- Base migrations install PGStac into a database with no current PGStac installation. These migrations follow the file pattern "pgstac.[version].sql"
41
+
- Incremental migrations are used to move PGStac from one version to the next. These migrations follow the file pattern "pgstac.[version].[fromversion].sql"
31
42
32
-
For each new version of PGStac, two migrations should be added to pypgstac/pypgstac/migrations/
33
-
- pgstac.[version].sql (equivalent to `cat sql/*.sql > migration.sql && echo "insert into migrations (versions) VALUES ('[version]')" >> migration.sql)
34
-
- pgstac.[version].[fromversion].sql (Migration to move from existing version to new version, can be created by hand or using the makemigration.sh tool below)
43
+
These migrations can be created when releasing a new version of PGStac using"
44
+
```
45
+
scripts/stageversion [version or increment type]
46
+
```
47
+
Examples:
48
+
```
49
+
scripts/stageversion 0.2.8
50
+
scripts/stageversion patch # if current version is 0.2.7 will bump to 0.2.8
51
+
scripts/stageversion minor # if current version is 0.2.7 will bump to 0.3.0
52
+
scripts/stageversion major # if current version is 0.2.7 will bump to 1.0.0
53
+
```
54
+
This will create a base migration for the new version and will create incremental migrations between any existing base migrations. The incremental migrations that are automatically generated by this script will have the extension ".staged" on the file. You must manually review (and make any modifications necessary) this file and remove the ".staged" extension to enable the migration.
35
55
36
56
### Running Migrations
37
-
Migrations can be installed by either directly running the appropriate migration sql file for from and target PGStac versions:
PyPGStac has a utility for checking the version of an existing PGStac database and applying the appropriate migrations in the correct order. It can also be used to setup a database from scratch.
42
58
43
-
### Creating Migrations Using Schema Diff
44
-
To create a migration from a previous version of pgstac you can calculate the migration from the running instance of pgstac using the makemigration.sh command. This will use docker to copy the schema of the existing database and the new sql into new docker databases and create/test the migration between the two.
59
+
To create an initial PGStac database or bring an existing one up to date:
0 commit comments