-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
12 changed files
with
248 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,44 +12,44 @@ on: | |
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/[email protected] | ||
|
||
- name: Install Nix | ||
uses: cachix/install-nix-action@v23 | ||
|
||
- name: Install python | ||
uses: actions/setup-python@v3 | ||
- name: Run pre-commit hooks | ||
run: nix-shell --pure --run 'pre-commit run --all-files' | ||
uses: pre-commit/[email protected] | ||
|
||
test-install-from-source: | ||
name: Test PostgreSQL ${{ matrix.pg }} source install on Ubuntu ${{ matrix.release }} | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
pg: ['11', '12', '13', '14', '15'] | ||
release: [focal, jammy] | ||
pg: ['12', '13', '14', '15', '16'] | ||
release: [20.04, 22.04] | ||
steps: | ||
- name: Check out repository | ||
uses: actions/[email protected] | ||
|
||
- name: Build Docker container | ||
run: docker build --build-arg=RELEASE=${{ matrix.release }} --tag=tester . | ||
run: | ||
docker build --build-arg=RELEASE=${{ matrix.release }} --build-arg="PG_VERSION=${{ | ||
matrix.pg }}" --tag=tester . | ||
|
||
- name: Install from source | ||
run: docker run --rm tester ./test/ci/install-from-source.bash ${{ matrix.pg }} | ||
run: docker run --rm tester ./test/ci/install-from-source.bash | ||
|
||
test-package-upgrade: | ||
name: Test PostgreSQL ${{ matrix.pg }} package upgrade on Ubuntu ${{ matrix.release }} | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
pg: ['11', '12', '13', '14'] # TODO: '15' | ||
release: [focal] # TODO: jammy | ||
pg: ['12', '13', '14', '15', '16'] | ||
release: [20.04] | ||
steps: | ||
- name: Check out repository | ||
uses: actions/[email protected] | ||
|
@@ -83,8 +83,8 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
pg: ['11', '12', '13', '14'] # TODO: '15' | ||
release: [focal] # TODO: jammy | ||
pg: ['11', '12', '13', '14'] | ||
release: [20.04] | ||
steps: | ||
- name: Check out repository | ||
uses: actions/[email protected] | ||
|
@@ -103,7 +103,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
pg: ['11', '12', '13', '14'] # TODO: '15' | ||
release: [focal] # TODO: jammy | ||
release: [20.04] | ||
steps: | ||
- name: Check out repository | ||
uses: actions/[email protected] | ||
|
@@ -123,7 +123,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
pg: ['11', '12', '13', '14'] # TODO: '15' | ||
release: [focal] # TODO: jammy | ||
release: [20.04] | ||
steps: | ||
- name: Check out repository | ||
uses: actions/[email protected] | ||
|
@@ -143,7 +143,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
pg: ['11', '12', '13', '14'] # TODO: '15' | ||
release: [focal] # TODO: jammy | ||
release: [20.04] | ||
steps: | ||
- name: Check out repository | ||
uses: actions/[email protected] | ||
|
@@ -178,7 +178,7 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
release: [focal, jammy] | ||
release: [20.04, 22.04] | ||
max-parallel: 1 | ||
steps: | ||
- name: Check out repository | ||
|
@@ -204,7 +204,6 @@ jobs: | |
fi | ||
fi | ||
echo "REPO=$REPO" | tee --append $GITHUB_ENV | ||
- name: Build and release package | ||
uses: linz/linz-software-repository@v15 | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,14 +120,8 @@ BEGIN | |
INTO v_table_has_data; | ||
|
||
IF v_table_has_data THEN | ||
IF @extschema@._ver_get_reversion_temp_table('_changeset_revision') THEN | ||
SELECT | ||
max(VER.revision) | ||
INTO | ||
v_revision | ||
FROM | ||
_changeset_revision VER; | ||
|
||
IF coalesce(current_setting('table_version.current_revision', TRUE), '') <> '' THEN | ||
v_revision := current_setting('table_version.current_revision', TRUE)::INTEGER; | ||
v_revision_exists := TRUE; | ||
ELSE | ||
SELECT @[email protected]_create_revision( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,20 +9,36 @@ $$ | |
DECLARE | ||
v_revision @extschema@.revision.id%TYPE; | ||
BEGIN | ||
IF @extschema@._ver_get_reversion_temp_table('_changeset_revision') THEN | ||
SELECT @extschema@._ver_create_revision(p_comment, p_revision_time, p_schema_change) | ||
INTO v_revision; | ||
PERFORM set_config('table_version.manual_revision', 't', FALSE); | ||
RETURN v_revision; | ||
END; | ||
$$ LANGUAGE plpgsql SECURITY DEFINER; | ||
|
||
|
||
|
||
CREATE OR REPLACE FUNCTION _ver_create_revision( | ||
p_comment TEXT, | ||
p_revision_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
p_schema_change BOOLEAN DEFAULT FALSE | ||
) | ||
RETURNS INTEGER AS | ||
$$ | ||
DECLARE | ||
v_revision @extschema@.revision.id%TYPE; | ||
BEGIN | ||
IF coalesce(current_setting('table_version.manual_revision', TRUE), '') <> '' AND | ||
coalesce(current_setting('table_version.current_revision', TRUE), '') <> '' | ||
THEN | ||
RAISE EXCEPTION 'A revision changeset is still in progress. Please complete the revision before starting a new one'; | ||
END IF; | ||
|
||
INSERT INTO @[email protected] (revision_time, schema_change, comment, user_name) | ||
VALUES (p_revision_time, p_schema_change, p_comment, SESSION_USER) | ||
RETURNING id INTO v_revision; | ||
|
||
CREATE TEMP TABLE _changeset_revision( | ||
revision INTEGER NOT NULL PRIMARY KEY | ||
); | ||
INSERT INTO _changeset_revision(revision) VALUES (v_revision); | ||
ANALYSE _changeset_revision; | ||
|
||
|
||
PERFORM set_config('table_version.current_revision', v_revision::VARCHAR, FALSE); | ||
RETURN v_revision; | ||
END; | ||
$$ LANGUAGE plpgsql SECURITY DEFINER; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,24 @@ DECLARE | |
v_user_name TEXT; | ||
|
||
BEGIN | ||
IF NOT @extschema@._ver_get_reversion_temp_table('_changeset_revision') THEN | ||
IF coalesce(current_setting('table_version.current_revision', TRUE), '') = '' THEN | ||
RAISE EXCEPTION 'No in-progress revision'; | ||
RETURN FALSE; | ||
END IF; | ||
|
||
SELECT user_name | ||
FROM @[email protected] r, _changeset_revision t | ||
WHERE r.id = t.revision | ||
INTO v_user_name; | ||
FROM @[email protected] r | ||
WHERE r.id = current_setting('table_version.current_revision', TRUE)::INTEGER | ||
INTO v_user_name; | ||
|
||
IF NOT pg_has_role(session_user, v_user_name, 'usage') THEN | ||
RAISE EXCEPTION 'In-progress revision can only be completed ' | ||
'by its creator user %', v_user_name; | ||
END IF; | ||
|
||
DROP TABLE _changeset_revision; | ||
|
||
PERFORM set_config('table_version.current_revision', '', FALSE); | ||
PERFORM set_config('table_version.manual_revision', '', FALSE); | ||
|
||
RETURN TRUE; | ||
END; | ||
$$ LANGUAGE plpgsql SECURITY DEFINER; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.