mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-10 15:57:53 +00:00
most of a dash views api impl
This commit is contained in:
parent
5e462a0ca2
commit
698f01ab9c
5 changed files with 176 additions and 5 deletions
27
crates/migrate/data/migrations/55.sql
Normal file
27
crates/migrate/data/migrations/55.sql
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-- database version 55
|
||||
-- dashboard views
|
||||
|
||||
create function generate_dash_view_id_inner() returns char(10) as $$
|
||||
select string_agg(substr('aieu234567890', ceil(random() * 13)::integer, 1), '') from generate_series(1, 10)
|
||||
$$ language sql volatile;
|
||||
|
||||
|
||||
create function generate_dash_view_id() returns char(10) as $$
|
||||
declare newid char(10);
|
||||
begin
|
||||
loop
|
||||
newid := generate_dash_view_id_inner();
|
||||
if not exists (select 1 from dash_views where id = newid) then return newid; end if;
|
||||
end loop;
|
||||
end
|
||||
$$ language plpgsql volatile;
|
||||
|
||||
create table dash_views (
|
||||
id text not null primary key default generate_dash_view_id(),
|
||||
system int references systems(id) on delete cascade,
|
||||
name text not null,
|
||||
value text not null,
|
||||
unique (system, name)
|
||||
);
|
||||
|
||||
update info set schema_version = 55;
|
||||
Loading…
Add table
Add a link
Reference in a new issue