]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#90] modification timestamps now use time zones
authorTomek Mrugalski <tomek@isc.org>
Tue, 8 Jun 2021 17:11:50 +0000 (19:11 +0200)
committerTomek Mrugalski <tomek@isc.org>
Thu, 28 Oct 2021 10:31:41 +0000 (12:31 +0200)
src/share/database/scripts/pgsql/upgrade_6.2_to_7.0.sh.in

index 1373bd1ea1165f8878b0844a05d514e5c4ee1916..5d8677440f4665397d77250d31eba55e6e2162fd 100644 (file)
@@ -38,7 +38,7 @@ psql "$@" >/dev/null <<EOF
 START TRANSACTION;
 
 -- Adding on update trigger in MySQL is as easy as using this column definition in CREATE TABLE:
--- modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+-- modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 -- Sadly, Postgres has its own convoluted way of doing this. Luckily, the update pattern is
 -- the same in many tables, so we can define the trigger function once and the use it everywhere.
 
@@ -170,7 +170,7 @@ CREATE TABLE dhcp6_subnet (
   subnet_prefix varchar(64) UNIQUE NOT NULL,
   client_class varchar(128) DEFAULT NULL,
   interface varchar(128) DEFAULT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   preferred_lifetime BIGINT DEFAULT NULL,
   rapid_commit BOOLEAN DEFAULT NULL,
   rebind_timer BIGINT DEFAULT NULL,
@@ -224,7 +224,7 @@ CREATE TABLE dhcp6_pool (
   start_address inet NOT NULL,
   end_address inet NOT NULL,
   subnet_id BIGINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   client_class varchar(128) DEFAULT NULL,
   require_client_classes TEXT DEFAULT NULL,
   user_context JSON DEFAULT NULL,
@@ -245,7 +245,7 @@ CREATE TABLE dhcp6_pd_pool (
   prefix_length SMALLINT NOT NULL,
   delegated_prefix_length SMALLINT NOT NULL,
   subnet_id BIGINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   excluded_prefix varchar(45) DEFAULT NULL,
   excluded_prefix_length SMALLINT NOT NULL,
   client_class varchar(128) DEFAULT NULL,
@@ -270,7 +270,7 @@ CREATE TRIGGER dhcp6_pd_pool_modification_ts_update
 CREATE TABLE dhcp6_subnet_server (
   subnet_id BIGINT NOT NULL,
   server_id BIGINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   PRIMARY KEY (subnet_id, server_id),
   CONSTRAINT fk_dhcp6_subnet_server_server_id FOREIGN KEY (server_id) REFERENCES dhcp6_server (id),
   CONSTRAINT fk_dhcp6_subnet_server_subnet_id FOREIGN KEY (subnet_id) REFERENCES dhcp6_subnet (subnet_id),
@@ -290,7 +290,7 @@ CREATE TABLE dhcp6_global_parameter (
   id SERIAL PRIMARY KEY NOT NULL,
   name varchar(128) NOT NULL,
   value TEXT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   parameter_type SMALLINT NOT NULL,
   CONSTRAINT fk_dhcp6_global_parameter_type FOREIGN KEY (parameter_type) REFERENCES parameter_data_type(id)
 );
@@ -306,7 +306,7 @@ CREATE TRIGGER dhcp6_global_parameter_modification_ts_update
 CREATE TABLE dhcp6_global_parameter_server (
   parameter_id BIGINT NOT NULL,
   server_id BIGINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   PRIMARY KEY (parameter_id, server_id),
   CONSTRAINT fk_dhcp6_global_parameter_server_parameter_id FOREIGN KEY (parameter_id) REFERENCES dhcp6_global_parameter(id) ON DELETE CASCADE  ON UPDATE NO ACTION,
   CONSTRAINT fk_dhcp6_global_parameter_server_server_id FOREIGN KEY (server_id) REFERENCES dhcp6_server(id) ON DELETE CASCADE  ON UPDATE NO ACTION
@@ -334,7 +334,7 @@ CREATE TRIGGER dhcp6_options_modification_ts_update
 CREATE TABLE dhcp6_options_server (
   option_id BIGINT NOT NULL,
   server_id BIGINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   PRIMARY KEY (option_id, server_id),
   CONSTRAINT fk_dhcp6_options_server_option_id FOREIGN KEY (option_id) REFERENCES dhcp6_options (option_id) ON DELETE CASCADE ON UPDATE NO ACTION,
   CONSTRAINT fk_dhcp6_options_server_server_id FOREIGN KEY (server_id) REFERENCES dhcp6_server (id) ON DELETE CASCADE ON UPDATE NO ACTION
@@ -354,7 +354,7 @@ CREATE TABLE dhcp6_option_def (
   name VARCHAR(128) NOT NULL,
   space VARCHAR(128) NOT NULL,
   type SMALLINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   is_array BOOLEAN NOT NULL,
   encapsulate VARCHAR(128) NOT NULL,
   record_types VARCHAR DEFAULT NULL,
@@ -371,7 +371,7 @@ CREATE TRIGGER dhcp6_option_def_modification_ts_update
 CREATE TABLE dhcp6_option_def_server (
   option_def_id BIGINT NOT NULL REFERENCES dhcp6_option_def (id) ON DELETE CASCADE ON UPDATE NO ACTION,
   server_id BIGINT NOT NULL REFERENCES dhcp6_server (id) ON DELETE CASCADE ON UPDATE NO ACTION,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   PRIMARY KEY (option_def_id, server_id)
 );
 CREATE TRIGGER dhcp6_option_def_server_modification_ts_update
@@ -382,7 +382,7 @@ CREATE TRIGGER dhcp6_option_def_server_modification_ts_update
 -- Now create two tables for audit revisions...
 CREATE TABLE dhcp6_audit_revision (
   id SERIAL PRIMARY KEY NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   log_message text DEFAULT NULL,
   server_id BIGINT DEFAULT NULL
 );
@@ -427,7 +427,7 @@ CREATE TABLE dhcp4_global_parameter (
   id SERIAL PRIMARY KEY NOT NULL,
   name varchar(128) NOT NULL,
   value TEXT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   parameter_type SMALLINT NOT NULL,
   CONSTRAINT fk_dhcp6_global_parameter_type FOREIGN KEY (parameter_type) REFERENCES parameter_data_type(id)
 );
@@ -442,7 +442,7 @@ CREATE TRIGGER dhcp4_global_parameter_modification_ts_update
 CREATE TABLE dhcp4_global_parameter_server (
   parameter_id BIGINT NOT NULL,
   server_id BIGINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   PRIMARY KEY (parameter_id, server_id),
   CONSTRAINT fk_dhcp4_global_parameter_server_parameter_id FOREIGN KEY (parameter_id) REFERENCES dhcp4_global_parameter(id) ON DELETE CASCADE ON UPDATE NO ACTION,
   CONSTRAINT fk_dhcp4_global_parameter_server_server_id FOREIGN KEY (server_id) REFERENCES dhcp4_server(id) ON DELETE CASCADE  ON UPDATE NO ACTION
@@ -510,7 +510,7 @@ CREATE TABLE dhcp4_subnet (
   client_class varchar(128) DEFAULT NULL,
   interface varchar(128) DEFAULT NULL,
   match_client_id BOOLEAN DEFAULT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   next_server inet DEFAULT NULL,
   rebind_timer BIGINT DEFAULT NULL,
   relay TEXT DEFAULT NULL,
@@ -555,7 +555,7 @@ CREATE TABLE dhcp4_pool (
   start_address inet NOT NULL,
   end_address inet NOT NULL,
   subnet_id BIGINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   client_class varchar(128) DEFAULT NULL,
   require_client_classes TEXT DEFAULT NULL,
   user_context JSON DEFAULT NULL,
@@ -573,7 +573,7 @@ CREATE TRIGGER dhcp4_pool_modification_ts_update
 ALTER TABLE dhcp4_options
   ADD COLUMN shared_network_name VARCHAR(128) DEFAULT NULL,
   ADD COLUMN pool_id BIGINT DEFAULT NULL,
-  ADD COLUMN modification_ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  ADD COLUMN modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   ADD CONSTRAINT fk_dhcp4_options_pool FOREIGN KEY (pool_id) REFERENCES dhcp4_pool (id) ON DELETE CASCADE ON UPDATE CASCADE,
   ADD CONSTRAINT fk_dhcp4_options_shared_network FOREIGN KEY (shared_network_name) REFERENCES dhcp4_shared_network (name) ON DELETE CASCADE ON UPDATE CASCADE;
 
@@ -590,7 +590,7 @@ CREATE TABLE dhcp4_option_def (
   name VARCHAR(128) NOT NULL,
   space VARCHAR(128) NOT NULL,
   type SMALLINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   is_array BOOLEAN NOT NULL,
   encapsulate VARCHAR(128) NOT NULL,
   record_types VARCHAR DEFAULT NULL,
@@ -607,7 +607,7 @@ CREATE TRIGGER dhcp4_option_def_modification_ts_update
 CREATE TABLE dhcp4_option_def_server (
   option_def_id BIGINT NOT NULL REFERENCES dhcp6_option_def (id) ON DELETE CASCADE ON UPDATE NO ACTION,
   server_id BIGINT NOT NULL REFERENCES dhcp4_server (id) ON DELETE CASCADE ON UPDATE NO ACTION,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   PRIMARY KEY (option_def_id, server_id)
 );
 CREATE TRIGGER dhcp4_option_def_server_modification_ts_update
@@ -619,7 +619,7 @@ CREATE TRIGGER dhcp4_option_def_server_modification_ts_update
 CREATE TABLE dhcp4_options_server (
   option_id BIGINT NOT NULL,
   server_id BIGINT NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   PRIMARY KEY (option_id, server_id),
   CONSTRAINT fk_dhcp6_options_server_option_id FOREIGN KEY (option_id) REFERENCES dhcp4_options (option_id) ON DELETE CASCADE ON UPDATE NO ACTION,
   CONSTRAINT fk_dhcp6_options_server_server_id FOREIGN KEY (server_id) REFERENCES dhcp4_server (id) ON DELETE CASCADE ON UPDATE NO ACTION
@@ -634,7 +634,7 @@ CREATE TRIGGER dhcp4_options_server_modification_ts_update
 -- Now create two tables for audit revisions...
 CREATE TABLE dhcp4_audit_revision (
   id SERIAL PRIMARY KEY NOT NULL,
-  modification_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  modification_ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
   log_message text DEFAULT NULL,
   server_id BIGINT DEFAULT NULL
 );