diff --git a/database/migrations/functions/issues/get_issues_filters.sql b/database/migrations/functions/issues/get_issues_filters.sql index 9625fbd..5db832f 100644 --- a/database/migrations/functions/issues/get_issues_filters.sql +++ b/database/migrations/functions/issues/get_issues_filters.sql @@ -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 ) ), diff --git a/database/migrations/functions/issues/search_issues.sql b/database/migrations/functions/issues/search_issues.sql index fa7dd76..a33a3bc 100644 --- a/database/migrations/functions/issues/search_issues.sql +++ b/database/migrations/functions/issues/search_issues.sql @@ -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 diff --git a/database/migrations/functions/projects/register_project.sql b/database/migrations/functions/projects/register_project.sql index a4df6b9..cbd931a 100644 --- a/database/migrations/functions/projects/register_project.sql +++ b/database/migrations/functions/projects/register_project.sql @@ -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 diff --git a/database/migrations/schema/002_drop_maturity_type.sql b/database/migrations/schema/002_drop_maturity_type.sql new file mode 100644 index 0000000..df123cc --- /dev/null +++ b/database/migrations/schema/002_drop_maturity_type.sql @@ -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;