diff --git a/db/migration/0021_dry_skreet.sql b/db/migration/0021_dry_skreet.sql new file mode 100644 index 0000000..3d247d8 --- /dev/null +++ b/db/migration/0021_dry_skreet.sql @@ -0,0 +1,6 @@ +ALTER TABLE "capital_project" ADD COLUMN "category" text;--> statement-breakpoint +ALTER TABLE "capital_project" ADD CONSTRAINT "capital_project_category_options" CHECK ("capital_project"."category" IN ( + 'Fixed Asset', + 'Lump Sum', + 'ITT, Vehicles, and Equipment' + )); \ No newline at end of file diff --git a/db/migration/meta/0021_snapshot.json b/db/migration/meta/0021_snapshot.json new file mode 100644 index 0000000..643b5a4 --- /dev/null +++ b/db/migration/meta/0021_snapshot.json @@ -0,0 +1,1136 @@ +{ + "id": "4a8c6c40-72e4-4942-ae51-00f6c443b25d", + "prevId": "c06c5fe8-f5ef-48d9-adeb-0ac8ed807c4e", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.agency_budget": { + "name": "agency_budget", + "schema": "", + "columns": { + "code": { + "name": "code", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sponsor": { + "name": "sponsor", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "agency_budget_sponsor_agency_initials_fk": { + "name": "agency_budget_sponsor_agency_initials_fk", + "tableFrom": "agency_budget", + "tableTo": "agency", + "columnsFrom": [ + "sponsor" + ], + "columnsTo": [ + "initials" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agency": { + "name": "agency", + "schema": "", + "columns": { + "initials": { + "name": "initials", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.borough": { + "name": "borough", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "char(1)", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "abbr": { + "name": "abbr", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.budget_line": { + "name": "budget_line", + "schema": "", + "columns": { + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "budget_line_code_agency_budget_code_fk": { + "name": "budget_line_code_agency_budget_code_fk", + "tableFrom": "budget_line", + "tableTo": "agency_budget", + "columnsFrom": [ + "code" + ], + "columnsTo": [ + "code" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "budget_line_code_id_pk": { + "name": "budget_line_code_id_pk", + "columns": [ + "code", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.capital_commitment_fund": { + "name": "capital_commitment_fund", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "capital_commitment_id": { + "name": "capital_commitment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "capital_fund_category": { + "name": "capital_fund_category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "capital_commitment_fund_capital_commitment_id_capital_commitment_id_fk": { + "name": "capital_commitment_fund_capital_commitment_id_capital_commitment_id_fk", + "tableFrom": "capital_commitment_fund", + "tableTo": "capital_commitment", + "columnsFrom": [ + "capital_commitment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "capital_commitment_fund_capital_fund_category": { + "name": "capital_commitment_fund_capital_fund_category", + "value": "\"capital_commitment_fund\".\"capital_fund_category\" IN ('city-non-exempt', 'city-exempt', 'city-cost', 'non-city-state', 'non-city-federal', 'non-city-other', 'non-city-cost', 'total')" + } + }, + "isRLSEnabled": false + }, + "public.capital_commitment_type": { + "name": "capital_commitment_type", + "schema": "", + "columns": { + "code": { + "name": "code", + "type": "char(4)", + "primaryKey": true, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.capital_commitment": { + "name": "capital_commitment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "char(4)", + "primaryKey": false, + "notNull": true + }, + "planned_date": { + "name": "planned_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "managing_code": { + "name": "managing_code", + "type": "char(3)", + "primaryKey": false, + "notNull": false + }, + "capital_project_id": { + "name": "capital_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "budget_line_code": { + "name": "budget_line_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "budget_line_id": { + "name": "budget_line_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "capital_commitment_type_capital_commitment_type_code_fk": { + "name": "capital_commitment_type_capital_commitment_type_code_fk", + "tableFrom": "capital_commitment", + "tableTo": "capital_commitment_type", + "columnsFrom": [ + "type" + ], + "columnsTo": [ + "code" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "capital_commitment_managing_code_capital_project_id_capital_project_managing_code_id_fk": { + "name": "capital_commitment_managing_code_capital_project_id_capital_project_managing_code_id_fk", + "tableFrom": "capital_commitment", + "tableTo": "capital_project", + "columnsFrom": [ + "managing_code", + "capital_project_id" + ], + "columnsTo": [ + "managing_code", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "capital_commitment_budget_line_code_budget_line_id_budget_line_code_id_fk": { + "name": "capital_commitment_budget_line_code_budget_line_id_budget_line_code_id_fk", + "tableFrom": "capital_commitment", + "tableTo": "budget_line", + "columnsFrom": [ + "budget_line_code", + "budget_line_id" + ], + "columnsTo": [ + "code", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.capital_project_checkbook": { + "name": "capital_project_checkbook", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "managing_code": { + "name": "managing_code", + "type": "char(3)", + "primaryKey": false, + "notNull": false + }, + "capital_project_id": { + "name": "capital_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "custom_fk": { + "name": "custom_fk", + "tableFrom": "capital_project_checkbook", + "tableTo": "capital_project", + "columnsFrom": [ + "managing_code", + "capital_project_id" + ], + "columnsTo": [ + "managing_code", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.capital_project_fund": { + "name": "capital_project_fund", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "managing_code": { + "name": "managing_code", + "type": "char(3)", + "primaryKey": false, + "notNull": false + }, + "capital_project_id": { + "name": "capital_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "capital_fund_category": { + "name": "capital_fund_category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "custom_fk": { + "name": "custom_fk", + "tableFrom": "capital_project_fund", + "tableTo": "capital_project", + "columnsFrom": [ + "managing_code", + "capital_project_id" + ], + "columnsTo": [ + "managing_code", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "capital_project_fund_stage_options": { + "name": "capital_project_fund_stage_options", + "value": "\"capital_project_fund\".\"stage\" IN ('adopt', 'allocate', 'commit', 'spent')" + }, + "capital_project_fund_capital_fund_category": { + "name": "capital_project_fund_capital_fund_category", + "value": "\"capital_project_fund\".\"capital_fund_category\" IN ('city-non-exempt', 'city-exempt', 'city-cost', 'non-city-state', 'non-city-federal', 'non-city-other', 'non-city-cost', 'total')" + } + }, + "isRLSEnabled": false + }, + "public.capital_project": { + "name": "capital_project", + "schema": "", + "columns": { + "managing_code": { + "name": "managing_code", + "type": "char(3)", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "managing_agency": { + "name": "managing_agency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "min_date": { + "name": "min_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "max_date": { + "name": "max_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "li_ft_m_pnt": { + "name": "li_ft_m_pnt", + "type": "geometry(multiPoint,2263)", + "primaryKey": false, + "notNull": false + }, + "li_ft_m_poly": { + "name": "li_ft_m_poly", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": false + }, + "mercator_label": { + "name": "mercator_label", + "type": "geometry(point,3857)", + "primaryKey": false, + "notNull": false + }, + "mercator_fill_m_pnt": { + "name": "mercator_fill_m_pnt", + "type": "geometry(multiPoint,3857)", + "primaryKey": false, + "notNull": false + }, + "mercator_fill_m_poly": { + "name": "mercator_fill_m_poly", + "type": "geometry(multiPolygon,3857)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "capital_project_mercator_fill_m_poly_index": { + "name": "capital_project_mercator_fill_m_poly_index", + "columns": [ + { + "expression": "mercator_fill_m_poly", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "capital_project_mercator_fill_m_pnt_index": { + "name": "capital_project_mercator_fill_m_pnt_index", + "columns": [ + { + "expression": "mercator_fill_m_pnt", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "capital_project_li_ft_m_pnt_index": { + "name": "capital_project_li_ft_m_pnt_index", + "columns": [ + { + "expression": "li_ft_m_pnt", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "capital_project_li_ft_m_poly_index": { + "name": "capital_project_li_ft_m_poly_index", + "columns": [ + { + "expression": "li_ft_m_poly", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + } + }, + "foreignKeys": { + "capital_project_managing_code_managing_code_id_fk": { + "name": "capital_project_managing_code_managing_code_id_fk", + "tableFrom": "capital_project", + "tableTo": "managing_code", + "columnsFrom": [ + "managing_code" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "capital_project_managing_agency_agency_initials_fk": { + "name": "capital_project_managing_agency_agency_initials_fk", + "tableFrom": "capital_project", + "tableTo": "agency", + "columnsFrom": [ + "managing_agency" + ], + "columnsTo": [ + "initials" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "capital_project_managing_code_id_pk": { + "name": "capital_project_managing_code_id_pk", + "columns": [ + "managing_code", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "capital_project_category_options": { + "name": "capital_project_category_options", + "value": "\"capital_project\".\"category\" IN (\n 'Fixed Asset',\n 'Lump Sum',\n 'ITT, Vehicles, and Equipment'\n )" + } + }, + "isRLSEnabled": false + }, + "public.city_council_district": { + "name": "city_council_district", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "li_ft": { + "name": "li_ft", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": false + }, + "mercator_fill": { + "name": "mercator_fill", + "type": "geometry(multiPolygon,3857)", + "primaryKey": false, + "notNull": false + }, + "mercator_label": { + "name": "mercator_label", + "type": "geometry(point,3857)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "city_council_district_mercator_fill_index": { + "name": "city_council_district_mercator_fill_index", + "columns": [ + { + "expression": "mercator_fill", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "city_council_district_mercator_label_index": { + "name": "city_council_district_mercator_label_index", + "columns": [ + { + "expression": "mercator_label", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "city_council_district_li_ft_index": { + "name": "city_council_district_li_ft_index", + "columns": [ + { + "expression": "li_ft", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.community_district": { + "name": "community_district", + "schema": "", + "columns": { + "borough_id": { + "name": "borough_id", + "type": "char(1)", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "char(2)", + "primaryKey": false, + "notNull": true + }, + "li_ft": { + "name": "li_ft", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": false + }, + "mercator_fill": { + "name": "mercator_fill", + "type": "geometry(multiPolygon,3857)", + "primaryKey": false, + "notNull": false + }, + "mercator_label": { + "name": "mercator_label", + "type": "geometry(point,3857)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "community_district_li_ft_index": { + "name": "community_district_li_ft_index", + "columns": [ + { + "expression": "li_ft", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "community_district_mercator_fill_index": { + "name": "community_district_mercator_fill_index", + "columns": [ + { + "expression": "mercator_fill", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "community_district_mercator_label_index": { + "name": "community_district_mercator_label_index", + "columns": [ + { + "expression": "mercator_label", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + } + }, + "foreignKeys": { + "community_district_borough_id_borough_id_fk": { + "name": "community_district_borough_id_borough_id_fk", + "tableFrom": "community_district", + "tableTo": "borough", + "columnsFrom": [ + "borough_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "community_district_borough_id_id_pk": { + "name": "community_district_borough_id_id_pk", + "columns": [ + "borough_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.land_use": { + "name": "land_use", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "char(2)", + "primaryKey": true, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "char(9)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.managing_code": { + "name": "managing_code", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "char(3)", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tax_lot": { + "name": "tax_lot", + "schema": "", + "columns": { + "bbl": { + "name": "bbl", + "type": "char(10)", + "primaryKey": true, + "notNull": true + }, + "borough_id": { + "name": "borough_id", + "type": "char(1)", + "primaryKey": false, + "notNull": true + }, + "block": { + "name": "block", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lot": { + "name": "lot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "land_use_id": { + "name": "land_use_id", + "type": "char(2)", + "primaryKey": false, + "notNull": false + }, + "wgs84": { + "name": "wgs84", + "type": "geography(multiPolygon, 4326)", + "primaryKey": false, + "notNull": true + }, + "li_ft": { + "name": "li_ft", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "tax_lot_borough_id_borough_id_fk": { + "name": "tax_lot_borough_id_borough_id_fk", + "tableFrom": "tax_lot", + "tableTo": "borough", + "columnsFrom": [ + "borough_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tax_lot_land_use_id_land_use_id_fk": { + "name": "tax_lot_land_use_id_land_use_id_fk", + "tableFrom": "tax_lot", + "tableTo": "land_use", + "columnsFrom": [ + "land_use_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.zoning_district": { + "name": "zoning_district", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "wgs84": { + "name": "wgs84", + "type": "geography(multiPolygon, 4326)", + "primaryKey": false, + "notNull": true + }, + "li_ft": { + "name": "li_ft", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.zoning_district_class": { + "name": "zoning_district_class", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "category": { + "name": "category", + "type": "category", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "char(9)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.zoning_district_zoning_district_class": { + "name": "zoning_district_zoning_district_class", + "schema": "", + "columns": { + "zoning_district_id": { + "name": "zoning_district_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "zoning_district_class_id": { + "name": "zoning_district_class_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "zoning_district_zoning_district_class_zoning_district_id_zoning_district_id_fk": { + "name": "zoning_district_zoning_district_class_zoning_district_id_zoning_district_id_fk", + "tableFrom": "zoning_district_zoning_district_class", + "tableTo": "zoning_district", + "columnsFrom": [ + "zoning_district_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "zoning_district_zoning_district_class_zoning_district_class_id_zoning_district_class_id_fk": { + "name": "zoning_district_zoning_district_class_zoning_district_class_id_zoning_district_class_id_fk", + "tableFrom": "zoning_district_zoning_district_class", + "tableTo": "zoning_district_class", + "columnsFrom": [ + "zoning_district_class_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.category": { + "name": "category", + "schema": "public", + "values": [ + "Residential", + "Commercial", + "Manufacturing" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/db/migration/meta/_journal.json b/db/migration/meta/_journal.json index 2e55877..ceeb230 100644 --- a/db/migration/meta/_journal.json +++ b/db/migration/meta/_journal.json @@ -148,6 +148,13 @@ "when": 1733925963262, "tag": "0020_overjoyed_swordsman", "breakpoints": true + }, + { + "idx": 21, + "version": "7", + "when": 1733929910053, + "tag": "0021_dry_skreet", + "breakpoints": true } ] } \ No newline at end of file diff --git a/openapi/components/schemas/CapitalProject.yaml b/openapi/components/schemas/CapitalProject.yaml index d7c8c4f..07a21eb 100644 --- a/openapi/components/schemas/CapitalProject.yaml +++ b/openapi/components/schemas/CapitalProject.yaml @@ -29,6 +29,9 @@ properties: format: date description: The ending date of the capital project example: '2024-05-15' + category: + $ref: ./CapitalProjectCategory.yaml + nullable: true required: - id - description @@ -36,3 +39,4 @@ required: - managingAgency - minDate - maxDate + - category diff --git a/openapi/components/schemas/CapitalProjectCategory.yaml b/openapi/components/schemas/CapitalProjectCategory.yaml index 3bf9ee5..7b8bb55 100644 --- a/openapi/components/schemas/CapitalProjectCategory.yaml +++ b/openapi/components/schemas/CapitalProjectCategory.yaml @@ -3,6 +3,6 @@ nullable: true enum: - Fixed Asset - Lump Sum - - ITT, Vehicles and Equipment + - ITT, Vehicles, and Equipment - null description: The type of Capital Project. diff --git a/src/borough/borough.repository.ts b/src/borough/borough.repository.ts index 5b98651..109015b 100644 --- a/src/borough/borough.repository.ts +++ b/src/borough/borough.repository.ts @@ -12,6 +12,7 @@ import { import { capitalProject, communityDistrict } from "src/schema"; import { eq, sql, and, isNotNull, asc } from "drizzle-orm"; import { + CapitalProjectCategory, FindCapitalProjectTilesByBoroughIdCommunityDistrictIdPathParams, FindCommunityDistrictGeoJsonByBoroughIdCommunityDistrictIdPathParams, } from "src/gen"; @@ -115,6 +116,7 @@ export class BoroughRepository { managingAgency: capitalProject.managingAgency, maxDate: capitalProject.maxDate, minDate: capitalProject.minDate, + category: sql`${capitalProject.category}`, }) .from(capitalProject) .leftJoin( diff --git a/src/capital-project/capital-project.repository.ts b/src/capital-project/capital-project.repository.ts index 1838c26..c08ae6c 100644 --- a/src/capital-project/capital-project.repository.ts +++ b/src/capital-project/capital-project.repository.ts @@ -2,6 +2,7 @@ import { Inject } from "@nestjs/common"; import { isNotNull, sql, and, eq, sum, asc } from "drizzle-orm"; import { DataRetrievalException } from "src/exception"; import { + CapitalProjectCategory, FindCapitalCommitmentsByManagingCodeCapitalProjectIdPathParams, FindCapitalProjectByManagingCodeCapitalProjectIdPathParams, FindCapitalProjectGeoJsonByManagingCodeCapitalProjectIdPathParams, @@ -66,6 +67,7 @@ export class CapitalProjectRepository { managingAgency: capitalProject.managingAgency, minDate: capitalProject.minDate, maxDate: capitalProject.maxDate, + category: sql`${capitalProject.category}`, sponsoringAgencies: sql< Array >`ARRAY_AGG(DISTINCT ${agencyBudget.sponsor})`, @@ -117,6 +119,7 @@ export class CapitalProjectRepository { managingAgency: capitalProject.managingAgency, minDate: capitalProject.minDate, maxDate: capitalProject.maxDate, + category: sql`${capitalProject.category}`, sponsoringAgencies: sql< Array >`ARRAY_AGG(DISTINCT ${agencyBudget.sponsor})`, diff --git a/src/city-council-district/city-council-district.repository.ts b/src/city-council-district/city-council-district.repository.ts index 9d727d3..aa3fb2e 100644 --- a/src/city-council-district/city-council-district.repository.ts +++ b/src/city-council-district/city-council-district.repository.ts @@ -10,6 +10,7 @@ import { FindCapitalProjectTilesByCityCouncilDistrictIdRepo, } from "./city-council-district.repository.schema"; import { + CapitalProjectCategory, FindCapitalProjectTilesByCityCouncilDistrictIdPathParams, FindCityCouncilDistrictGeoJsonByCityCouncilDistrictIdPathParams, FindCityCouncilDistrictTilesPathParams, @@ -212,6 +213,7 @@ export class CityCouncilDistrictRepository { managingAgency: capitalProject.managingAgency, maxDate: capitalProject.maxDate, minDate: capitalProject.minDate, + category: sql`${capitalProject.category}`, }) .from(capitalProject) .leftJoin( diff --git a/src/gen/schemas/CapitalProject.json b/src/gen/schemas/CapitalProject.json index 5df3c7a..6744edd 100644 --- a/src/gen/schemas/CapitalProject.json +++ b/src/gen/schemas/CapitalProject.json @@ -33,6 +33,13 @@ "format": "date", "description": "The ending date of the capital project", "example": "2024-05-15" + }, + "category": { + "nullable": true, + "type": "string", + "enum": ["Fixed Asset", "Lump Sum", "ITT, Vehicles, and Equipment", null], + "description": "The type of Capital Project.", + "x-readme-ref-name": "CapitalProjectCategory" } }, "required": [ @@ -41,7 +48,8 @@ "managingCode", "managingAgency", "minDate", - "maxDate" + "maxDate", + "category" ], "x-readme-ref-name": "CapitalProject" } diff --git a/src/gen/schemas/CapitalProjectBudgeted.json b/src/gen/schemas/CapitalProjectBudgeted.json index cd1a55e..edba5a6 100644 --- a/src/gen/schemas/CapitalProjectBudgeted.json +++ b/src/gen/schemas/CapitalProjectBudgeted.json @@ -35,6 +35,18 @@ "format": "date", "description": "The ending date of the capital project", "example": "2024-05-15" + }, + "category": { + "nullable": true, + "type": "string", + "enum": [ + "Fixed Asset", + "Lump Sum", + "ITT, Vehicles, and Equipment", + null + ], + "description": "The type of Capital Project.", + "x-readme-ref-name": "CapitalProjectCategory" } }, "required": [ @@ -43,7 +55,8 @@ "managingCode", "managingAgency", "minDate", - "maxDate" + "maxDate", + "category" ], "x-readme-ref-name": "CapitalProject" }, diff --git a/src/gen/schemas/CapitalProjectBudgetedGeoJson.json b/src/gen/schemas/CapitalProjectBudgetedGeoJson.json index 3aa6c69..3d1266d 100644 --- a/src/gen/schemas/CapitalProjectBudgetedGeoJson.json +++ b/src/gen/schemas/CapitalProjectBudgetedGeoJson.json @@ -98,6 +98,18 @@ "format": "date", "description": "The ending date of the capital project", "example": "2024-05-15" + }, + "category": { + "nullable": true, + "type": "string", + "enum": [ + "Fixed Asset", + "Lump Sum", + "ITT, Vehicles, and Equipment", + null + ], + "description": "The type of Capital Project.", + "x-readme-ref-name": "CapitalProjectCategory" } }, "required": [ @@ -106,7 +118,8 @@ "managingCode", "managingAgency", "minDate", - "maxDate" + "maxDate", + "category" ], "x-readme-ref-name": "CapitalProject" }, diff --git a/src/gen/schemas/CapitalProjectCategory.json b/src/gen/schemas/CapitalProjectCategory.json index 6a8d95e..0203c07 100644 --- a/src/gen/schemas/CapitalProjectCategory.json +++ b/src/gen/schemas/CapitalProjectCategory.json @@ -1,7 +1,7 @@ { - "description": "The type of Capital Project.", "type": "string", - "enum": ["Fixed Asset", "Lump Sum", "ITT, Vehicles and Equipment", null], "nullable": true, + "enum": ["Fixed Asset", "Lump Sum", "ITT, Vehicles, and Equipment", null], + "description": "The type of Capital Project.", "x-readme-ref-name": "CapitalProjectCategory" } diff --git a/src/gen/schemas/CapitalProjectPage.json b/src/gen/schemas/CapitalProjectPage.json index 11c12bf..37d1f03 100644 --- a/src/gen/schemas/CapitalProjectPage.json +++ b/src/gen/schemas/CapitalProjectPage.json @@ -71,6 +71,18 @@ "format": "date", "description": "The ending date of the capital project", "example": "2024-05-15" + }, + "category": { + "nullable": true, + "type": "string", + "enum": [ + "Fixed Asset", + "Lump Sum", + "ITT, Vehicles, and Equipment", + null + ], + "description": "The type of Capital Project.", + "x-readme-ref-name": "CapitalProjectCategory" } }, "required": [ @@ -79,7 +91,8 @@ "managingCode", "managingAgency", "minDate", - "maxDate" + "maxDate", + "category" ], "x-readme-ref-name": "CapitalProject" } diff --git a/src/gen/types/CapitalProject.ts b/src/gen/types/CapitalProject.ts index 52abc33..5828d8a 100644 --- a/src/gen/types/CapitalProject.ts +++ b/src/gen/types/CapitalProject.ts @@ -1,3 +1,5 @@ +import type { CapitalProjectCategory } from "./CapitalProjectCategory"; + export type CapitalProject = { /** * @description The id for the project, which combines with the managing code to make a unique id @@ -29,4 +31,8 @@ export type CapitalProject = { * @type string, date */ maxDate: string; + /** + * @type string + */ + category: CapitalProjectCategory | null; }; diff --git a/src/gen/types/CapitalProjectCategory.ts b/src/gen/types/CapitalProjectCategory.ts index c02be79..19e5933 100644 --- a/src/gen/types/CapitalProjectCategory.ts +++ b/src/gen/types/CapitalProjectCategory.ts @@ -1,7 +1,7 @@ export const capitalProjectCategory = { "Fixed Asset": "Fixed Asset", "Lump Sum": "Lump Sum", - "ITT, Vehicles and Equipment": "ITT, Vehicles and Equipment", + "ITT, Vehicles, and Equipment": "ITT, Vehicles, and Equipment", } as const; export type CapitalProjectCategory = (typeof capitalProjectCategory)[keyof typeof capitalProjectCategory]; diff --git a/src/gen/zod/capitalProjectCategorySchema.ts b/src/gen/zod/capitalProjectCategorySchema.ts index 605e50e..c4b61d7 100644 --- a/src/gen/zod/capitalProjectCategorySchema.ts +++ b/src/gen/zod/capitalProjectCategorySchema.ts @@ -4,6 +4,6 @@ import { z } from "zod"; * @description The type of Capital Project. */ export const capitalProjectCategorySchema = z - .enum(["Fixed Asset", "Lump Sum", "ITT, Vehicles and Equipment"]) + .enum(["Fixed Asset", "Lump Sum", "ITT, Vehicles, and Equipment"]) .describe("The type of Capital Project.") .nullable(); diff --git a/src/gen/zod/capitalProjectSchema.ts b/src/gen/zod/capitalProjectSchema.ts index 5eb7263..536314a 100644 --- a/src/gen/zod/capitalProjectSchema.ts +++ b/src/gen/zod/capitalProjectSchema.ts @@ -1,3 +1,4 @@ +import { capitalProjectCategorySchema } from "./capitalProjectCategorySchema"; import { z } from "zod"; export const capitalProjectSchema = z.object({ @@ -19,4 +20,5 @@ export const capitalProjectSchema = z.object({ .date() .describe("The starting date of the capital project"), maxDate: z.string().date().describe("The ending date of the capital project"), + category: z.lazy(() => capitalProjectCategorySchema).nullable(), }); diff --git a/src/schema/capital-project.ts b/src/schema/capital-project.ts index 3f3685f..fefab2d 100644 --- a/src/schema/capital-project.ts +++ b/src/schema/capital-project.ts @@ -5,11 +5,14 @@ import { text, date, primaryKey, + check, } from "drizzle-orm/pg-core"; import { managingCode, managingCodeEntitySchema } from "./managing-code"; import { agency, agencyEntitySchema } from "./agency"; import { z } from "zod"; import { multiPointGeom, multiPolygonGeom, pointGeom } from "src/drizzle-pgis"; +import { sql } from "drizzle-orm"; +import { capitalProjectCategorySchema } from "src/gen"; export const capitalProject = pgTable( "capital_project", @@ -24,6 +27,7 @@ export const capitalProject = pgTable( description: text("description").notNull(), minDate: date("min_date").notNull(), maxDate: date("max_date").notNull(), + category: text("category"), liFtMPnt: multiPointGeom("li_ft_m_pnt", 2263), liFtMPoly: multiPolygonGeom("li_ft_m_poly", 2263), mercatorLabel: pointGeom("mercator_label", 3857), @@ -36,15 +40,17 @@ export const capitalProject = pgTable( index().using("GIST", table.mercatorFillMPnt), index().using("GIST", table.liFtMPnt), index().using("GIST", table.liFtMPoly), + check( + "capital_project_category_options", + sql`${table.category} IN ( + 'Fixed Asset', + 'Lump Sum', + 'ITT, Vehicles, and Equipment' + )`, + ), ], ); -export const capitalProjectCategoryEnumSchema = z.enum([ - "Fixed Asset", - "Lump Sum", - "ITT, Vehicles and Equipment", -]); - export const capitalProjectEntitySchema = z.object({ managingCode: managingCodeEntitySchema.shape.id, id: z.string(), @@ -52,4 +58,5 @@ export const capitalProjectEntitySchema = z.object({ description: z.string(), minDate: z.string().date(), maxDate: z.string().date(), + category: capitalProjectCategorySchema, });