wynn/migrations/005_wynn_items_fullresult.sql
a e8be23774f
Some checks failed
commit-tag / commit-tag-image (map[context:./migrations file:./migrations/Dockerfile name:migrations]) (push) Successful in 18s
commit-tag / commit-tag-image (map[context:./ts file:./ts/Dockerfile name:ts]) (push) Failing after 57s
noot
2025-06-30 21:31:26 -05:00

42 lines
1.0 KiB
SQL

-- Write your migrate up statements here
-- Create new table to store entire fullresult
create table wynn.items_fullresult (
hash text not null primary key,
data jsonb not null,
timestamp timestamptz not null default now()
);
create index items_fullresult_timestamp on wynn.items_fullresult (timestamp);
-- Drop the old items table
drop table if exists wynn.items;
-- Remove the old hash tracking
delete from meta.hashes where key = 'wynn.items';
---- create above / drop below ----
-- Recreate the old items table
create table wynn.items (
name text not null primary key,
display_name text not null,
type text not null,
hash text not null,
data jsonb not null
);
-- Restore hash tracking
insert into meta.hashes (key, value)
select 'wynn.items', hash
from wynn.items_fullresult
order by timestamp desc
limit 1
on conflict do nothing;
-- Drop the new table
drop table if exists wynn.items_fullresult;
-- Write your migrate down statements here. If this migration is irreversible
-- Then delete the separator line above.