opendtu-logger/migrations/00007_events.sql
Pieter Hollander 444e5065a4
All checks were successful
Build Docker image / build (push) Successful in 1m8s
Build Golang packages / release (push) Has been skipped
Implement proper DB migrations using Goose. Upgrade go packages.
2024-07-26 22:35:30 +02:00

26 lines
833 B
SQL

-- +goose Up
-- +goose StatementBegin
DO $$
BEGIN
-- Check if start_timestamp column exists
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_name='opendtu_events'
AND column_name='start_timestamp') THEN
-- Add start_timestamp column
ALTER TABLE opendtu_events
ADD COLUMN start_timestamp TIMESTAMPTZ;
END IF;
-- Check if end_timestamp column exists
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_name='opendtu_events'
AND column_name='end_timestamp') THEN
-- Add end_timestamp column
ALTER TABLE opendtu_events
ADD COLUMN end_timestamp TIMESTAMPTZ;
END IF;
END $$;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
-- +goose StatementEnd