diff --git a/db/migrations/00017_create_db_version_table.sql b/db/migrations/00017_create_db_version_table.sql index 8e4ac35..2cf57e9 100644 --- a/db/migrations/00017_create_db_version_table.sql +++ b/db/migrations/00017_create_db_version_table.sql @@ -1,7 +1,8 @@ -- +goose Up CREATE TABLE IF NOT EXISTS public.db_version ( singleton BOOLEAN NOT NULL DEFAULT TRUE UNIQUE CHECK (singleton), - version TEXT NOT NULL + version TEXT NOT NULL, + tstamp TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() ); -- +goose Down diff --git a/db/migrations/00018_update_db_version.sql b/db/migrations/00018_update_db_version.sql index 6f64fd6..116acd9 100644 --- a/db/migrations/00018_update_db_version.sql +++ b/db/migrations/00018_update_db_version.sql @@ -1,6 +1,6 @@ -- +goose Up INSERT INTO public.db_version (singleton, version) VALUES (true, 'v0.3.2') -ON CONFLICT (singleton) DO UPDATE SET version = 'v0.3.2'; +ON CONFLICT (singleton) DO UPDATE SET (version, tstamp) = ('v0.3.2', NOW()); -- +goose Down DELETE FROM public.db_version WHERE version = 'v0.3.2'; diff --git a/db/pre_batch_processing_migrations/00014_create_eth_db_version_table.sql b/db/pre_batch_processing_migrations/00014_create_eth_db_version_table.sql index 8e4ac35..2cf57e9 100644 --- a/db/pre_batch_processing_migrations/00014_create_eth_db_version_table.sql +++ b/db/pre_batch_processing_migrations/00014_create_eth_db_version_table.sql @@ -1,7 +1,8 @@ -- +goose Up CREATE TABLE IF NOT EXISTS public.db_version ( singleton BOOLEAN NOT NULL DEFAULT TRUE UNIQUE CHECK (singleton), - version TEXT NOT NULL + version TEXT NOT NULL, + tstamp TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() ); -- +goose Down diff --git a/db/pre_batch_processing_migrations/00015_update_db_version.sql b/db/pre_batch_processing_migrations/00015_update_db_version.sql index 6f64fd6..116acd9 100644 --- a/db/pre_batch_processing_migrations/00015_update_db_version.sql +++ b/db/pre_batch_processing_migrations/00015_update_db_version.sql @@ -1,6 +1,6 @@ -- +goose Up INSERT INTO public.db_version (singleton, version) VALUES (true, 'v0.3.2') -ON CONFLICT (singleton) DO UPDATE SET version = 'v0.3.2'; +ON CONFLICT (singleton) DO UPDATE SET (version, tstamp) = ('v0.3.2', NOW()); -- +goose Down DELETE FROM public.db_version WHERE version = 'v0.3.2'; diff --git a/schema.sql b/schema.sql index fc72234..df83153 100644 --- a/schema.sql +++ b/schema.sql @@ -419,6 +419,7 @@ CREATE TABLE public.blocks ( CREATE TABLE public.db_version ( singleton boolean DEFAULT true NOT NULL, version text NOT NULL, + tstamp timestamp without time zone DEFAULT now(), CONSTRAINT db_version_singleton_check CHECK (singleton) );