Skip to content

Commit

Permalink
Change project maturity field type to text (#551)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio Castaño Arteaga <[email protected]>
  • Loading branch information
tegioz authored Feb 8, 2024
1 parent c8b5c1d commit 157b659
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
9 changes: 6 additions & 3 deletions database/migrations/functions/issues/get_issues_filters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ returns json as $$
'key', 'maturity',
'options', (
select coalesce(json_agg(json_build_object(
'name', initcap(maturity::text),
'value', maturity::text
'name', initcap(maturity),
'value', maturity
)), '[]')
from (
select unnest(enum_range(null::maturity)) as maturity
select distinct maturity
from project
where maturity is not null
order by maturity asc
) m
)
),
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/functions/issues/search_issues.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ begin
p.foundation_id = any(v_foundation) else true end
and
case when cardinality(v_maturity) > 0 then
p.maturity::text = any(v_maturity) else true end
p.maturity = any(v_maturity) else true end
and
case when cardinality(v_project) > 0 then
p.name = any(v_project) else true end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ begin
p_project->>'logo_dark_url',
p_project->>'devstats_url',
(p_project->>'accepted_at')::date,
(p_project->>'maturity')::maturity,
(p_project->>'maturity'),
p_project->'maintainers_wanted',
p_project->>'digest',
p_foundation_id
Expand Down
11 changes: 11 additions & 0 deletions database/migrations/schema/002_drop_maturity_type.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
alter table project
alter column maturity type text using maturity::text,
add constraint maturity_not_empty_check check (maturity <> '');;
drop type if exists maturity;

---- create above / drop below ----

create type maturity as enum ('graduated', 'incubating', 'sandbox');
alter table project
drop constraint maturity_not_empty_check,
alter column maturity type maturity using maturity::maturity;

0 comments on commit 157b659

Please sign in to comment.