Skip to content

Commit

Permalink
🐛 Reload all tsigkeys on full slavezone reload
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmybergman committed Jun 10, 2024
1 parent 11e8eb6 commit 8f55c64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion server/debian/atomiadns-database.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ if [ $retval != 0 ]; then
echo "database zonedata already exist, but doesn't contain the atomiadns schema. You will have to make sure that the schema matches $basedir/schema manually"
exit 1
else
latest_version="94"
latest_version="95"

if [ "$schema_version" = "$latest_version" ]; then
echo "The installed schema is the latest version, keeping the database as it is."
Expand Down Expand Up @@ -670,6 +670,10 @@ if [ $retval != 0 ]; then
recreate_procedure "setzonestatus"
fi

if [ "$schema_version" -lt 95 ]; then
recreate_procedure "reloadallslavezones"
fi

set_schema_version "$latest_version"
else
echo "database zonedata already exist, but contains a bad schema version ($schema_version), this should never happen and indicates a bug."
Expand Down
2 changes: 1 addition & 1 deletion server/schema/ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CREATE TABLE atomiadns_schemaversion (
version INT
);

INSERT INTO atomiadns_schemaversion (version) VALUES (94);
INSERT INTO atomiadns_schemaversion (version) VALUES (95);

CREATE TABLE allow_zonetransfer (
id SERIAL PRIMARY KEY NOT NULL,
Expand Down
2 changes: 2 additions & 0 deletions server/schema/reloadallslavezones.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ CREATE OR REPLACE FUNCTION ReloadAllSlaveZones () RETURNS void AS $$
BEGIN
INSERT INTO slavezone_change (nameserver_id, zone)
SELECT nameserver.id, slavezone.name FROM nameserver, slavezone WHERE nameserver.nameserver_group_id = slavezone.nameserver_group_id;
INSERT INTO tsigkey_change (nameserver_id, tsigkey_name)
SELECT n.id, k.name FROM tsigkey k INNER JOIN nameserver n ON k.nameserver_group_id = n.nameserver_group_id;
END; $$ LANGUAGE plpgsql;

0 comments on commit 8f55c64

Please sign in to comment.