Skip to content
Snippets Groups Projects
Commit f0abad06 authored by Marcin's avatar Marcin
Browse files

eliminate hafd.table_schema from usage

parent 859f9321
No related branches found
Tags 0.20.7
6 merge requests!627merge in fix for get_current_block_age,!626Fix get_current_block_age function to avoid healthcheck fails,!622merge develop to master,!599merge ( with merge commit) develop to master,!597Merge develop to master for release,!590issue #259 automaticly get tables to db hash computation
......@@ -98,8 +98,8 @@ verify_table_schema() {
psql_do -a -d "$DB_NAME_AFTER_UPDATE" -c 'CREATE EXTENSION hive_fork_manager CASCADE;'
psql_do -d "$DB_NAME_AFTER_UPDATE" -q -t -A -f "$SCRIPTPATH/update.sql"
BEFORE_UPDATE=$(psql_do -d "$DB_NAME" -t -A -c "SELECT schema_hash FROM hive_update.create_database_hash()")
AFTER_UPDATE=$(psql_do -d "$DB_NAME_AFTER_UPDATE" -t -A -c "SELECT schema_hash FROM hive_update.create_database_hash()")
BEFORE_UPDATE=$(psql_do -d "$DB_NAME" -t -A -c "SELECT hive_update.create_database_hash()")
AFTER_UPDATE=$(psql_do -d "$DB_NAME_AFTER_UPDATE" -t -A -c "SELECT hive_update.create_database_hash()")
if [ "$BEFORE_UPDATE" = "$AFTER_UPDATE" ]; then
echo "The table schema is correct, verification completed."
echo "Dropping temporary database"
......
......@@ -336,28 +336,20 @@ $BODY$
DROP FUNCTION IF EXISTS hive_update.create_database_hash;
CREATE FUNCTION hive_update.create_database_hash()
RETURNS SETOF hafd.table_schema
RETURNS UUID
LANGUAGE plpgsql
VOLATILE
STABLE
AS
$BODY$
DECLARE
ts hafd.table_schema%ROWTYPE;
_tmp TEXT;
_provider_hashes TEXT;
BEGIN
TRUNCATE hafd.table_schema;
SELECT string_agg(table_schema, ' | ') FROM hive_update.calculate_schema_hash() INTO _tmp;
SELECT string_agg(provider || hash, ' | ') FROM hive_update.calculate_state_provider_hashes() INTO _provider_hashes;
_tmp = _tmp || _provider_hashes;
INSERT INTO hafd.table_schema VALUES ('hafd', MD5(_tmp)::uuid);
ts.schema_name := 'hafd';
ts.schema_hash := MD5(_tmp)::uuid;
RETURN NEXT ts;
RETURN MD5(_tmp)::uuid;
END;
$BODY$
;
......
......@@ -27,7 +27,7 @@ BEGIN
SELECT STRING_AGG( hash, '|') FROM hive_update.calculate_state_provider_hashes() INTO __all_before_hashes;
SELECT * FROM hive_update.calculate_state_provider_hash( 'KEYAUTH'::hafd.state_providers ) INTO __keyauth_before_hash;
SELECT schema_hash FROM hive_update.create_database_hash() INTO __database_hash_before;
SELECT hive_update.create_database_hash() INTO __database_hash_before;
EXECUTE format( 'CREATE OR REPLACE FUNCTION hive.start_provider_keyauth( _context hafd.context_name )
RETURNS TEXT[]
......@@ -43,7 +43,7 @@ BEGIN
SELECT STRING_AGG( hash, '|') FROM hive_update.calculate_state_provider_hashes() INTO __all_after_hashes;
SELECT * FROM hive_update.calculate_state_provider_hash( 'KEYAUTH'::hafd.state_providers ) INTO __keyauth_after_hash;
SELECT schema_hash FROM hive_update.create_database_hash() INTO __database_hash_after;
SELECT hive_update.create_database_hash() INTO __database_hash_after;
ASSERT __all_after_hashes != __all_before_hashes, 'Hashes not changed after modification';
ASSERT __keyauth_after_hash != __keyauth_before_hash, 'Hash not changed after modification';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment