* feat(spot): added sql for spot feature * feat(spot): added sql code to all related files * feat(spot): added default value for created_at * feat(spot): added spots schema * feat(spot): applied a new spots schema to all sql requests
39 lines
No EOL
1.1 KiB
PL/PgSQL
39 lines
No EOL
1.1 KiB
PL/PgSQL
\set previous_version 'v1.20.0'
|
|
\set next_version 'v1.19.0'
|
|
SELECT openreplay_version() AS current_version,
|
|
openreplay_version() = :'previous_version' AS valid_previous,
|
|
openreplay_version() = :'next_version' AS is_next
|
|
\gset
|
|
|
|
\if :valid_previous
|
|
\echo valid previous DB version :'previous_version', starting DB downgrade to :'next_version'
|
|
BEGIN;
|
|
SELECT format($fn_def$
|
|
CREATE OR REPLACE FUNCTION openreplay_version()
|
|
RETURNS text AS
|
|
$$
|
|
SELECT '%1$s'
|
|
$$ LANGUAGE sql IMMUTABLE;
|
|
$fn_def$, :'next_version')
|
|
\gexec
|
|
|
|
--
|
|
ALTER TABLE IF EXISTS public.users
|
|
DROP COLUMN IF EXISTS spot_jwt_iat,
|
|
DROP COLUMN IF EXISTS spot_jwt_refresh_jti,
|
|
DROP COLUMN IF EXISTS spot_jwt_refresh_iat;
|
|
|
|
DROP SCHEMA or_cache CASCADE;
|
|
|
|
ALTER TABLE IF EXISTS public.tenants
|
|
DROP COLUMN IF EXISTS scope_state;
|
|
|
|
DROP SCHEMA IF EXISTS spots CASCADE;
|
|
|
|
COMMIT;
|
|
|
|
\elif :is_next
|
|
\echo new version detected :'next_version', nothing to do
|
|
\else
|
|
\warn skipping DB downgrade of :'next_version', expected previous version :'previous_version', found :'current_version'
|
|
\endif |