diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..0cd1891 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +DATABASE_URL="postgresql://postgres:postgres@localhost:5432/cic_graph?schema=public" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b3d775c --- /dev/null +++ b/.gitignore @@ -0,0 +1,128 @@ +.env +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.* +!.env.example + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# vitepress build output +**/.vitepress/dist + +# vitepress cache directory +**/.vitepress/cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 8949f33..0000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM hasura/graphql-engine:v2.20.0.cli-migrations-v3 as base - -RUN curl -L https://github.com/jackc/tern/releases/download/v2.0.1/tern_2.0.1_linux_amd64.tar.gz > tern.tar.gz && \ - tar xzvf tern.tar.gz && \ - chmod +x tern && \ - mv tern /bin - -WORKDIR /service - -COPY migrations migrations/ -COPY metadata metadata/ -COPY LICENSE . - -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - -EXPOSE 8080 - -ENTRYPOINT ["/entrypoint.sh"] - -CMD $HGE_BINARY serve \ No newline at end of file diff --git a/README.md b/README.md index 938c04f..7d5fcae 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,39 @@ # cic-graph -![GitHub release (latest by date)](https://img.shields.io/github/v/tag/grassrootseconomics/cic-graph) -> CIC Graph -Central CIC Stack Postgres store specifically for indexing: -- Transactional data from the chain -- Custodial user data (PII, custodial client data) -- Voucher data (backers, certifications, e.t.c.) -- VPAs (Virtual Payment Addresses) -- Marketplace data (proposed) +## Dev +### Docker +To run the application in a Docker container, you can use the following command: -Relationships, check constraints and referential integrity are built in at the Postgres level. However, CIC Graph is meant to be complemented by secondary backend services to provide CRUD and any other important functionality around it. +```bash +cd dev +docker compose up +``` +### Install dependencies -Primarily **Hasura** is supported as a GraphQL proxy backend infront of it. Aditionally, other 3rd party proxies such as **Supabase** and **PostgREST** are expected to work on top of the Postgres schema defined in `migrations`. +```bash +pnpm install +``` -## Hasura Development -**Prerequisites** +### Development -- Docker and Docker Compose (latest) -- [tern](https://github.com/jackc/tern) -- [hasura CLI](https://hasura.io/docs/latest/hasura-cli/install-hasura-cli/) +Testing new schema designs or modifications in a local development environment +```bash +pnpm drizzle-kit push +``` -Hasura expects a metadata definition consistent with the underlying Postgres schema. -For ease of testing and development, a Docker image which bakes in the migrations and metadata files is provided (`Dockerfile`). The `dev` folder also contains a docker-compose.yaml file to quickly get started. +#### Migrations +To generate a new migration, you can use the following command: -Below is an exmaple of how to add a table and sync the git repo with the changes. +```bash +pnpm drizzle-kit generate +``` -### Adding a new table - -1. Bring up the containers in `dev` with `docker-compose up -d`. -2. Start the Hasura Console with `hasura console --admin-secret "admin" --endpoint http://localhost:8080`. -3. In the `migrations` folder, run `tern new $MIGRATION_NAME` and write the migration file. -4. Run the migration inside Hasura in the Data manager tab, checking "Track This", "Cascade metadata" and "This is a migration" -5. Run `hasura metadata export --admin-secret "admin" --endpoint http://localhost:8080` to sync the metadata. -7. Git commit. - - -## License - -[AGPL-3.0](LICENSE). +Apply Migration +```bash +pnpm drizzle-kit migrate +``` diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index 9fb536e..b243d41 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -15,24 +15,8 @@ services: timeout: 5s retries: 5 ports: - - '5432:5432' - hasura: - image: ghcr.io/grassrootseconomics/cic-graph/cic-graph:latest - restart: unless-stopped - depends_on: - postgres: - condition: service_healthy - environment: - HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgres@postgres:5432/cic_graph - PG_DATABASE_URL: postgres://postgres:postgres@postgres:5432/cic_graph - HASURA_GRAPHQL_ENABLE_CONSOLE: "true" - HASURA_GRAPHQL_ADMIN_SECRET: admin - HASURA_GRAPHQL_UNAUTHORIZED_ROLE: anonymous - HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log - HASURA_GRAPHQL_DEV_MODE: "true" - ports: - - '8080:8080' + - "5432:5432" + volumes: cic-graph-pg: driver: local - \ No newline at end of file diff --git a/drizzle.config.ts b/drizzle.config.ts new file mode 100644 index 0000000..9a89c4f --- /dev/null +++ b/drizzle.config.ts @@ -0,0 +1,18 @@ +// drizzle.config.ts + +import { config } from "dotenv"; +import { defineConfig } from "drizzle-kit"; + +config(); + +export default defineConfig({ + out: './drizzle', + schema: './src/db/schema.ts', + dialect: 'postgresql', + dbCredentials: { + url: process.env.DATABASE_URL as string, + }, + verbose: true, + // Always ask for confirmation + strict: true, +}); diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index ca0e018..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -set -e - -PG_DATABASE_URL=${PG_DATABASE_URL:-postgres://postgres:postgres@postgres:5432/cic_graph} -/bin/tern migrate --migrations /service/migrations --config /service/migrations/tern.conf - -log() { - TIMESTAMP=$(date -u "+%Y-%m-%dT%H:%M:%S.000+0000") - LOGKIND=$1 - MESSAGE=$2 - echo "{\"timestamp\":\"$TIMESTAMP\",\"level\":\"info\",\"type\":\"startup\",\"detail\":{\"kind\":\"$LOGKIND\",\"info\":\"$MESSAGE\"}}" -} - -DEFAULT_METADATA_DIR="/service/metadata" -TEMP_PROJECT_DIR="/tmp/hasura-project" - -if [ -z ${HGE_BINARY+x} ]; then - log "migrations-startup" "validation failed: expected HGE_BINARY environment variable to be set" - exit 1 -fi - -# Use 9691 port for running temporary instance. -# In case 9691 is occupied (according to docker networking), then this will fail. -# override with another port in that case -# TODO: Find a proper random port -if [ -z ${HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT+x} ]; then - log "migrations-startup" "migrations server port env var is not set, defaulting to 9691" - HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT=9691 -fi - -if [ -z ${HASURA_GRAPHQL_MIGRATIONS_SERVER_TIMEOUT+x} ]; then - log "migrations-startup" "server timeout is not set, defaulting to 30 seconds" - HASURA_GRAPHQL_MIGRATIONS_SERVER_TIMEOUT=30 -fi - -# wait for a port to be ready -wait_for_port() { - local PORT=$1 - log "migrations-startup" "waiting $HASURA_GRAPHQL_MIGRATIONS_SERVER_TIMEOUT for $PORT to be ready" - for _ in $(seq 1 $HASURA_GRAPHQL_MIGRATIONS_SERVER_TIMEOUT); - do - nc -z localhost "$PORT" > /dev/null 2>&1 && log "migrations-startup" "port $PORT is ready" && return - sleep 1 - done - log "migrations-startup" "failed waiting for $PORT, try increasing HASURA_GRAPHQL_MIGRATIONS_SERVER_TIMEOUT (default: 30)" && exit 1 -} - -log "migrations-startup" "starting graphql engine temporarily on port $HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT" - -# start graphql engine with metadata api enabled -$HGE_BINARY serve --enabled-apis="metadata" \ - --server-port=${HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT} & -# store the pid to kill it later -PID=$! - -# wait for port to be ready -wait_for_port $HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT - -# check if metadata directory is set, default otherwise -if [ -z ${HASURA_GRAPHQL_METADATA_DIR+x} ]; then - log "migrations-startup" "env var HASURA_GRAPHQL_METADATA_DIR is not set, defaulting to $DEFAULT_METADATA_DIR" - HASURA_GRAPHQL_METADATA_DIR="$DEFAULT_METADATA_DIR" -fi - -# apply metadata if the directory exist -if [ -d "$HASURA_GRAPHQL_METADATA_DIR" ]; then - rm -rf "TEMP_PROJECT_DIR" - log "migrations-apply" "applying metadata from $HASURA_GRAPHQL_METADATA_DIR" - mkdir -p "$TEMP_PROJECT_DIR" - cp -a "$HASURA_GRAPHQL_METADATA_DIR/." "$TEMP_PROJECT_DIR/metadata/" - cd "$TEMP_PROJECT_DIR" - echo "version: 3" > config.yaml - echo "endpoint: http://localhost:$HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT" >> config.yaml - echo "metadata_directory: metadata" >> config.yaml - hasura-cli metadata apply -else - log "migrations-apply" "directory $HASURA_GRAPHQL_METADATA_DIR does not exist, skipping metadata" -fi - -# kill graphql engine that we started earlier -log "migrations-shutdown" "killing temporary server" -kill $PID - -# pass control to CMD -log "migrations-shutdown" "graphql-engine will now start in normal mode" -exec "$@" \ No newline at end of file diff --git a/metadata/actions.graphql b/metadata/actions.graphql deleted file mode 100644 index e69de29..0000000 diff --git a/metadata/actions.yaml b/metadata/actions.yaml deleted file mode 100644 index 1edb4c2..0000000 --- a/metadata/actions.yaml +++ /dev/null @@ -1,6 +0,0 @@ -actions: [] -custom_types: - enums: [] - input_objects: [] - objects: [] - scalars: [] diff --git a/metadata/allow_list.yaml b/metadata/allow_list.yaml deleted file mode 100644 index fe51488..0000000 --- a/metadata/allow_list.yaml +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/metadata/api_limits.yaml b/metadata/api_limits.yaml deleted file mode 100644 index 0967ef4..0000000 --- a/metadata/api_limits.yaml +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/metadata/backend_configs.yaml b/metadata/backend_configs.yaml deleted file mode 100644 index 0967ef4..0000000 --- a/metadata/backend_configs.yaml +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/metadata/cron_triggers.yaml b/metadata/cron_triggers.yaml deleted file mode 100644 index fe51488..0000000 --- a/metadata/cron_triggers.yaml +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/metadata/databases/cic_graph/tables/public_account_role_type.yaml b/metadata/databases/cic_graph/tables/public_account_role_type.yaml deleted file mode 100644 index 4de9c1b..0000000 --- a/metadata/databases/cic_graph/tables/public_account_role_type.yaml +++ /dev/null @@ -1,12 +0,0 @@ -table: - name: account_role_type - schema: public -is_enum: true -array_relationships: - - name: accounts - using: - foreign_key_constraint_on: - column: account_role - table: - name: accounts - schema: public diff --git a/metadata/databases/cic_graph/tables/public_account_type.yaml b/metadata/databases/cic_graph/tables/public_account_type.yaml deleted file mode 100644 index 7a7a942..0000000 --- a/metadata/databases/cic_graph/tables/public_account_type.yaml +++ /dev/null @@ -1,12 +0,0 @@ -table: - name: account_type - schema: public -is_enum: true -array_relationships: - - name: accounts - using: - foreign_key_constraint_on: - column: account_type - table: - name: accounts - schema: public diff --git a/metadata/databases/cic_graph/tables/public_accounts.yaml b/metadata/databases/cic_graph/tables/public_accounts.yaml deleted file mode 100644 index 5d8c220..0000000 --- a/metadata/databases/cic_graph/tables/public_accounts.yaml +++ /dev/null @@ -1,124 +0,0 @@ -table: - name: accounts - schema: public -object_relationships: - - name: accountTypeByAccountType - using: - foreign_key_constraint_on: account_type - - name: account_role_type - using: - foreign_key_constraint_on: account_role - - name: marketplace - using: - foreign_key_constraint_on: - column: account - table: - name: marketplaces - schema: public - - name: user - using: - foreign_key_constraint_on: user_identifier -array_relationships: - - name: commodity_listings - using: - foreign_key_constraint_on: - column: account - table: - name: product_listings - schema: public - - name: voucher_backers - using: - foreign_key_constraint_on: - column: backer - table: - name: voucher_issuers - schema: public - - name: voucher_certifications - using: - foreign_key_constraint_on: - column: certifier - table: - name: voucher_certifications - schema: public - - name: vpas - using: - foreign_key_constraint_on: - column: linked_account - table: - name: vpa - schema: public -insert_permissions: - - role: anonymous - permission: - check: {} - columns: - - account_type - - blockchain_address - - user_identifier - - role: backend - permission: - check: {} - columns: - - account_type - - blockchain_address - - created_at - - user_identifier - - role: user - permission: - check: - user_identifier: - _eq: X-Hasura-User-Id - set: - account_type: x-hasura-User-Id - user_identifier: x-hasura-User-Id - columns: - - account_type - - blockchain_address -select_permissions: - - role: backend - permission: - columns: - - id - - user_identifier - - account_type - - blockchain_address - - created_at - filter: {} - - role: user - permission: - columns: - - account_type - - blockchain_address - - created_at - - id - filter: - user_identifier: - _eq: X-Hasura-User-Id - limit: 250 -update_permissions: - - role: backend - permission: - columns: - - account_type - - blockchain_address - - created_at - - user_identifier - filter: {} - check: {} - - role: user - permission: - columns: - - account_type - - blockchain_address - filter: - user_identifier: - _eq: X-Hasura-User-Id - check: - user_identifier: - _eq: X-Hasura-User-Id - set: - user_identifier: x-hasura-User-Id -delete_permissions: - - role: backend - permission: - filter: {} diff --git a/metadata/databases/cic_graph/tables/public_commodity_listings.yaml b/metadata/databases/cic_graph/tables/public_commodity_listings.yaml deleted file mode 100644 index c6395ce..0000000 --- a/metadata/databases/cic_graph/tables/public_commodity_listings.yaml +++ /dev/null @@ -1,13 +0,0 @@ -table: - name: commodity_listings - schema: public -object_relationships: - - name: accountByAccount - using: - foreign_key_constraint_on: account - - name: commodityTypeByCommodityType - using: - foreign_key_constraint_on: commodity_type - - name: voucherByVoucher - using: - foreign_key_constraint_on: voucher diff --git a/metadata/databases/cic_graph/tables/public_commodity_type.yaml b/metadata/databases/cic_graph/tables/public_commodity_type.yaml deleted file mode 100644 index 4e7c04b..0000000 --- a/metadata/databases/cic_graph/tables/public_commodity_type.yaml +++ /dev/null @@ -1,12 +0,0 @@ -table: - name: commodity_type - schema: public -is_enum: true -array_relationships: - - name: commodity_listings - using: - foreign_key_constraint_on: - column: commodity_type - table: - name: product_listings - schema: public diff --git a/metadata/databases/cic_graph/tables/public_gas_gift_status_type.yaml b/metadata/databases/cic_graph/tables/public_gas_gift_status_type.yaml deleted file mode 100644 index 6ec0746..0000000 --- a/metadata/databases/cic_graph/tables/public_gas_gift_status_type.yaml +++ /dev/null @@ -1,4 +0,0 @@ -table: - name: gas_gift_status_type - schema: public -is_enum: true diff --git a/metadata/databases/cic_graph/tables/public_gender_type.yaml b/metadata/databases/cic_graph/tables/public_gender_type.yaml deleted file mode 100644 index 92b4ca5..0000000 --- a/metadata/databases/cic_graph/tables/public_gender_type.yaml +++ /dev/null @@ -1,12 +0,0 @@ -table: - name: gender_type - schema: public -is_enum: true -array_relationships: - - name: personal_informations - using: - foreign_key_constraint_on: - column: gender - table: - name: personal_information - schema: public diff --git a/metadata/databases/cic_graph/tables/public_interface_type.yaml b/metadata/databases/cic_graph/tables/public_interface_type.yaml deleted file mode 100644 index e86e7c9..0000000 --- a/metadata/databases/cic_graph/tables/public_interface_type.yaml +++ /dev/null @@ -1,12 +0,0 @@ -table: - name: interface_type - schema: public -is_enum: true -array_relationships: - - name: users - using: - foreign_key_constraint_on: - column: interface_type - table: - name: users - schema: public diff --git a/metadata/databases/cic_graph/tables/public_marketplaces.yaml b/metadata/databases/cic_graph/tables/public_marketplaces.yaml deleted file mode 100644 index 850c2ea..0000000 --- a/metadata/databases/cic_graph/tables/public_marketplaces.yaml +++ /dev/null @@ -1,50 +0,0 @@ -table: - name: marketplaces - schema: public -object_relationships: - - name: accountByAccount - using: - foreign_key_constraint_on: account -insert_permissions: - - role: user - permission: - check: - account: - _eq: X-Hasura-Account-Id - set: - account: x-hasura-Account-Id - columns: - - created_at - - marketplace_name -select_permissions: - - role: anonymous - permission: - columns: - - account - - created_at - - id - - marketplace_name - filter: {} - limit: 100 - - role: user - permission: - columns: - - account - - id - - marketplace_name - - created_at - filter: {} - limit: 250 -update_permissions: - - role: user - permission: - columns: - - marketplace_name - filter: - account: - _eq: X-Hasura-Account-Id - check: - account: - _eq: X-Hasura-Account-Id - set: - account: x-hasura-Account-Id diff --git a/metadata/databases/cic_graph/tables/public_personal_information.yaml b/metadata/databases/cic_graph/tables/public_personal_information.yaml deleted file mode 100644 index 41a7c64..0000000 --- a/metadata/databases/cic_graph/tables/public_personal_information.yaml +++ /dev/null @@ -1,54 +0,0 @@ -table: - name: personal_information - schema: public -object_relationships: - - name: gender_type - using: - foreign_key_constraint_on: gender - - name: user - using: - foreign_key_constraint_on: user_identifier -insert_permissions: - - role: user - permission: - check: - user_identifier: - _eq: X-Hasura-User-Id - set: - user_identifier: x-hasura-User-Id - columns: - - family_name - - gender - - given_names - - location_name - - year_of_birth -select_permissions: - - role: user - permission: - columns: - - user_identifier - - year_of_birth - - geo - - family_name - - gender - - given_names - - location_name - filter: - user_identifier: - _eq: X-Hasura-User-Id - limit: 1 -update_permissions: - - role: user - permission: - columns: - - family_name - - gender - - given_names - - location_name - - year_of_birth - filter: - user_identifier: - _eq: X-Hasura-User-Id - check: null - set: - user_identifier: x-hasura-User-Id diff --git a/metadata/databases/cic_graph/tables/public_product_listings.yaml b/metadata/databases/cic_graph/tables/public_product_listings.yaml deleted file mode 100644 index ea8dded..0000000 --- a/metadata/databases/cic_graph/tables/public_product_listings.yaml +++ /dev/null @@ -1,13 +0,0 @@ -table: - name: product_listings - schema: public -object_relationships: - - name: accountByAccount - using: - foreign_key_constraint_on: account - - name: commodityTypeByCommodityType - using: - foreign_key_constraint_on: commodity_type - - name: voucherByVoucher - using: - foreign_key_constraint_on: voucher diff --git a/metadata/databases/cic_graph/tables/public_service_accepted_payment.yaml b/metadata/databases/cic_graph/tables/public_service_accepted_payment.yaml deleted file mode 100644 index 8df1165..0000000 --- a/metadata/databases/cic_graph/tables/public_service_accepted_payment.yaml +++ /dev/null @@ -1,67 +0,0 @@ -table: - name: service_accepted_payment - schema: public -object_relationships: - - name: voucherByVoucher - using: - foreign_key_constraint_on: voucher -array_relationships: - - name: services - using: - foreign_key_constraint_on: - column: service_accepted_payment - table: - name: services - schema: public -insert_permissions: - - role: user - permission: - check: - services: - marketplaceByMarketplace: - account: - _eq: X-Hasura-Account-Id - columns: - - price - - voucher -select_permissions: - - role: anonymous - permission: - columns: - - id - - price - - voucher - filter: {} - limit: 100 - - role: user - permission: - columns: - - price - - voucher - filter: {} - limit: 250 - allow_aggregations: true -update_permissions: - - role: user - permission: - columns: - - price - - voucher - filter: - services: - marketplaceByMarketplace: - account: - _eq: X-Hasura-Account-Id - check: - services: - marketplaceByMarketplace: - account: - _eq: X-Hasura-Account-Id -delete_permissions: - - role: user - permission: - filter: - services: - marketplaceByMarketplace: - account: - _eq: X-Hasura-Account-Id diff --git a/metadata/databases/cic_graph/tables/public_service_type.yaml b/metadata/databases/cic_graph/tables/public_service_type.yaml deleted file mode 100644 index 7c3b888..0000000 --- a/metadata/databases/cic_graph/tables/public_service_type.yaml +++ /dev/null @@ -1,10 +0,0 @@ -table: - name: service_type - schema: public -is_enum: true -select_permissions: - - role: anonymous - permission: - columns: - - value - filter: {} diff --git a/metadata/databases/cic_graph/tables/public_services.yaml b/metadata/databases/cic_graph/tables/public_services.yaml deleted file mode 100644 index d301e9a..0000000 --- a/metadata/databases/cic_graph/tables/public_services.yaml +++ /dev/null @@ -1,96 +0,0 @@ -table: - name: services - schema: public -object_relationships: - - name: marketplaceByMarketplace - using: - foreign_key_constraint_on: marketplace - - name: serviceAcceptedPaymentByServiceAcceptedPayment - using: - foreign_key_constraint_on: service_accepted_payment - - name: serviceTypeByServiceType - using: - foreign_key_constraint_on: service_type -array_relationships: - - name: services_images - using: - foreign_key_constraint_on: - column: service_id - table: - name: services_images - schema: public - - name: services_ratings - using: - foreign_key_constraint_on: - column: service_id - table: - name: services_ratings - schema: public -insert_permissions: - - role: user - permission: - check: - marketplaceByMarketplace: - account: - _eq: X-Hasura-Account_Id - columns: - - location_name - - marketplace - - service_accepted_payment - - service_available - - service_description - - service_type -select_permissions: - - role: anonymous - permission: - columns: - - service_available - - id - - marketplace - - service_accepted_payment - - geo - - location_name - - service_description - - service_type - - created_at - filter: {} - limit: 100 - - role: user - permission: - columns: - - service_available - - id - - marketplace - - service_accepted_payment - - geo - - location_name - - service_description - - service_type - - created_at - filter: {} - limit: 250 -update_permissions: - - role: user - permission: - columns: - - location_name - - marketplace - - service_accepted_payment - - service_available - - service_description - - service_type - filter: - marketplaceByMarketplace: - account: - _eq: X-Hasura-Account_Id - check: - marketplaceByMarketplace: - account: - _eq: X-Hasura-Account_Id -delete_permissions: - - role: user - permission: - filter: - marketplaceByMarketplace: - account: - _eq: X-Hasura-Account_Id diff --git a/metadata/databases/cic_graph/tables/public_services_images.yaml b/metadata/databases/cic_graph/tables/public_services_images.yaml deleted file mode 100644 index d361ae3..0000000 --- a/metadata/databases/cic_graph/tables/public_services_images.yaml +++ /dev/null @@ -1,32 +0,0 @@ -table: - name: services_images - schema: public -object_relationships: - - name: service - using: - foreign_key_constraint_on: service_id -select_permissions: - - role: anonymous - permission: - columns: - - id - - service_id - - url_pointer - filter: {} - limit: 100 - - role: user - permission: - columns: - - id - - service_id - - url_pointer - filter: {} - limit: 250 -delete_permissions: - - role: user - permission: - filter: - service: - marketplaceByMarketplace: - account: - _eq: X-Hasura-Account-Id diff --git a/metadata/databases/cic_graph/tables/public_services_ratings.yaml b/metadata/databases/cic_graph/tables/public_services_ratings.yaml deleted file mode 100644 index c4d18a9..0000000 --- a/metadata/databases/cic_graph/tables/public_services_ratings.yaml +++ /dev/null @@ -1,61 +0,0 @@ -table: - name: services_ratings - schema: public -object_relationships: - - name: account - using: - foreign_key_constraint_on: rating_by - - name: service - using: - foreign_key_constraint_on: service_id -insert_permissions: - - role: user - permission: - check: - rating_by: - _eq: X-Hasura_Account-Id - set: - rating_by: x-hasura-Account-Id - columns: - - score - - service_id -select_permissions: - - role: anonymous - permission: - columns: - - created_at - - id - - rating_by - - score - - service_id - filter: {} - limit: 100 - - role: user - permission: - columns: - - created_at - - rating_by - - score - - service_id - filter: {} - limit: 250 -update_permissions: - - role: user - permission: - columns: - - score - - service_id - filter: - rating_by: - _eq: X-Hasura_Account-Id - check: - rating_by: - _eq: X-Hasura_Account-Id - set: - rating_by: x-hasura-Account-Id -delete_permissions: - - role: user - permission: - filter: - rating_by: - _eq: X-Hasura_Account-Id diff --git a/metadata/databases/cic_graph/tables/public_swap_pool_tags.yaml b/metadata/databases/cic_graph/tables/public_swap_pool_tags.yaml deleted file mode 100644 index b7b8640..0000000 --- a/metadata/databases/cic_graph/tables/public_swap_pool_tags.yaml +++ /dev/null @@ -1,3 +0,0 @@ -table: - name: swap_pool_tags - schema: public diff --git a/metadata/databases/cic_graph/tables/public_swap_pools.yaml b/metadata/databases/cic_graph/tables/public_swap_pools.yaml deleted file mode 100644 index 765a981..0000000 --- a/metadata/databases/cic_graph/tables/public_swap_pools.yaml +++ /dev/null @@ -1,3 +0,0 @@ -table: - name: swap_pools - schema: public diff --git a/metadata/databases/cic_graph/tables/public_tags.yaml b/metadata/databases/cic_graph/tables/public_tags.yaml deleted file mode 100644 index af58d27..0000000 --- a/metadata/databases/cic_graph/tables/public_tags.yaml +++ /dev/null @@ -1,3 +0,0 @@ -table: - name: tags - schema: public diff --git a/metadata/databases/cic_graph/tables/public_till.yaml b/metadata/databases/cic_graph/tables/public_till.yaml deleted file mode 100644 index 3c9d2ad..0000000 --- a/metadata/databases/cic_graph/tables/public_till.yaml +++ /dev/null @@ -1,7 +0,0 @@ -table: - name: till - schema: public -object_relationships: - - name: account - using: - foreign_key_constraint_on: linked_account diff --git a/metadata/databases/cic_graph/tables/public_transactions.yaml b/metadata/databases/cic_graph/tables/public_transactions.yaml deleted file mode 100644 index 12a2d65..0000000 --- a/metadata/databases/cic_graph/tables/public_transactions.yaml +++ /dev/null @@ -1,24 +0,0 @@ -table: - name: transactions - schema: public -object_relationships: - - name: txTypeByTxType - using: - foreign_key_constraint_on: tx_type - - name: voucher - using: - foreign_key_constraint_on: voucher_address -select_permissions: - - role: anonymous - permission: - columns: - - date_block - - id - - recipient_address - - sender_address - - success - - tx_hash - - tx_type - - tx_value - - voucher_address - filter: {} diff --git a/metadata/databases/cic_graph/tables/public_tx_type.yaml b/metadata/databases/cic_graph/tables/public_tx_type.yaml deleted file mode 100644 index 0e06072..0000000 --- a/metadata/databases/cic_graph/tables/public_tx_type.yaml +++ /dev/null @@ -1,12 +0,0 @@ -table: - name: tx_type - schema: public -is_enum: true -array_relationships: - - name: transactions - using: - foreign_key_constraint_on: - column: tx_type - table: - name: transactions - schema: public diff --git a/metadata/databases/cic_graph/tables/public_users.yaml b/metadata/databases/cic_graph/tables/public_users.yaml deleted file mode 100644 index 45c902c..0000000 --- a/metadata/databases/cic_graph/tables/public_users.yaml +++ /dev/null @@ -1,92 +0,0 @@ -table: - name: users - schema: public -object_relationships: - - name: interfaceTypeByInterfaceType - using: - foreign_key_constraint_on: interface_type - - name: personal_information - using: - foreign_key_constraint_on: - column: user_identifier - table: - name: personal_information - schema: public -array_relationships: - - name: accounts - using: - foreign_key_constraint_on: - column: user_identifier - table: - name: accounts - schema: public -insert_permissions: - - role: anonymous - permission: - check: {} - columns: - - interface_identifier - - interface_type - - role: backend - permission: - check: {} - columns: - - activated - - created_at - - interface_identifier - - interface_type - - role: user - permission: - check: {} - columns: - - interface_identifier - - interface_type -select_permissions: - - role: backend - permission: - columns: - - activated - - id - - interface_identifier - - interface_type - - created_at - filter: {} - - role: user - permission: - columns: - - activated - - created_at - - id - - interface_identifier - - interface_type - filter: - id: - _eq: X-Hasura-User-Id - limit: 1 -update_permissions: - - role: backend - permission: - columns: - - activated - - created_at - - interface_identifier - - interface_type - filter: {} - check: {} - - role: user - permission: - columns: - - interface_identifier - filter: - id: - _eq: X-Hasura-User-Id - check: - id: - _eq: X-Hasura-User-Id - set: - activated: "false" - id: x-hasura-User-Id -delete_permissions: - - role: backend - permission: - filter: {} diff --git a/metadata/databases/cic_graph/tables/public_voucher_backers.yaml b/metadata/databases/cic_graph/tables/public_voucher_backers.yaml deleted file mode 100644 index 3f0f8e7..0000000 --- a/metadata/databases/cic_graph/tables/public_voucher_backers.yaml +++ /dev/null @@ -1,26 +0,0 @@ -table: - name: voucher_backers - schema: public -object_relationships: - - name: account - using: - foreign_key_constraint_on: backer - - name: voucherByVoucher - using: - foreign_key_constraint_on: voucher -select_permissions: - - role: anonymous - permission: - columns: - - backer - - created_at - - voucher - filter: {} - limit: 100 - - role: user - permission: - columns: - - backer - - created_at - - voucher - filter: {} diff --git a/metadata/databases/cic_graph/tables/public_voucher_certifications.yaml b/metadata/databases/cic_graph/tables/public_voucher_certifications.yaml deleted file mode 100644 index 0db960d..0000000 --- a/metadata/databases/cic_graph/tables/public_voucher_certifications.yaml +++ /dev/null @@ -1,33 +0,0 @@ -table: - name: voucher_certifications - schema: public -object_relationships: - - name: account - using: - foreign_key_constraint_on: certifier - - name: voucherByVoucher - using: - foreign_key_constraint_on: voucher -select_permissions: - - role: anonymous - permission: - columns: - - certificate_url_pointer - - certifier - - certifier_weight - - created_at - - id - - voucher - filter: {} - limit: 100 - - role: user - permission: - columns: - - certificate_url_pointer - - certifier - - certifier_weight - - created_at - - id - - voucher - filter: {} - limit: 250 diff --git a/metadata/databases/cic_graph/tables/public_voucher_issuers.yaml b/metadata/databases/cic_graph/tables/public_voucher_issuers.yaml deleted file mode 100644 index 85a9442..0000000 --- a/metadata/databases/cic_graph/tables/public_voucher_issuers.yaml +++ /dev/null @@ -1,28 +0,0 @@ -table: - name: voucher_issuers - schema: public -object_relationships: - - name: account - using: - foreign_key_constraint_on: backer - - name: voucherByVoucher - using: - foreign_key_constraint_on: voucher -select_permissions: - - role: anonymous - permission: - columns: - - backer - - created_at - - id - - voucher - filter: {} - limit: 100 - - role: user - permission: - columns: - - backer - - created_at - - id - - voucher - filter: {} diff --git a/metadata/databases/cic_graph/tables/public_voucher_tags.yaml b/metadata/databases/cic_graph/tables/public_voucher_tags.yaml deleted file mode 100644 index 4b98051..0000000 --- a/metadata/databases/cic_graph/tables/public_voucher_tags.yaml +++ /dev/null @@ -1,3 +0,0 @@ -table: - name: voucher_tags - schema: public diff --git a/metadata/databases/cic_graph/tables/public_voucher_type.yaml b/metadata/databases/cic_graph/tables/public_voucher_type.yaml deleted file mode 100644 index d35f6a6..0000000 --- a/metadata/databases/cic_graph/tables/public_voucher_type.yaml +++ /dev/null @@ -1,11 +0,0 @@ -table: - name: voucher_type - schema: public -array_relationships: - - name: vouchers - using: - foreign_key_constraint_on: - column: voucher_type - table: - name: vouchers - schema: public diff --git a/metadata/databases/cic_graph/tables/public_vouchers.yaml b/metadata/databases/cic_graph/tables/public_vouchers.yaml deleted file mode 100644 index 27f4e97..0000000 --- a/metadata/databases/cic_graph/tables/public_vouchers.yaml +++ /dev/null @@ -1,36 +0,0 @@ -table: - name: vouchers - schema: public -object_relationships: - - name: voucherTypeByVoucherType - using: - foreign_key_constraint_on: voucher_type -array_relationships: - - name: commodity_listings - using: - foreign_key_constraint_on: - column: voucher - table: - name: product_listings - schema: public - - name: transactions - using: - foreign_key_constraint_on: - column: voucher_address - table: - name: transactions - schema: public - - name: voucher_backers - using: - foreign_key_constraint_on: - column: voucher - table: - name: voucher_issuers - schema: public - - name: voucher_certifications - using: - foreign_key_constraint_on: - column: voucher - table: - name: voucher_certifications - schema: public diff --git a/metadata/databases/cic_graph/tables/public_vpa.yaml b/metadata/databases/cic_graph/tables/public_vpa.yaml deleted file mode 100644 index 2548e8c..0000000 --- a/metadata/databases/cic_graph/tables/public_vpa.yaml +++ /dev/null @@ -1,36 +0,0 @@ -table: - name: vpa - schema: public -object_relationships: - - name: account - using: - foreign_key_constraint_on: linked_account -insert_permissions: - - role: backend - permission: - check: {} - columns: - - linked_account - - vpa -select_permissions: - - role: backend - permission: - columns: - - id - - linked_account - - vpa - - created_at - filter: {} -update_permissions: - - role: backend - permission: - columns: - - created_at - - linked_account - - vpa - filter: {} - check: {} -delete_permissions: - - role: backend - permission: - filter: {} diff --git a/metadata/databases/cic_graph/tables/tables.yaml b/metadata/databases/cic_graph/tables/tables.yaml deleted file mode 100644 index 61d653f..0000000 --- a/metadata/databases/cic_graph/tables/tables.yaml +++ /dev/null @@ -1,23 +0,0 @@ -- "!include public_account_role_type.yaml" -- "!include public_account_type.yaml" -- "!include public_accounts.yaml" -- "!include public_commodity_type.yaml" -- "!include public_gas_gift_status_type.yaml" -- "!include public_gender_type.yaml" -- "!include public_interface_type.yaml" -- "!include public_marketplaces.yaml" -- "!include public_personal_information.yaml" -- "!include public_product_listings.yaml" -- "!include public_service_type.yaml" -- "!include public_swap_pool_tags.yaml" -- "!include public_swap_pools.yaml" -- "!include public_tags.yaml" -- "!include public_transactions.yaml" -- "!include public_tx_type.yaml" -- "!include public_users.yaml" -- "!include public_voucher_certifications.yaml" -- "!include public_voucher_issuers.yaml" -- "!include public_voucher_tags.yaml" -- "!include public_voucher_type.yaml" -- "!include public_vouchers.yaml" -- "!include public_vpa.yaml" diff --git a/metadata/databases/databases.yaml b/metadata/databases/databases.yaml deleted file mode 100644 index ee8b471..0000000 --- a/metadata/databases/databases.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- name: cic_graph - kind: postgres - configuration: - connection_info: - database_url: - from_env: PG_DATABASE_URL - isolation_level: read-committed - use_prepared_statements: true - tables: "!include cic_graph/tables/tables.yaml" diff --git a/metadata/graphql_schema_introspection.yaml b/metadata/graphql_schema_introspection.yaml deleted file mode 100644 index 61a4dca..0000000 --- a/metadata/graphql_schema_introspection.yaml +++ /dev/null @@ -1 +0,0 @@ -disabled_for_roles: [] diff --git a/metadata/inherited_roles.yaml b/metadata/inherited_roles.yaml deleted file mode 100644 index fe51488..0000000 --- a/metadata/inherited_roles.yaml +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/metadata/metrics_config.yaml b/metadata/metrics_config.yaml deleted file mode 100644 index 0967ef4..0000000 --- a/metadata/metrics_config.yaml +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/metadata/network.yaml b/metadata/network.yaml deleted file mode 100644 index 0967ef4..0000000 --- a/metadata/network.yaml +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/metadata/opentelemetry.yaml b/metadata/opentelemetry.yaml deleted file mode 100644 index 0967ef4..0000000 --- a/metadata/opentelemetry.yaml +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/metadata/query_collections.yaml b/metadata/query_collections.yaml deleted file mode 100644 index fe51488..0000000 --- a/metadata/query_collections.yaml +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/metadata/remote_schemas.yaml b/metadata/remote_schemas.yaml deleted file mode 100644 index fe51488..0000000 --- a/metadata/remote_schemas.yaml +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/metadata/rest_endpoints.yaml b/metadata/rest_endpoints.yaml deleted file mode 100644 index fe51488..0000000 --- a/metadata/rest_endpoints.yaml +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/metadata/version.yaml b/metadata/version.yaml deleted file mode 100644 index 0a70aff..0000000 --- a/metadata/version.yaml +++ /dev/null @@ -1 +0,0 @@ -version: 3 diff --git a/migrations/001_init.sql b/migrations/001_init.sql deleted file mode 100644 index 6c0c434..0000000 --- a/migrations/001_init.sql +++ /dev/null @@ -1,186 +0,0 @@ --- account_type enum -CREATE TABLE IF NOT EXISTS account_type ( - value TEXT PRIMARY KEY -); -INSERT INTO account_type (value) VALUES -('CUSTODIAL_PERSONAL'), -('CUSTODIAL_BUSINESS'), -('CUSTODIAL_COMMUNITY'), -('CUSTODIAL_SYSTEM'), -('NON_CUSTODIAL_PERSONAL'), -('NON_CUSTODIAL_BUSINESS'), -('NON_CUSTODIAL_COMMUNITY'), -('NON_CUSTODIAL_SYSTEM'); - --- service_type enum -CREATE TABLE IF NOT EXISTS service_type ( - value TEXT PRIMARY KEY -); -INSERT INTO service_type (value) VALUES -('WANT'), -('OFFER'); - --- interface_type enum -CREATE TABLE IF NOT EXISTS interface_type ( - value TEXT PRIMARY KEY -); -INSERT INTO interface_type (value) VALUES -('USSD'), -('TELEGRAM'), -('APP'); - --- interface_type enum -CREATE TABLE IF NOT EXISTS gender_type ( - value TEXT PRIMARY KEY -); -INSERT INTO gender_type (value) VALUES -('MALE'), -('FEMALE'); - -CREATE TABLE IF NOT EXISTS tx_type ( - value TEXT PRIMARY KEY -); -INSERT INTO tx_type (value) VALUES -('MINT_TO'), -('TRANSFER'), -('TRANSFER_FROM'); - --- bootstrap user and voucher core tables/models - --- 'users' contains every registered user -CREATE TABLE IF NOT EXISTS users ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - interface_type TEXT REFERENCES interface_type(value) NOT NULL, - interface_identifier TEXT UNIQUE NOT NULL CHECK (interface_identifier <> '' AND char_length(interface_identifier) <= 64), - activated BOOLEAN DEFAULT false, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE TABLE IF NOT EXISTS personal_information ( - user_identifier INT REFERENCES users(id) ON DELETE CASCADE UNIQUE NOT NULL, - year_of_birth INT NULL CHECK (year_of_birth >= 1900 AND year_of_birth < 2100), - gender TEXT REFERENCES gender_type(value), - family_name TEXT NULL CHECK (family_name <> '' AND char_length(family_name) <= 64), - given_names TEXT NULL CHECK (given_names <> '' AND char_length(given_names) <= 64), - location_name TEXT NULL CHECK (location_name <> '' AND char_length(location_name) <= 64), - geo POINT -); - --- every user can have multiple accounts -CREATE TABLE IF NOT EXISTS accounts ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - user_identifier INT REFERENCES users(id) ON DELETE CASCADE NOT NULL, - account_type TEXT REFERENCES account_type(value) NOT NULL, - blockchain_address TEXT UNIQUE NOT NULL CHECK (blockchain_address <> '' AND char_length(blockchain_address) <= 42), - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- every account can have a unique market place -CREATE TABLE IF NOT EXISTS marketplaces ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - account INT REFERENCES accounts(id) UNIQUE NOT NULL, - marketplace_name TEXT NOT NULL CHECK (marketplace_name <> '' AND char_length(marketplace_name) <= 64), - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- vouchers created on sarafu network -CREATE TABLE IF NOT EXISTS vouchers ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - voucher_address TEXT NOT NULL UNIQUE CHECK (voucher_address <> '' AND char_length(voucher_address) <= 42), - symbol TEXT NOT NULL CHECK (symbol <> '' AND char_length(symbol) <= 8), - voucher_name TEXT NOT NULL CHECK (voucher_name <> '' AND char_length(voucher_name) <= 64), - voucher_description TEXT NOT NULL CHECK (voucher_description <> '' AND char_length(voucher_description) <= 256), - demurrage_rate NUMERIC NOT NULL CHECK (demurrage_rate > 0), - sink_address TEXT NOT NULL CHECK (voucher_address <> '' AND char_length(voucher_address) <= 42), - supply INT NOT NULL CHECK (supply > 0), - active BOOLEAN DEFAULT true, - location_name TEXT NULL CHECK (location_name <> '' AND char_length(location_name) <= 64), - geo POINT, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- voucher issuers is the group of people (1 - n) who back a certain voucher -CREATE TABLE IF NOT EXISTS voucher_backers ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - voucher INT REFERENCES vouchers(id) NOT NULL, - backer INT REFERENCES accounts(id) NOT NULL, - active BOOLEAN DEFAULT true, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- voucher audit/certifier related info -CREATE TABLE IF NOT EXISTS voucher_certifications ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - voucher INT REFERENCES vouchers(id) NOT NULL, - certifier INT REFERENCES accounts(id) NOT NULL, - certifier_weight NUMERIC NOT NULL CHECK (certifier_weight > 0 AND certifier_weight <= 10), - certificate_url_pointer TEXT NOT NULL CHECK (certificate_url_pointer <> '' AND char_length(certificate_url_pointer) <= 256), - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- multiple vouchers can b e used to pay for a service -CREATE TABLE IF NOT EXISTS service_accepted_payment ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - voucher INT REFERENCES vouchers(id) NOT NULL, - price FLOAT NOT NULL CHECK (price > 0) -); - --- every marketplace can have multiple services offered -CREATE TABLE IF NOT EXISTS services ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - marketplace INT REFERENCES marketplaces(id) NOT NULL, - service_type TEXT REFERENCES service_type(value) NOT NULL CHECK (service_type <> '' AND char_length(service_type) <= 64), - service_description TEXT NOT NULL CHECK (service_description <> '' AND char_length(service_description) <= 256), - service_available BOOLEAN DEFAULT true, - service_accepted_payment INT REFERENCES service_accepted_payment(id) NOT NULL, - location_name TEXT NOT NULL CHECK (location_name <> '' AND char_length(location_name) <= 64), - geo POINT, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- services/goods offered images if any -CREATE TABLE IF NOT EXISTS services_images ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - service_id INT REFERENCES services(id), - url_pointer TEXT NOT NULL CHECK (url_pointer <> '' AND char_length(url_pointer) <= 256) -); - --- public service ratings -CREATE TABLE IF NOT EXISTS services_ratings ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - service_id INT REFERENCES services(id) NOT NULL, - rating_by INT REFERENCES accounts(id) NOT NULL, - score INT CHECK (score > 0 AND score <= 5) NOT NULL, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- linked transactional data -CREATE TABLE IF NOT EXISTS transactions ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - tx_hash VARCHAR(64) NOT NULL UNIQUE, - block_number INT NOT NULL, - tx_index INT NOT NULL, - voucher_address TEXT NOT NULL REFERENCES vouchers(voucher_address) NOT NULL CHECK (voucher_address <> '' AND char_length(voucher_address) <= 42), - sender_address VARCHAR(42) NOT NULL, - recipient_address VARCHAR(42) NOT NULL, - tx_value BIGINT NOT NULL, - tx_type TEXT REFERENCES tx_type(value), - date_block TIMESTAMP NOT NULL, - success BOOLEAN NOT NULL -); - --- virtual payment addresses -CREATE TABLE IF NOT EXISTS vpa ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - vpa TEXT NOT NULL UNIQUE CHECK (vpa <> '' AND char_length(vpa) <= 64), - linked_account INT REFERENCES accounts(id) NOT NULL, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- sarafu till number -CREATE TABLE IF NOT EXISTS till ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - till TEXT NOT NULL UNIQUE, - linked_account INT REFERENCES accounts(id) NOT NULL, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); \ No newline at end of file diff --git a/migrations/002_fix_txs.sql b/migrations/002_fix_txs.sql deleted file mode 100644 index 36622b4..0000000 --- a/migrations/002_fix_txs.sql +++ /dev/null @@ -1,12 +0,0 @@ --- #24 fix -ALTER TABLE transactions ALTER COLUMN tx_hash TYPE VARCHAR(66); - --- #20 fix -ALTER TABLE personal_information ADD COLUMN language_code VARCHAR(3); -ALTER TABLE personal_information ALTER COLUMN language_code SET DEFAULT 'eng'; - --- #16 fix -ALTER TABLE vouchers ADD COLUMN radius INT; - --- #15 fix -ALTER TABLE voucher_backers RENAME TO voucher_issuers; \ No newline at end of file diff --git a/migrations/003_fix_pk.sql b/migrations/003_fix_pk.sql deleted file mode 100644 index e0b7b9d..0000000 --- a/migrations/003_fix_pk.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE personal_information ADD COLUMN id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY; diff --git a/migrations/004_accounts_role.sql b/migrations/004_accounts_role.sql deleted file mode 100644 index 7c6d87e..0000000 --- a/migrations/004_accounts_role.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE IF NOT EXISTS account_role_type ( - value TEXT PRIMARY KEY -); -INSERT INTO account_role_type (value) VALUES -('USER'), -('STAFF'), -('ADMIN'); - -ALTER TABLE accounts ADD COLUMN account_role TEXT REFERENCES account_role_type(value) DEFAULT 'USER' NOT NULL; diff --git a/migrations/005_voucher_internal.sql b/migrations/005_voucher_internal.sql deleted file mode 100644 index f782b75..0000000 --- a/migrations/005_voucher_internal.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vouchers ADD COLUMN internal BOOLEAN DEFAULT false; \ No newline at end of file diff --git a/migrations/006_voucher_updates.sql b/migrations/006_voucher_updates.sql deleted file mode 100644 index 6ea29c6..0000000 --- a/migrations/006_voucher_updates.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE IF NOT EXISTS voucher_type ( - value TEXT PRIMARY KEY -); -INSERT INTO voucher_type (value) VALUES -('DEMURRAGE'), -('GIFTABLE'); - -ALTER TABLE vouchers -DROP COLUMN supply, -DROP COLUMN demurrage_rate; - -ALTER TABLE vouchers -ADD COLUMN voucher_email TEXT, -ADD COLUMN voucher_website TEXT, -ADD COLUMN voucher_uoa TEXT NOT NULL DEFAULT 'KES', -ADD COLUMN voucher_value INT NOT NULL DEFAULT 10, -ADD COLUMN voucher_type TEXT REFERENCES voucher_type(value) NOT NULL DEFAULT 'DEMURRAGE'; \ No newline at end of file diff --git a/migrations/007_commodity.sql b/migrations/007_commodity.sql deleted file mode 100644 index da79333..0000000 --- a/migrations/007_commodity.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE IF NOT EXISTS commodity_type ( - value TEXT PRIMARY KEY -); -INSERT INTO commodity_type (value) VALUES -('SERVICE'), -('GOOD'); - -CREATE TABLE IF NOT EXISTS commodity_listings ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - voucher INT REFERENCES vouchers(id) NOT NULL, - account INT REFERENCES accounts(id) NOT NULL, - commodity_name TEXT NOT NULL, - quantity INT NOT NULL, - frequency TEXT NOT NULL, - commodity_type TEXT REFERENCES commodity_type(value) NOT NULL, - commodity_description TEXT NOT NULL, - commodity_available BOOLEAN DEFAULT true, - location_name TEXT NOT NULL, - geo POINT, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); \ No newline at end of file diff --git a/migrations/008_voucher_version.sql b/migrations/008_voucher_version.sql deleted file mode 100644 index fd3094d..0000000 --- a/migrations/008_voucher_version.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vouchers -ADD COLUMN contract_version TEXT; \ No newline at end of file diff --git a/migrations/009_gas_gift.sql b/migrations/009_gas_gift.sql deleted file mode 100644 index da49231..0000000 --- a/migrations/009_gas_gift.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE IF NOT EXISTS gas_gift_status_type ( - value TEXT PRIMARY KEY -); -INSERT INTO gas_gift_status_type (value) VALUES -('APPROVED'), -('REQUESTED'), -('REJECTED'), -('NONE'); - -ALTER TABLE accounts ADD COLUMN gas_gift_status TEXT REFERENCES gas_gift_status_type(value) DEFAULT 'NONE' NOT NULL; - -ALTER TABLE accounts ADD COLUMN gas_approver INT REFERENCES accounts(id); \ No newline at end of file diff --git a/migrations/010_default_voucher.sql b/migrations/010_default_voucher.sql deleted file mode 100644 index 9ef25fa..0000000 --- a/migrations/010_default_voucher.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE accounts ADD COLUMN default_voucher TEXT REFERENCES vouchers(voucher_address); \ No newline at end of file diff --git a/migrations/011_drop unused_tables.sql b/migrations/011_drop unused_tables.sql deleted file mode 100644 index fb7cf5d..0000000 --- a/migrations/011_drop unused_tables.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP TABLE IF EXISTS services CASCADE; -DROP TABLE IF EXISTS services_ratings, services_images, till, service_accepted_payment CASCADE; \ No newline at end of file diff --git a/migrations/012_pools.sql b/migrations/012_pools.sql deleted file mode 100644 index 2fb5095..0000000 --- a/migrations/012_pools.sql +++ /dev/null @@ -1,32 +0,0 @@ --- swap pools -CREATE TABLE IF NOT EXISTS swap_pools ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - pool_address TEXT NOT NULL UNIQUE CHECK (pool_address <> '' AND char_length(pool_address) <= 42), - swap_pool_description TEXT NOT NULL CHECK (swap_pool_description <> '' AND char_length(swap_pool_description) <= 256), - banner_url TEXT -); - --- URL pointers -ALTER TABLE vouchers ADD COLUMN uoa TEXT; -ALTER TABLE vouchers ADD COLUMN icon_url TEXT; -ALTER TABLE vouchers ADD COLUMN banner_url TEXT; - --- tags -CREATE TABLE IF NOT EXISTS tags ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - tag TEXT NOT NULL UNIQUE -); - -CREATE TABLE IF NOT EXISTS voucher_tags ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - voucher INT REFERENCES vouchers(id) NOT NULL, - tag INT REFERENCES tags(id) NOT NULL, - UNIQUE (voucher, tag) -); - -CREATE TABLE IF NOT EXISTS swap_pool_tags ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - swap_pool INT REFERENCES vouchers(id) NOT NULL, - tag INT REFERENCES tags(id) NOT NULL, - UNIQUE (swap_pool, tag) -); \ No newline at end of file diff --git a/migrations/013_update_products.sql b/migrations/013_update_products.sql deleted file mode 100644 index 09855b7..0000000 --- a/migrations/013_update_products.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE commodity_listings RENAME TO product_listings; -ALTER TABLE product_listings ADD COLUMN price INT DEFAULT 0; \ No newline at end of file diff --git a/migrations/014_drop_desc_constraints.sql b/migrations/014_drop_desc_constraints.sql deleted file mode 100644 index 6d56a6b..0000000 --- a/migrations/014_drop_desc_constraints.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE swap_pools DROP CONSTRAINT swap_pools_swap_pool_description_check RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_description_check RESTRICT; - diff --git a/migrations/015_drop_unnecessary_constraints.sql b/migrations/015_drop_unnecessary_constraints.sql deleted file mode 100644 index 17719af..0000000 --- a/migrations/015_drop_unnecessary_constraints.sql +++ /dev/null @@ -1,19 +0,0 @@ -ALTER TABLE personal_information DROP CONSTRAINT personal_information_family_name_check RESTRICT; -ALTER TABLE personal_information DROP CONSTRAINT personal_information_year_of_birth_check RESTRICT; -ALTER TABLE personal_information DROP CONSTRAINT personal_information_given_names_check RESTRICT; -ALTER TABLE personal_information DROP CONSTRAINT personal_information_location_name_check RESTRICT; - -ALTER TABLE users DROP CONSTRAINT users_interface_identifier_check RESTRICT; - -ALTER TABLE voucher_certifications DROP CONSTRAINT voucher_certifications_certifier_weight_check RESTRICT; -ALTER TABLE voucher_certifications DROP CONSTRAINT voucher_certifications_certificate_url_pointer_check RESTRICT; - -ALTER TABLE vouchers DROP CONSTRAINT vouchers_symbol_check RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_name_check RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_address_check RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_address_check1 RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_location_name_check RESTRICT; - -ALTER TABLE vpa DROP CONSTRAINT vpa_vpa_check RESTRICT; - - diff --git a/migrations/016_field_reports.sql b/migrations/016_field_reports.sql deleted file mode 100644 index ed8182b..0000000 --- a/migrations/016_field_reports.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE IF NOT EXISTS field_report_status_type ( - value TEXT PRIMARY KEY -); -INSERT INTO field_report_status_type (value) VALUES -('DRAFT'), -('SUBMITTED'), -('APPROVED'), -('REJECTED'); - -CREATE TABLE IF NOT EXISTS field_reports ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - title TEXT NOT NULL, - report TEXT NOT NULL, - "description" TEXT NOT NULL, - vouchers TEXT[] NOT NULL, - image_url TEXT, - tags TEXT[], - location TEXT, - period_from TIMESTAMP, - period_to TIMESTAMP, - created_by INT REFERENCES users(id) NOT NULL, - modified_by INT REFERENCES users(id) NOT NULL, - verified_by INT[], - "status" TEXT REFERENCES field_report_status_type(value) DEFAULT 'DRAFT' NOT NULL, - rejection_reason TEXT, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - diff --git a/migrations/cic_graph/1683629212320_run_sql_migration/down.sql b/migrations/cic_graph/1683629212320_run_sql_migration/down.sql deleted file mode 100644 index c64e186..0000000 --- a/migrations/cic_graph/1683629212320_run_sql_migration/down.sql +++ /dev/null @@ -1,14 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- -- #24 fix --- ALTER TABLE transactions ALTER COLUMN tx_hash TYPE VARCHAR(66); --- --- -- #20 fix --- ALTER TABLE personal_information ADD COLUMN language_code VARCHAR(3); --- ALTER TABLE personal_information ALTER COLUMN language_code SET DEFAULT 'eng'; --- --- -- #16 fix --- ALTER TABLE vouchers ADD COLUMN radius INT; --- --- -- #15 fix --- ALTER TABLE voucher_backers RENAME TO voucher_issuers; diff --git a/migrations/cic_graph/1683629212320_run_sql_migration/up.sql b/migrations/cic_graph/1683629212320_run_sql_migration/up.sql deleted file mode 100644 index 2825683..0000000 --- a/migrations/cic_graph/1683629212320_run_sql_migration/up.sql +++ /dev/null @@ -1,12 +0,0 @@ --- #24 fix -ALTER TABLE transactions ALTER COLUMN tx_hash TYPE VARCHAR(66); - --- #20 fix -ALTER TABLE personal_information ADD COLUMN language_code VARCHAR(3); -ALTER TABLE personal_information ALTER COLUMN language_code SET DEFAULT 'eng'; - --- #16 fix -ALTER TABLE vouchers ADD COLUMN radius INT; - --- #15 fix -ALTER TABLE voucher_backers RENAME TO voucher_issuers; diff --git a/migrations/cic_graph/1688447063690_fix_pk/down.sql b/migrations/cic_graph/1688447063690_fix_pk/down.sql deleted file mode 100644 index 9e7db12..0000000 --- a/migrations/cic_graph/1688447063690_fix_pk/down.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- ALTER TABLE personal_information ADD COLUMN id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY; diff --git a/migrations/cic_graph/1688447063690_fix_pk/up.sql b/migrations/cic_graph/1688447063690_fix_pk/up.sql deleted file mode 100644 index e0b7b9d..0000000 --- a/migrations/cic_graph/1688447063690_fix_pk/up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE personal_information ADD COLUMN id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY; diff --git a/migrations/cic_graph/1689303117473_accounts_role/down.sql b/migrations/cic_graph/1689303117473_accounts_role/down.sql deleted file mode 100644 index ac23788..0000000 --- a/migrations/cic_graph/1689303117473_accounts_role/down.sql +++ /dev/null @@ -1,11 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- CREATE TABLE IF NOT EXISTS account_role_type ( --- value TEXT PRIMARY KEY --- ); --- INSERT INTO account_role_type (value) VALUES --- ('USER'), --- ('STAFF'), --- ('ADMIN'); --- --- ALTER TABLE accounts ADD COLUMN account_role TEXT REFERENCES account_role_type(value) DEFAULT 'USER' NOT NULL; diff --git a/migrations/cic_graph/1689303117473_accounts_role/up.sql b/migrations/cic_graph/1689303117473_accounts_role/up.sql deleted file mode 100644 index 7c6d87e..0000000 --- a/migrations/cic_graph/1689303117473_accounts_role/up.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE IF NOT EXISTS account_role_type ( - value TEXT PRIMARY KEY -); -INSERT INTO account_role_type (value) VALUES -('USER'), -('STAFF'), -('ADMIN'); - -ALTER TABLE accounts ADD COLUMN account_role TEXT REFERENCES account_role_type(value) DEFAULT 'USER' NOT NULL; diff --git a/migrations/cic_graph/1692352815959_voucher_internal/down.sql b/migrations/cic_graph/1692352815959_voucher_internal/down.sql deleted file mode 100644 index d366084..0000000 --- a/migrations/cic_graph/1692352815959_voucher_internal/down.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- ALTER TABLE vouchers ADD COLUMN internal BOOLEAN DEFAULT false; diff --git a/migrations/cic_graph/1692352815959_voucher_internal/up.sql b/migrations/cic_graph/1692352815959_voucher_internal/up.sql deleted file mode 100644 index 663be33..0000000 --- a/migrations/cic_graph/1692352815959_voucher_internal/up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vouchers ADD COLUMN internal BOOLEAN DEFAULT false; diff --git a/migrations/cic_graph/1694419664787_voucher_updates/down.sql b/migrations/cic_graph/1694419664787_voucher_updates/down.sql deleted file mode 100644 index 9deab4a..0000000 --- a/migrations/cic_graph/1694419664787_voucher_updates/down.sql +++ /dev/null @@ -1,19 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- CREATE TABLE IF NOT EXISTS voucher_type ( --- value TEXT PRIMARY KEY --- ); --- INSERT INTO voucher_type (value) VALUES --- ('DEMURRAGE'), --- ('GIFTABLE'); --- --- ALTER TABLE vouchers --- DROP COLUMN supply, --- DROP COLUMN demurrage_rate; --- --- ALTER TABLE vouchers --- ADD COLUMN voucher_email TEXT, --- ADD COLUMN voucher_website TEXT, --- ADD COLUMN voucher_uoa TEXT NOT NULL DEFAULT 'KES', --- ADD COLUMN voucher_value INT NOT NULL DEFAULT 10, --- ADD COLUMN voucher_type TEXT REFERENCES voucher_type(value) NOT NULL DEFAULT 'DEMURRAGE'; diff --git a/migrations/cic_graph/1694419664787_voucher_updates/up.sql b/migrations/cic_graph/1694419664787_voucher_updates/up.sql deleted file mode 100644 index dcd55fc..0000000 --- a/migrations/cic_graph/1694419664787_voucher_updates/up.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE IF NOT EXISTS voucher_type ( - value TEXT PRIMARY KEY -); -INSERT INTO voucher_type (value) VALUES -('DEMURRAGE'), -('GIFTABLE'); - -ALTER TABLE vouchers -DROP COLUMN supply, -DROP COLUMN demurrage_rate; - -ALTER TABLE vouchers -ADD COLUMN voucher_email TEXT, -ADD COLUMN voucher_website TEXT, -ADD COLUMN voucher_uoa TEXT NOT NULL DEFAULT 'KES', -ADD COLUMN voucher_value INT NOT NULL DEFAULT 10, -ADD COLUMN voucher_type TEXT REFERENCES voucher_type(value) NOT NULL DEFAULT 'DEMURRAGE'; diff --git a/migrations/cic_graph/1694422050457_commodity/down.sql b/migrations/cic_graph/1694422050457_commodity/down.sql deleted file mode 100644 index 1ea34da..0000000 --- a/migrations/cic_graph/1694422050457_commodity/down.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- CREATE TABLE IF NOT EXISTS commodity_type ( --- value TEXT PRIMARY KEY --- ); --- INSERT INTO commodity_type (value) VALUES --- ('SERVICE'), --- ('GOOD'); --- --- CREATE TABLE IF NOT EXISTS commodity_listings ( --- id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, --- voucher INT REFERENCES vouchers(id) NOT NULL, --- account INT REFERENCES accounts(id) NOT NULL, --- commodity_name TEXT NOT NULL, --- quantity INT NOT NULL, --- frequency TEXT NOT NULL, --- commodity_type TEXT REFERENCES commodity_type(value) NOT NULL, --- commodity_description TEXT NOT NULL, --- commodity_available BOOLEAN DEFAULT true, --- location_name TEXT NOT NULL, --- geo POINT, --- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP --- ); diff --git a/migrations/cic_graph/1694422050457_commodity/up.sql b/migrations/cic_graph/1694422050457_commodity/up.sql deleted file mode 100644 index 5ec00f8..0000000 --- a/migrations/cic_graph/1694422050457_commodity/up.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE IF NOT EXISTS commodity_type ( - value TEXT PRIMARY KEY -); -INSERT INTO commodity_type (value) VALUES -('SERVICE'), -('GOOD'); - -CREATE TABLE IF NOT EXISTS commodity_listings ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - voucher INT REFERENCES vouchers(id) NOT NULL, - account INT REFERENCES accounts(id) NOT NULL, - commodity_name TEXT NOT NULL, - quantity INT NOT NULL, - frequency TEXT NOT NULL, - commodity_type TEXT REFERENCES commodity_type(value) NOT NULL, - commodity_description TEXT NOT NULL, - commodity_available BOOLEAN DEFAULT true, - location_name TEXT NOT NULL, - geo POINT, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); diff --git a/migrations/cic_graph/1697016015189_voucher_version/down.sql b/migrations/cic_graph/1697016015189_voucher_version/down.sql deleted file mode 100644 index d8ef62e..0000000 --- a/migrations/cic_graph/1697016015189_voucher_version/down.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- ALTER TABLE vouchers --- ADD COLUMN contract_version TEXT; diff --git a/migrations/cic_graph/1697016015189_voucher_version/up.sql b/migrations/cic_graph/1697016015189_voucher_version/up.sql deleted file mode 100644 index 89b869a..0000000 --- a/migrations/cic_graph/1697016015189_voucher_version/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vouchers -ADD COLUMN contract_version TEXT; diff --git a/migrations/cic_graph/1699422690072_gas_gift/down.sql b/migrations/cic_graph/1699422690072_gas_gift/down.sql deleted file mode 100644 index 44f9984..0000000 --- a/migrations/cic_graph/1699422690072_gas_gift/down.sql +++ /dev/null @@ -1,14 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- CREATE TABLE IF NOT EXISTS gas_gift_status_type ( --- value TEXT PRIMARY KEY --- ); --- INSERT INTO gas_gift_status_type (value) VALUES --- ('APPROVED'), --- ('REQUESTED'), --- ('REJECTED'), --- ('NONE'); --- --- ALTER TABLE accounts ADD COLUMN gas_gift_status TEXT REFERENCES gas_gift_status_type(value) DEFAULT 'NONE' NOT NULL; --- --- ALTER TABLE accounts ADD COLUMN gas_approver INT REFERENCES accounts(id); diff --git a/migrations/cic_graph/1699422690072_gas_gift/up.sql b/migrations/cic_graph/1699422690072_gas_gift/up.sql deleted file mode 100644 index 0c582cb..0000000 --- a/migrations/cic_graph/1699422690072_gas_gift/up.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE IF NOT EXISTS gas_gift_status_type ( - value TEXT PRIMARY KEY -); -INSERT INTO gas_gift_status_type (value) VALUES -('APPROVED'), -('REQUESTED'), -('REJECTED'), -('NONE'); - -ALTER TABLE accounts ADD COLUMN gas_gift_status TEXT REFERENCES gas_gift_status_type(value) DEFAULT 'NONE' NOT NULL; - -ALTER TABLE accounts ADD COLUMN gas_approver INT REFERENCES accounts(id); diff --git a/migrations/cic_graph/1706183152785_default_voucher/down.sql b/migrations/cic_graph/1706183152785_default_voucher/down.sql deleted file mode 100644 index 96f7901..0000000 --- a/migrations/cic_graph/1706183152785_default_voucher/down.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- ALTER TABLE accounts ADD COLUMN default_voucher TEXT REFERENCES vouchers(voucher_address); diff --git a/migrations/cic_graph/1706183152785_default_voucher/up.sql b/migrations/cic_graph/1706183152785_default_voucher/up.sql deleted file mode 100644 index 06c348b..0000000 --- a/migrations/cic_graph/1706183152785_default_voucher/up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE accounts ADD COLUMN default_voucher TEXT REFERENCES vouchers(voucher_address); diff --git a/migrations/cic_graph/1717595822104_drop_unused_tables/down.sql b/migrations/cic_graph/1717595822104_drop_unused_tables/down.sql deleted file mode 100644 index cbc407f..0000000 --- a/migrations/cic_graph/1717595822104_drop_unused_tables/down.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- DROP TABLE IF EXISTS services CASCADE; --- DROP TABLE IF EXISTS services_ratings, services_images, till, service_accepted_payment CASCADE; diff --git a/migrations/cic_graph/1717595822104_drop_unused_tables/up.sql b/migrations/cic_graph/1717595822104_drop_unused_tables/up.sql deleted file mode 100644 index cb29a18..0000000 --- a/migrations/cic_graph/1717595822104_drop_unused_tables/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP TABLE IF EXISTS services CASCADE; -DROP TABLE IF EXISTS services_ratings, services_images, till, service_accepted_payment CASCADE; diff --git a/migrations/cic_graph/1717597236877_pools/down.sql b/migrations/cic_graph/1717597236877_pools/down.sql deleted file mode 100644 index 21ebed2..0000000 --- a/migrations/cic_graph/1717597236877_pools/down.sql +++ /dev/null @@ -1,34 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- -- swap pools --- CREATE TABLE IF NOT EXISTS swap_pools ( --- id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, --- pool_address TEXT NOT NULL UNIQUE CHECK (pool_address <> '' AND char_length(pool_address) <= 42), --- swap_pool_description TEXT NOT NULL CHECK (swap_pool_description <> '' AND char_length(swap_pool_description) <= 256), --- banner_url TEXT --- ); --- --- -- URL pointers --- ALTER TABLE vouchers ADD COLUMN uoa TEXT NOT NULL; --- ALTER TABLE vouchers ADD COLUMN icon_url TEXT; --- ALTER TABLE vouchers ADD COLUMN banner_url TEXT; --- --- -- tags --- CREATE TABLE IF NOT EXISTS tags ( --- id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, --- tag TEXT NOT NULL UNIQUE --- ); --- --- CREATE TABLE IF NOT EXISTS voucher_tags ( --- id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, --- voucher INT REFERENCES vouchers(id) NOT NULL, --- tag INT REFERENCES tags(id) NOT NULL, --- UNIQUE (voucher, tag) --- ); --- --- CREATE TABLE IF NOT EXISTS swap_pool_tags ( --- id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, --- swap_pool INT REFERENCES vouchers(id) NOT NULL, --- tag INT REFERENCES tags(id) NOT NULL, --- UNIQUE (swap_pool, tag) --- ); diff --git a/migrations/cic_graph/1717597236877_pools/up.sql b/migrations/cic_graph/1717597236877_pools/up.sql deleted file mode 100644 index 2fe191d..0000000 --- a/migrations/cic_graph/1717597236877_pools/up.sql +++ /dev/null @@ -1,32 +0,0 @@ --- swap pools -CREATE TABLE IF NOT EXISTS swap_pools ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - pool_address TEXT NOT NULL UNIQUE CHECK (pool_address <> '' AND char_length(pool_address) <= 42), - swap_pool_description TEXT NOT NULL CHECK (swap_pool_description <> '' AND char_length(swap_pool_description) <= 256), - banner_url TEXT -); - --- URL pointers -ALTER TABLE vouchers ADD COLUMN uoa TEXT; -ALTER TABLE vouchers ADD COLUMN icon_url TEXT; -ALTER TABLE vouchers ADD COLUMN banner_url TEXT; - --- tags -CREATE TABLE IF NOT EXISTS tags ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - tag TEXT NOT NULL UNIQUE -); - -CREATE TABLE IF NOT EXISTS voucher_tags ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - voucher INT REFERENCES vouchers(id) NOT NULL, - tag INT REFERENCES tags(id) NOT NULL, - UNIQUE (voucher, tag) -); - -CREATE TABLE IF NOT EXISTS swap_pool_tags ( - id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - swap_pool INT REFERENCES vouchers(id) NOT NULL, - tag INT REFERENCES tags(id) NOT NULL, - UNIQUE (swap_pool, tag) -); diff --git a/migrations/cic_graph/1717662189256_update_products/down.sql b/migrations/cic_graph/1717662189256_update_products/down.sql deleted file mode 100644 index 5a6a52f..0000000 --- a/migrations/cic_graph/1717662189256_update_products/down.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- ALTER TABLE commodity_listings RENAME TO product_listings; --- ALTER TABLE product_listings ADD COLUMN price INT NOT NULL; diff --git a/migrations/cic_graph/1717662189256_update_products/up.sql b/migrations/cic_graph/1717662189256_update_products/up.sql deleted file mode 100644 index c4a6bd6..0000000 --- a/migrations/cic_graph/1717662189256_update_products/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE commodity_listings RENAME TO product_listings; -ALTER TABLE product_listings ADD COLUMN price INT NOT NULL DEFAULT 0; diff --git a/migrations/cic_graph/1719922775002_014_drop_desc_constraints/down.sql b/migrations/cic_graph/1719922775002_014_drop_desc_constraints/down.sql deleted file mode 100644 index 2da2ade..0000000 --- a/migrations/cic_graph/1719922775002_014_drop_desc_constraints/down.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- ALTER TABLE swap_pools DROP CONSTRAINT swap_pools_swap_pool_description_check RESTRICT; --- ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_description_check RESTRICT; diff --git a/migrations/cic_graph/1719922775002_014_drop_desc_constraints/up.sql b/migrations/cic_graph/1719922775002_014_drop_desc_constraints/up.sql deleted file mode 100644 index 7134ff4..0000000 --- a/migrations/cic_graph/1719922775002_014_drop_desc_constraints/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE swap_pools DROP CONSTRAINT swap_pools_swap_pool_description_check RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_description_check RESTRICT; diff --git a/migrations/cic_graph/1724122169685_drop_unnecessary_constraints/down.sql b/migrations/cic_graph/1724122169685_drop_unnecessary_constraints/down.sql deleted file mode 100644 index a01a3db..0000000 --- a/migrations/cic_graph/1724122169685_drop_unnecessary_constraints/down.sql +++ /dev/null @@ -1,19 +0,0 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- ALTER TABLE personal_information DROP CONSTRAINT personal_information_family_name_check RESTRICT; --- ALTER TABLE personal_information DROP CONSTRAINT personal_information_year_of_birth_check RESTRICT; --- ALTER TABLE personal_information DROP CONSTRAINT personal_information_given_names_check RESTRICT; --- ALTER TABLE personal_information DROP CONSTRAINT personal_information_location_name_check RESTRICT; --- --- ALTER TABLE users DROP CONSTRAINT users_interface_identifier_check RESTRICT; --- --- ALTER TABLE voucher_certifications DROP CONSTRAINT voucher_certifications_certifier_weight_check RESTRICT; --- ALTER TABLE voucher_certifications DROP CONSTRAINT voucher_certifications_certificate_url_pointer_check RESTRICT; --- --- ALTER TABLE vouchers DROP CONSTRAINT vouchers_symbol_check RESTRICT; --- ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_name_check RESTRICT; --- ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_address_check RESTRICT; --- ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_address_check1 RESTRICT; --- ALTER TABLE vouchers DROP CONSTRAINT vouchers_location_name_check RESTRICT; --- --- ALTER TABLE vpa DROP CONSTRAINT vpa_vpa_check RESTRICT; diff --git a/migrations/cic_graph/1724122169685_drop_unnecessary_constraints/up.sql b/migrations/cic_graph/1724122169685_drop_unnecessary_constraints/up.sql deleted file mode 100644 index 5a0cdca..0000000 --- a/migrations/cic_graph/1724122169685_drop_unnecessary_constraints/up.sql +++ /dev/null @@ -1,17 +0,0 @@ -ALTER TABLE personal_information DROP CONSTRAINT personal_information_family_name_check RESTRICT; -ALTER TABLE personal_information DROP CONSTRAINT personal_information_year_of_birth_check RESTRICT; -ALTER TABLE personal_information DROP CONSTRAINT personal_information_given_names_check RESTRICT; -ALTER TABLE personal_information DROP CONSTRAINT personal_information_location_name_check RESTRICT; - -ALTER TABLE users DROP CONSTRAINT users_interface_identifier_check RESTRICT; - -ALTER TABLE voucher_certifications DROP CONSTRAINT voucher_certifications_certifier_weight_check RESTRICT; -ALTER TABLE voucher_certifications DROP CONSTRAINT voucher_certifications_certificate_url_pointer_check RESTRICT; - -ALTER TABLE vouchers DROP CONSTRAINT vouchers_symbol_check RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_name_check RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_address_check RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_voucher_address_check1 RESTRICT; -ALTER TABLE vouchers DROP CONSTRAINT vouchers_location_name_check RESTRICT; - -ALTER TABLE vpa DROP CONSTRAINT vpa_vpa_check RESTRICT; diff --git a/migrations/tern.conf b/migrations/tern.conf deleted file mode 100644 index 87a033c..0000000 --- a/migrations/tern.conf +++ /dev/null @@ -1,2 +0,0 @@ -[database] -conn_string = {{env "PG_DATABASE_URL"}} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..677a90e --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "scripts": { + "generate": "drizzle-kit generate", + "migrate": "drizzle-kit migrate", + "studio": "drizzle-kit studio" + }, + "dependencies": { + "dotenv": "^16.5.0", + "drizzle-orm": "^0.43.1", + "pg": "^8.16.0" + }, + "devDependencies": { + "@types/pg": "^8.15.2", + "drizzle-kit": "^0.31.1", + "tsx": "^4.19.4" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..49f5691 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,920 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + dotenv: + specifier: ^16.5.0 + version: 16.5.0 + drizzle-orm: + specifier: ^0.43.1 + version: 0.43.1(@types/pg@8.15.2)(pg@8.16.0) + pg: + specifier: ^8.16.0 + version: 8.16.0 + devDependencies: + '@types/pg': + specifier: ^8.15.2 + version: 8.15.2 + drizzle-kit: + specifier: ^0.31.1 + version: 0.31.1 + tsx: + specifier: ^4.19.4 + version: 4.19.4 + +packages: + + '@drizzle-team/brocli@0.10.2': + resolution: {integrity: sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w==} + + '@esbuild-kit/core-utils@3.3.2': + resolution: {integrity: sha512-sPRAnw9CdSsRmEtnsl2WXWdyquogVpB3yZ3dgwJfe8zrOzTsV7cJvmwrKVa+0ma5BoiGJ+BoqkMvawbayKUsqQ==} + deprecated: 'Merged into tsx: https://tsx.is' + + '@esbuild-kit/esm-loader@2.6.5': + resolution: {integrity: sha512-FxEMIkJKnodyA1OaCUoEvbYRkoZlLZ4d/eXFu9Fh8CbBBgP5EmZxrfTRyN0qpXZ4vOvqnE5YdRdcrmUUXuU+dA==} + deprecated: 'Merged into tsx: https://tsx.is' + + '@esbuild/aix-ppc64@0.25.4': + resolution: {integrity: sha512-1VCICWypeQKhVbE9oW/sJaAmjLxhVqacdkvPLEjwlttjfwENRSClS8EjBz0KzRyFSCPDIkuXW34Je/vk7zdB7Q==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.18.20': + resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm64@0.25.4': + resolution: {integrity: sha512-bBy69pgfhMGtCnwpC/x5QhfxAz/cBgQ9enbtwjf6V9lnPI/hMyT9iWpR1arm0l3kttTr4L0KSLpKmLp/ilKS9A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm@0.18.20': + resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + + '@esbuild/android-arm@0.25.4': + resolution: {integrity: sha512-QNdQEps7DfFwE3hXiU4BZeOV68HHzYwGd0Nthhd3uCkkEKK7/R6MTgM0P7H7FAs5pU/DIWsviMmEGxEoxIZ+ZQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-x64@0.18.20': + resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + + '@esbuild/android-x64@0.25.4': + resolution: {integrity: sha512-TVhdVtQIFuVpIIR282btcGC2oGQoSfZfmBdTip2anCaVYcqWlZXGcdcKIUklfX2wj0JklNYgz39OBqh2cqXvcQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/darwin-arm64@0.18.20': + resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-arm64@0.25.4': + resolution: {integrity: sha512-Y1giCfM4nlHDWEfSckMzeWNdQS31BQGs9/rouw6Ub91tkK79aIMTH3q9xHvzH8d0wDru5Ci0kWB8b3up/nl16g==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-x64@0.18.20': + resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + + '@esbuild/darwin-x64@0.25.4': + resolution: {integrity: sha512-CJsry8ZGM5VFVeyUYB3cdKpd/H69PYez4eJh1W/t38vzutdjEjtP7hB6eLKBoOdxcAlCtEYHzQ/PJ/oU9I4u0A==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.18.20': + resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-arm64@0.25.4': + resolution: {integrity: sha512-yYq+39NlTRzU2XmoPW4l5Ifpl9fqSk0nAJYM/V/WUGPEFfek1epLHJIkTQM6bBs1swApjO5nWgvr843g6TjxuQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.18.20': + resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.25.4': + resolution: {integrity: sha512-0FgvOJ6UUMflsHSPLzdfDnnBBVoCDtBTVyn/MrWloUNvq/5SFmh13l3dvgRPkDihRxb77Y17MbqbCAa2strMQQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.18.20': + resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm64@0.25.4': + resolution: {integrity: sha512-+89UsQTfXdmjIvZS6nUnOOLoXnkUTB9hR5QAeLrQdzOSWZvNSAXAtcRDHWtqAUtAmv7ZM1WPOOeSxDzzzMogiQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.18.20': + resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-arm@0.25.4': + resolution: {integrity: sha512-kro4c0P85GMfFYqW4TWOpvmF8rFShbWGnrLqlzp4X1TNWjRY3JMYUfDCtOxPKOIY8B0WC8HN51hGP4I4hz4AaQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.18.20': + resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-ia32@0.25.4': + resolution: {integrity: sha512-yTEjoapy8UP3rv8dB0ip3AfMpRbyhSN3+hY8mo/i4QXFeDxmiYbEKp3ZRjBKcOP862Ua4b1PDfwlvbuwY7hIGQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.18.20': + resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-loong64@0.25.4': + resolution: {integrity: sha512-NeqqYkrcGzFwi6CGRGNMOjWGGSYOpqwCjS9fvaUlX5s3zwOtn1qwg1s2iE2svBe4Q/YOG1q6875lcAoQK/F4VA==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-mips64el@0.18.20': + resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-mips64el@0.25.4': + resolution: {integrity: sha512-IcvTlF9dtLrfL/M8WgNI/qJYBENP3ekgsHbYUIzEzq5XJzzVEV/fXY9WFPfEEXmu3ck2qJP8LG/p3Q8f7Zc2Xg==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.18.20': + resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-ppc64@0.25.4': + resolution: {integrity: sha512-HOy0aLTJTVtoTeGZh4HSXaO6M95qu4k5lJcH4gxv56iaycfz1S8GO/5Jh6X4Y1YiI0h7cRyLi+HixMR+88swag==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.18.20': + resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-riscv64@0.25.4': + resolution: {integrity: sha512-i8JUDAufpz9jOzo4yIShCTcXzS07vEgWzyX3NH2G7LEFVgrLEhjwL3ajFE4fZI3I4ZgiM7JH3GQ7ReObROvSUA==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.18.20': + resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-s390x@0.25.4': + resolution: {integrity: sha512-jFnu+6UbLlzIjPQpWCNh5QtrcNfMLjgIavnwPQAfoGx4q17ocOU9MsQ2QVvFxwQoWpZT8DvTLooTvmOQXkO51g==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.18.20': + resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + + '@esbuild/linux-x64@0.25.4': + resolution: {integrity: sha512-6e0cvXwzOnVWJHq+mskP8DNSrKBr1bULBvnFLpc1KY+d+irZSgZ02TGse5FsafKS5jg2e4pbvK6TPXaF/A6+CA==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-arm64@0.25.4': + resolution: {integrity: sha512-vUnkBYxZW4hL/ie91hSqaSNjulOnYXE1VSLusnvHg2u3jewJBz3YzB9+oCw8DABeVqZGg94t9tyZFoHma8gWZQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.18.20': + resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.25.4': + resolution: {integrity: sha512-XAg8pIQn5CzhOB8odIcAm42QsOfa98SBeKUdo4xa8OvX8LbMZqEtgeWE9P/Wxt7MlG2QqvjGths+nq48TrUiKw==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.25.4': + resolution: {integrity: sha512-Ct2WcFEANlFDtp1nVAXSNBPDxyU+j7+tId//iHXU2f/lN5AmO4zLyhDcpR5Cz1r08mVxzt3Jpyt4PmXQ1O6+7A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.18.20': + resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.25.4': + resolution: {integrity: sha512-xAGGhyOQ9Otm1Xu8NT1ifGLnA6M3sJxZ6ixylb+vIUVzvvd6GOALpwQrYrtlPouMqd/vSbgehz6HaVk4+7Afhw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/sunos-x64@0.18.20': + resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + + '@esbuild/sunos-x64@0.25.4': + resolution: {integrity: sha512-Mw+tzy4pp6wZEK0+Lwr76pWLjrtjmJyUB23tHKqEDP74R3q95luY/bXqXZeYl4NYlvwOqoRKlInQialgCKy67Q==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.18.20': + resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-arm64@0.25.4': + resolution: {integrity: sha512-AVUP428VQTSddguz9dO9ngb+E5aScyg7nOeJDrF1HPYu555gmza3bDGMPhmVXL8svDSoqPCsCPjb265yG/kLKQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.18.20': + resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-ia32@0.25.4': + resolution: {integrity: sha512-i1sW+1i+oWvQzSgfRcxxG2k4I9n3O9NRqy8U+uugaT2Dy7kLO9Y7wI72haOahxceMX8hZAzgGou1FhndRldxRg==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.18.20': + resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + + '@esbuild/win32-x64@0.25.4': + resolution: {integrity: sha512-nOT2vZNw6hJ+z43oP1SPea/G/6AbN6X+bGNhNuq8NtRHy4wsMhw765IKLNmnjek7GvjWBYQ8Q5VBoYTFg9y1UQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + '@types/node@22.15.19': + resolution: {integrity: sha512-3vMNr4TzNQyjHcRZadojpRaD9Ofr6LsonZAoQ+HMUa/9ORTPoxVIw0e0mpqWpdjj8xybyCM+oKOUH2vwFu/oEw==} + + '@types/pg@8.15.2': + resolution: {integrity: sha512-+BKxo5mM6+/A1soSHBI7ufUglqYXntChLDyTbvcAn1Lawi9J7J9Ok3jt6w7I0+T/UDJ4CyhHk66+GZbwmkYxSg==} + + buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + + debug@4.4.1: + resolution: {integrity: sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + dotenv@16.5.0: + resolution: {integrity: sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==} + engines: {node: '>=12'} + + drizzle-kit@0.31.1: + resolution: {integrity: sha512-PUjYKWtzOzPtdtQlTHQG3qfv4Y0XT8+Eas6UbxCmxTj7qgMf+39dDujf1BP1I+qqZtw9uzwTh8jYtkMuCq+B0Q==} + hasBin: true + + drizzle-orm@0.43.1: + resolution: {integrity: sha512-dUcDaZtE/zN4RV/xqGrVSMpnEczxd5cIaoDeor7Zst9wOe/HzC/7eAaulywWGYXdDEc9oBPMjayVEDg0ziTLJA==} + peerDependencies: + '@aws-sdk/client-rds-data': '>=3' + '@cloudflare/workers-types': '>=4' + '@electric-sql/pglite': '>=0.2.0' + '@libsql/client': '>=0.10.0' + '@libsql/client-wasm': '>=0.10.0' + '@neondatabase/serverless': '>=0.10.0' + '@op-engineering/op-sqlite': '>=2' + '@opentelemetry/api': ^1.4.1 + '@planetscale/database': '>=1.13' + '@prisma/client': '*' + '@tidbcloud/serverless': '*' + '@types/better-sqlite3': '*' + '@types/pg': '*' + '@types/sql.js': '*' + '@vercel/postgres': '>=0.8.0' + '@xata.io/client': '*' + better-sqlite3: '>=7' + bun-types: '*' + expo-sqlite: '>=14.0.0' + gel: '>=2' + knex: '*' + kysely: '*' + mysql2: '>=2' + pg: '>=8' + postgres: '>=3' + prisma: '*' + sql.js: '>=1' + sqlite3: '>=5' + peerDependenciesMeta: + '@aws-sdk/client-rds-data': + optional: true + '@cloudflare/workers-types': + optional: true + '@electric-sql/pglite': + optional: true + '@libsql/client': + optional: true + '@libsql/client-wasm': + optional: true + '@neondatabase/serverless': + optional: true + '@op-engineering/op-sqlite': + optional: true + '@opentelemetry/api': + optional: true + '@planetscale/database': + optional: true + '@prisma/client': + optional: true + '@tidbcloud/serverless': + optional: true + '@types/better-sqlite3': + optional: true + '@types/pg': + optional: true + '@types/sql.js': + optional: true + '@vercel/postgres': + optional: true + '@xata.io/client': + optional: true + better-sqlite3: + optional: true + bun-types: + optional: true + expo-sqlite: + optional: true + gel: + optional: true + knex: + optional: true + kysely: + optional: true + mysql2: + optional: true + pg: + optional: true + postgres: + optional: true + prisma: + optional: true + sql.js: + optional: true + sqlite3: + optional: true + + esbuild-register@3.6.0: + resolution: {integrity: sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==} + peerDependencies: + esbuild: '>=0.12 <1' + + esbuild@0.18.20: + resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} + engines: {node: '>=12'} + hasBin: true + + esbuild@0.25.4: + resolution: {integrity: sha512-8pgjLUcUjcgDg+2Q4NYXnPbo/vncAY4UmyaCm0jZevERqCHZIaWwdJHkf8XQtu4AxSKCdvrUbT0XUr1IdZzI8Q==} + engines: {node: '>=18'} + hasBin: true + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + get-tsconfig@4.10.0: + resolution: {integrity: sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + obuf@1.1.2: + resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==} + + pg-cloudflare@1.2.5: + resolution: {integrity: sha512-OOX22Vt0vOSRrdoUPKJ8Wi2OpE/o/h9T8X1s4qSkCedbNah9ei2W2765be8iMVxQUsvgT7zIAT2eIa9fs5+vtg==} + + pg-connection-string@2.9.0: + resolution: {integrity: sha512-P2DEBKuvh5RClafLngkAuGe9OUlFV7ebu8w1kmaaOgPcpJd1RIFh7otETfI6hAR8YupOLFTY7nuvvIn7PLciUQ==} + + pg-int8@1.0.1: + resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==} + engines: {node: '>=4.0.0'} + + pg-numeric@1.0.2: + resolution: {integrity: sha512-BM/Thnrw5jm2kKLE5uJkXqqExRUY/toLHda65XgFTBTFYZyopbKjBe29Ii3RbkvlsMoFwD+tHeGaCjjv0gHlyw==} + engines: {node: '>=4'} + + pg-pool@3.10.0: + resolution: {integrity: sha512-DzZ26On4sQ0KmqnO34muPcmKbhrjmyiO4lCCR0VwEd7MjmiKf5NTg/6+apUEu0NF7ESa37CGzFxH513CoUmWnA==} + peerDependencies: + pg: '>=8.0' + + pg-protocol@1.10.0: + resolution: {integrity: sha512-IpdytjudNuLv8nhlHs/UrVBhU0e78J0oIS/0AVdTbWxSOkFUVdsHC/NrorO6nXsQNDTT1kzDSOMJubBQviX18Q==} + + pg-types@2.2.0: + resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==} + engines: {node: '>=4'} + + pg-types@4.0.2: + resolution: {integrity: sha512-cRL3JpS3lKMGsKaWndugWQoLOCoP+Cic8oseVcbr0qhPzYD5DWXK+RZ9LY9wxRf7RQia4SCwQlXk0q6FCPrVng==} + engines: {node: '>=10'} + + pg@8.16.0: + resolution: {integrity: sha512-7SKfdvP8CTNXjMUzfcVTaI+TDzBEeaUnVwiVGZQD1Hh33Kpev7liQba9uLd4CfN8r9mCVsD0JIpq03+Unpz+kg==} + engines: {node: '>= 8.0.0'} + peerDependencies: + pg-native: '>=3.0.1' + peerDependenciesMeta: + pg-native: + optional: true + + pgpass@1.0.5: + resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==} + + postgres-array@2.0.0: + resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==} + engines: {node: '>=4'} + + postgres-array@3.0.4: + resolution: {integrity: sha512-nAUSGfSDGOaOAEGwqsRY27GPOea7CNipJPOA7lPbdEpx5Kg3qzdP0AaWC5MlhTWV9s4hFX39nomVZ+C4tnGOJQ==} + engines: {node: '>=12'} + + postgres-bytea@1.0.0: + resolution: {integrity: sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==} + engines: {node: '>=0.10.0'} + + postgres-bytea@3.0.0: + resolution: {integrity: sha512-CNd4jim9RFPkObHSjVHlVrxoVQXz7quwNFpz7RY1okNNme49+sVyiTvTRobiLV548Hx/hb1BG+iE7h9493WzFw==} + engines: {node: '>= 6'} + + postgres-date@1.0.7: + resolution: {integrity: sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==} + engines: {node: '>=0.10.0'} + + postgres-date@2.1.0: + resolution: {integrity: sha512-K7Juri8gtgXVcDfZttFKVmhglp7epKb1K4pgrkLxehjqkrgPhfG6OO8LHLkfaqkbpjNRnra018XwAr1yQFWGcA==} + engines: {node: '>=12'} + + postgres-interval@1.2.0: + resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==} + engines: {node: '>=0.10.0'} + + postgres-interval@3.0.0: + resolution: {integrity: sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw==} + engines: {node: '>=12'} + + postgres-range@1.1.4: + resolution: {integrity: sha512-i/hbxIE9803Alj/6ytL7UHQxRvZkI9O4Sy+J3HGc4F4oo/2eQAjTSNJ0bfxyse3bH0nuVesCk+3IRLaMtG3H6w==} + + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + + source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + + split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + + tsx@4.19.4: + resolution: {integrity: sha512-gK5GVzDkJK1SI1zwHf32Mqxf2tSJkNx+eYcNly5+nHvWqXUJYUkWBQtKauoESz3ymezAI++ZwT855x5p5eop+Q==} + engines: {node: '>=18.0.0'} + hasBin: true + + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} + + xtend@4.0.2: + resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} + engines: {node: '>=0.4'} + +snapshots: + + '@drizzle-team/brocli@0.10.2': {} + + '@esbuild-kit/core-utils@3.3.2': + dependencies: + esbuild: 0.18.20 + source-map-support: 0.5.21 + + '@esbuild-kit/esm-loader@2.6.5': + dependencies: + '@esbuild-kit/core-utils': 3.3.2 + get-tsconfig: 4.10.0 + + '@esbuild/aix-ppc64@0.25.4': + optional: true + + '@esbuild/android-arm64@0.18.20': + optional: true + + '@esbuild/android-arm64@0.25.4': + optional: true + + '@esbuild/android-arm@0.18.20': + optional: true + + '@esbuild/android-arm@0.25.4': + optional: true + + '@esbuild/android-x64@0.18.20': + optional: true + + '@esbuild/android-x64@0.25.4': + optional: true + + '@esbuild/darwin-arm64@0.18.20': + optional: true + + '@esbuild/darwin-arm64@0.25.4': + optional: true + + '@esbuild/darwin-x64@0.18.20': + optional: true + + '@esbuild/darwin-x64@0.25.4': + optional: true + + '@esbuild/freebsd-arm64@0.18.20': + optional: true + + '@esbuild/freebsd-arm64@0.25.4': + optional: true + + '@esbuild/freebsd-x64@0.18.20': + optional: true + + '@esbuild/freebsd-x64@0.25.4': + optional: true + + '@esbuild/linux-arm64@0.18.20': + optional: true + + '@esbuild/linux-arm64@0.25.4': + optional: true + + '@esbuild/linux-arm@0.18.20': + optional: true + + '@esbuild/linux-arm@0.25.4': + optional: true + + '@esbuild/linux-ia32@0.18.20': + optional: true + + '@esbuild/linux-ia32@0.25.4': + optional: true + + '@esbuild/linux-loong64@0.18.20': + optional: true + + '@esbuild/linux-loong64@0.25.4': + optional: true + + '@esbuild/linux-mips64el@0.18.20': + optional: true + + '@esbuild/linux-mips64el@0.25.4': + optional: true + + '@esbuild/linux-ppc64@0.18.20': + optional: true + + '@esbuild/linux-ppc64@0.25.4': + optional: true + + '@esbuild/linux-riscv64@0.18.20': + optional: true + + '@esbuild/linux-riscv64@0.25.4': + optional: true + + '@esbuild/linux-s390x@0.18.20': + optional: true + + '@esbuild/linux-s390x@0.25.4': + optional: true + + '@esbuild/linux-x64@0.18.20': + optional: true + + '@esbuild/linux-x64@0.25.4': + optional: true + + '@esbuild/netbsd-arm64@0.25.4': + optional: true + + '@esbuild/netbsd-x64@0.18.20': + optional: true + + '@esbuild/netbsd-x64@0.25.4': + optional: true + + '@esbuild/openbsd-arm64@0.25.4': + optional: true + + '@esbuild/openbsd-x64@0.18.20': + optional: true + + '@esbuild/openbsd-x64@0.25.4': + optional: true + + '@esbuild/sunos-x64@0.18.20': + optional: true + + '@esbuild/sunos-x64@0.25.4': + optional: true + + '@esbuild/win32-arm64@0.18.20': + optional: true + + '@esbuild/win32-arm64@0.25.4': + optional: true + + '@esbuild/win32-ia32@0.18.20': + optional: true + + '@esbuild/win32-ia32@0.25.4': + optional: true + + '@esbuild/win32-x64@0.18.20': + optional: true + + '@esbuild/win32-x64@0.25.4': + optional: true + + '@types/node@22.15.19': + dependencies: + undici-types: 6.21.0 + + '@types/pg@8.15.2': + dependencies: + '@types/node': 22.15.19 + pg-protocol: 1.10.0 + pg-types: 4.0.2 + + buffer-from@1.1.2: {} + + debug@4.4.1: + dependencies: + ms: 2.1.3 + + dotenv@16.5.0: {} + + drizzle-kit@0.31.1: + dependencies: + '@drizzle-team/brocli': 0.10.2 + '@esbuild-kit/esm-loader': 2.6.5 + esbuild: 0.25.4 + esbuild-register: 3.6.0(esbuild@0.25.4) + transitivePeerDependencies: + - supports-color + + drizzle-orm@0.43.1(@types/pg@8.15.2)(pg@8.16.0): + optionalDependencies: + '@types/pg': 8.15.2 + pg: 8.16.0 + + esbuild-register@3.6.0(esbuild@0.25.4): + dependencies: + debug: 4.4.1 + esbuild: 0.25.4 + transitivePeerDependencies: + - supports-color + + esbuild@0.18.20: + optionalDependencies: + '@esbuild/android-arm': 0.18.20 + '@esbuild/android-arm64': 0.18.20 + '@esbuild/android-x64': 0.18.20 + '@esbuild/darwin-arm64': 0.18.20 + '@esbuild/darwin-x64': 0.18.20 + '@esbuild/freebsd-arm64': 0.18.20 + '@esbuild/freebsd-x64': 0.18.20 + '@esbuild/linux-arm': 0.18.20 + '@esbuild/linux-arm64': 0.18.20 + '@esbuild/linux-ia32': 0.18.20 + '@esbuild/linux-loong64': 0.18.20 + '@esbuild/linux-mips64el': 0.18.20 + '@esbuild/linux-ppc64': 0.18.20 + '@esbuild/linux-riscv64': 0.18.20 + '@esbuild/linux-s390x': 0.18.20 + '@esbuild/linux-x64': 0.18.20 + '@esbuild/netbsd-x64': 0.18.20 + '@esbuild/openbsd-x64': 0.18.20 + '@esbuild/sunos-x64': 0.18.20 + '@esbuild/win32-arm64': 0.18.20 + '@esbuild/win32-ia32': 0.18.20 + '@esbuild/win32-x64': 0.18.20 + + esbuild@0.25.4: + optionalDependencies: + '@esbuild/aix-ppc64': 0.25.4 + '@esbuild/android-arm': 0.25.4 + '@esbuild/android-arm64': 0.25.4 + '@esbuild/android-x64': 0.25.4 + '@esbuild/darwin-arm64': 0.25.4 + '@esbuild/darwin-x64': 0.25.4 + '@esbuild/freebsd-arm64': 0.25.4 + '@esbuild/freebsd-x64': 0.25.4 + '@esbuild/linux-arm': 0.25.4 + '@esbuild/linux-arm64': 0.25.4 + '@esbuild/linux-ia32': 0.25.4 + '@esbuild/linux-loong64': 0.25.4 + '@esbuild/linux-mips64el': 0.25.4 + '@esbuild/linux-ppc64': 0.25.4 + '@esbuild/linux-riscv64': 0.25.4 + '@esbuild/linux-s390x': 0.25.4 + '@esbuild/linux-x64': 0.25.4 + '@esbuild/netbsd-arm64': 0.25.4 + '@esbuild/netbsd-x64': 0.25.4 + '@esbuild/openbsd-arm64': 0.25.4 + '@esbuild/openbsd-x64': 0.25.4 + '@esbuild/sunos-x64': 0.25.4 + '@esbuild/win32-arm64': 0.25.4 + '@esbuild/win32-ia32': 0.25.4 + '@esbuild/win32-x64': 0.25.4 + + fsevents@2.3.3: + optional: true + + get-tsconfig@4.10.0: + dependencies: + resolve-pkg-maps: 1.0.0 + + ms@2.1.3: {} + + obuf@1.1.2: {} + + pg-cloudflare@1.2.5: + optional: true + + pg-connection-string@2.9.0: {} + + pg-int8@1.0.1: {} + + pg-numeric@1.0.2: {} + + pg-pool@3.10.0(pg@8.16.0): + dependencies: + pg: 8.16.0 + + pg-protocol@1.10.0: {} + + pg-types@2.2.0: + dependencies: + pg-int8: 1.0.1 + postgres-array: 2.0.0 + postgres-bytea: 1.0.0 + postgres-date: 1.0.7 + postgres-interval: 1.2.0 + + pg-types@4.0.2: + dependencies: + pg-int8: 1.0.1 + pg-numeric: 1.0.2 + postgres-array: 3.0.4 + postgres-bytea: 3.0.0 + postgres-date: 2.1.0 + postgres-interval: 3.0.0 + postgres-range: 1.1.4 + + pg@8.16.0: + dependencies: + pg-connection-string: 2.9.0 + pg-pool: 3.10.0(pg@8.16.0) + pg-protocol: 1.10.0 + pg-types: 2.2.0 + pgpass: 1.0.5 + optionalDependencies: + pg-cloudflare: 1.2.5 + + pgpass@1.0.5: + dependencies: + split2: 4.2.0 + + postgres-array@2.0.0: {} + + postgres-array@3.0.4: {} + + postgres-bytea@1.0.0: {} + + postgres-bytea@3.0.0: + dependencies: + obuf: 1.1.2 + + postgres-date@1.0.7: {} + + postgres-date@2.1.0: {} + + postgres-interval@1.2.0: + dependencies: + xtend: 4.0.2 + + postgres-interval@3.0.0: {} + + postgres-range@1.1.4: {} + + resolve-pkg-maps@1.0.0: {} + + source-map-support@0.5.21: + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + + source-map@0.6.1: {} + + split2@4.2.0: {} + + tsx@4.19.4: + dependencies: + esbuild: 0.25.4 + get-tsconfig: 4.10.0 + optionalDependencies: + fsevents: 2.3.3 + + undici-types@6.21.0: {} + + xtend@4.0.2: {} diff --git a/src/db/schema.ts b/src/db/schema.ts new file mode 100644 index 0000000..538bc1b --- /dev/null +++ b/src/db/schema.ts @@ -0,0 +1,476 @@ +// drizzle-orm schema definition – natural‑key version +// --------------------------------------------------------------- +// Users now use their *blockchain address* (text) as primary key +// SwapPools likewise use their pool address as primary key +// All foreign‑key columns updated accordingly +// --------------------------------------------------------------- +import { + bigint, + bigserial, + boolean, + integer, + numeric, + pgEnum, + pgTable, + point, + primaryKey, + text, + timestamp, + uniqueIndex, + varchar, +} from "drizzle-orm/pg-core"; + +// --------------------------------------------------------------- +// 1. ENUM types +// --------------------------------------------------------------- +export const userRole = pgEnum("user_role", [ + "USER", + "ADMIN", + "STAFF", + "SUPER_ADMIN", +]); + +export const genderKind = pgEnum("gender_kind", [ + "MALE", + "FEMALE", + "OTHER", + "UNSPECIFIED", +]); +export const swapPoolFiatDepositType = pgEnum("swap_pool_fiat_deposit_type", [ + "FIAT_DEPOSIT", + "CRYPTO_DEPOSIT", +]); +export const commodityKind = pgEnum("commodity_kind", ["GOOD", "SERVICE"]); +export const frequencyKind = pgEnum("frequency_kind", [ + "ONCE", + "DAILY", + "WEEKLY", + "MONTHLY", +]); +export const reportStatus = pgEnum("report_status", [ + "DRAFT", + "SUBMITTED", + "APPROVED", + "REJECTED", +]); +export const voucherKind = pgEnum("voucher_kind", [ + "DEMURRAGE_ERC20", + "ERC20", + "EXPIRING_ERC20", +]); +export const gasGiftStatus = pgEnum("gas_gift_status", [ + "NONE", + "PENDING", + "APPROVED", + "DECLINED", +]); +export const contactKind = pgEnum("contact_kind", ["EMAIL", "PHONE", "SOCIAL"]); + +export const notificationKind = pgEnum("notification_kind", [ + "SYSTEM", // System-generated notifications + "USER_MESSAGE", // Direct user-to-user messages + "OFFERING_NEW", // New offering in your area/interests + "OFFERING_UPDATE", // Offering you're watching was updated + "FIELD_REPORT_NEW", // New field report + "FIELD_REPORT_STATUS", // Field report status changed + "GAS_GIFT_STATUS", // Gas gift status update + "VOUCHER_NEW", // New voucher available + "SWAP_POOL_UPDATE", // Swap pool updates + "VERIFICATION_REQUEST", // Verification requested + "ADMIN_NOTICE", // Administrative notices +]); + +export const notificationStatus = pgEnum("notification_status", [ + "UNREAD", + "READ", + "ARCHIVED", +]); + +export const notificationPriority = pgEnum("notification_priority", [ + "LOW", + "NORMAL", + "HIGH", + "URGENT", +]); + +// --------------------------------------------------------------- +// 2. Core tables +// --------------------------------------------------------------- +export const users = pgTable("users", { + address: text("address").primaryKey(), // PK + role: userRole("role").notNull().default("USER"), + gasGiftStatus: gasGiftStatus("gas_gift_status").notNull().default("NONE"), + gasApproverAddr: text("gas_approver_addr").references(() => users.address), + defaultVoucherAddr: text("default_voucher_addr").references( + () => vouchers.address + ), + activated: boolean("activated").notNull().default(false), // ?? + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }) + .notNull() + .defaultNow(), +}); + +export const userProfiles = pgTable("user_profiles", { + userAddress: text("user_address") + .primaryKey() + .references(() => users.address, { onDelete: "cascade" }), + yearOfBirth: integer("year_of_birth"), + gender: genderKind("gender"), + familyName: text("family_name"), + givenNames: text("given_names"), + locationName: text("location_name"), + geo: point("geo"), + languageCode: varchar("language_code", { length: 3 }).default("eng"), + profilePictureUrl: text("profile_picture_url"), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }) + .notNull() + .defaultNow(), +}); + +// --------------------------------------------------------------- +// 3. Vouchers & issuers (unchanged) +// --------------------------------------------------------------- +export const vouchers = pgTable("vouchers", { + address: text("address").primaryKey(), + symbol: text("symbol").notNull(), // TODO: Should this just come from the chain? + name: text("name").notNull(), // TODO: Should this just come from the chain? + description: text("description").notNull(), + sinkAddress: text("sink_address").notNull(), // TODO: Should this just come from the chain? + kind: voucherKind("kind").notNull(), + value: integer("value").notNull().default(10), // TODO: Where is this used + uoa: text("uoa").notNull().default("KES"), + internal: boolean("internal").notNull().default(false), + iconUrl: text("icon_url"), + bannerUrl: text("banner_url"), + locationName: text("location_name"), + geo: point("geo"), + customTerms: text("custom_terms"), + contractVersion: text("contract_version").notNull(), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), +}); + +export const voucherIssuers = pgTable("voucher_issuers", { + id: bigserial("id", { mode: "number" }).primaryKey(), + voucherAddress: text("voucher_addr") + .notNull() + .references(() => vouchers.address, { onDelete: "cascade" }), + issuerAddress: text("issuer_address") + .notNull() + .references(() => users.address, { onDelete: "cascade" }), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }) + .notNull() + .defaultNow(), +}); + +// --------------------------------------------------------------- +// 4. Offerings +// --------------------------------------------------------------- + +export const offerings = pgTable("offerings", { + id: bigserial("id", { mode: "number" }).primaryKey(), + kind: commodityKind("kind").notNull(), + name: text("name").notNull(), + description: text("description").notNull(), + sellerAddress: text("seller_address") + .notNull() + .references(() => users.address, { onDelete: "cascade" }), + voucherAddr: text("voucher_addr") + .notNull() + .references(() => vouchers.address, { onDelete: "cascade" }), + quantity: integer("quantity").notNull(), + frequency: frequencyKind("frequency").notNull(), + price: integer("price").notNull().default(0), + available: boolean("available").notNull().default(true), + locationName: text("location_name"), + geo: point("geo"), + imageUrl: text("image_url"), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }) + .notNull() + .defaultNow(), +}); + +// --------------------------------------------------------------- +// 5. Tags & field reports +// --------------------------------------------------------------- +export const tags = pgTable("tags", { + id: bigserial("id", { mode: "number" }).primaryKey(), + tag: text("tag").notNull().unique(), +}); + +export const fieldReports = pgTable("field_reports", { + id: bigserial("id", { mode: "number" }).primaryKey(), + title: text("title").notNull(), + body: text("body").notNull(), + imageUrl: text("image_url").notNull(), + description: text("description"), + locationName: text("location_name"), + geo: point("geo"), + periodFrom: timestamp("period_from", { withTimezone: true }), + periodTo: timestamp("period_to", { withTimezone: true }), + status: reportStatus("status").notNull().default("DRAFT"), + rejectionReason: text("rejection_reason"), + createdByAddr: text("created_by_addr") + .notNull() + .references(() => users.address), + modifiedByAddr: text("modified_by_addr") + .notNull() + .references(() => users.address), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }) + .notNull() + .defaultNow(), +}); + +export const fieldReportTags = pgTable( + "field_report_tags", + { + reportId: bigint("report_id", { mode: "number" }) + .notNull() + .references(() => fieldReports.id, { onDelete: "cascade" }), + tagId: bigint("tag_id", { mode: "number" }) + .notNull() + .references(() => tags.id, { onDelete: "cascade" }), + }, + (t) => [primaryKey({ columns: [t.reportId, t.tagId] })] +); + +export const fieldReportVouchers = pgTable( + "field_report_vouchers", + { + reportId: bigint("report_id", { mode: "number" }) + .notNull() + .references(() => fieldReports.id, { onDelete: "cascade" }), + voucherAddr: text("voucher_addr") + .notNull() + .references(() => vouchers.address, { onDelete: "cascade" }), + }, + (t) => [primaryKey({ columns: [t.reportId, t.voucherAddr] })] +); + +export const fieldReportVerifications = pgTable( + "field_report_verifications", + { + reportId: bigint("report_id", { mode: "number" }) + .notNull() + .references(() => fieldReports.id, { onDelete: "cascade" }), + userAddr: text("user_addr") + .notNull() + .references(() => users.address, { onDelete: "cascade" }), + verifiedAt: timestamp("verified_at", { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (t) => [primaryKey({ columns: [t.reportId, t.userAddr] })] +); + +// --------------------------------------------------------------- +// 6. Swap pools & tags – address as PK +// --------------------------------------------------------------- +export const swapPools = pgTable("swap_pools", { + address: text("address").primaryKey(), + description: text("description").notNull(), + bannerUrl: text("banner_url"), + customTerms: text("custom_terms"), + defaultVoucherAddr: text("default_voucher_addr").references( + () => vouchers.address, + { onDelete: "set null" } + ), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }), +}); + +export const swapPoolTags = pgTable( + "swap_pool_tags", + { + poolAddress: text("pool_address") + .notNull() + .references(() => swapPools.address, { onDelete: "cascade" }), + tagId: bigint("tag_id", { mode: "number" }) + .notNull() + .references(() => tags.id, { onDelete: "cascade" }), + }, + (t) => [primaryKey({ columns: [t.poolAddress, t.tagId] })] +); + +// --------------------------------------------------------------- +// 7. Contact‑info tables (updated FKs) +// --------------------------------------------------------------- +export const userContacts = pgTable( + "user_contacts", + { + id: bigserial("id", { mode: "number" }).primaryKey(), + userAddress: text("user_address") + .notNull() + .references(() => users.address, { onDelete: "cascade" }), + kind: contactKind("kind").notNull(), + value: text("value").notNull(), + platform: text("platform"), + verified: boolean("verified").notNull().default(false), + verifiedAt: timestamp("verified_at", { withTimezone: true }), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (t) => [ + uniqueIndex("idx_user_contacts_unique").on(t.userAddress, t.kind, t.value), + ] +); + +export const voucherContacts = pgTable( + "voucher_contacts", + { + id: bigserial("id", { mode: "number" }).primaryKey(), + voucherAddr: text("voucher_addr") + .notNull() + .references(() => vouchers.address, { onDelete: "cascade" }), + kind: contactKind("kind").notNull(), + value: text("value").notNull(), + platform: text("platform"), + verified: boolean("verified").notNull().default(false), + verifiedAt: timestamp("verified_at", { withTimezone: true }), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (t) => [ + uniqueIndex("idx_voucher_contacts_unique").on( + t.voucherAddr, + t.kind, + t.value + ), + ] +); + +export const swapPoolContacts = pgTable( + "swap_pool_contacts", + { + id: bigserial("id", { mode: "number" }).primaryKey(), + poolAddress: text("pool_address") + .notNull() + .references(() => swapPools.address, { onDelete: "cascade" }), + kind: contactKind("kind").notNull(), + value: text("value").notNull(), + platform: text("platform"), + verified: boolean("verified").notNull().default(false), + verifiedAt: timestamp("verified_at", { withTimezone: true }), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (t) => [ + uniqueIndex("idx_swap_pool_contacts_unique").on( + t.poolAddress, + t.kind, + t.value + ), + ] +); + +// --------------------------------------------------------------- +// 8. Notifications +// --------------------------------------------------------------- +export const notifications = pgTable( + "notifications", + { + id: bigserial("id", { mode: "number" }).primaryKey(), + recipientAddr: text("recipient_addr") + .notNull() + .references(() => users.address, { onDelete: "cascade" }), + senderAddr: text("sender_addr").references(() => users.address, { + onDelete: "set null", + }), + kind: notificationKind("kind").notNull(), + status: notificationStatus("status").notNull().default("UNREAD"), + priority: notificationPriority("priority").notNull().default("NORMAL"), + title: text("title").notNull(), + body: text("body").notNull(), + imageUrl: text("image_url"), + actionUrl: text("action_url"), // Deep link or URL for action + actionLabel: text("action_label"), // Button text like "View Offering" + // Generic reference fields for linking to any entity + refOfferingId: bigint("ref_offering_id", { mode: "number" }).references( + () => offerings.id, + { onDelete: "cascade" } + ), + refFieldReportId: bigint("ref_field_report_id", { + mode: "number", + }).references(() => fieldReports.id, { onDelete: "cascade" }), + refVoucherAddr: text("ref_voucher_addr").references( + () => vouchers.address, + { + onDelete: "cascade", + } + ), + refSwapPoolAddr: text("ref_swap_pool_addr").references( + () => swapPools.address, + { onDelete: "cascade" } + ), + // Metadata + metadata: text("metadata"), // JSON string for additional data + expiresAt: timestamp("expires_at", { withTimezone: true }), + readAt: timestamp("read_at", { withTimezone: true }), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (t) => [ + // Indexes for common queries + uniqueIndex("idx_notifications_recipient_created").on( + t.recipientAddr, + t.createdAt + ), + uniqueIndex("idx_notifications_recipient_status").on( + t.recipientAddr, + t.status + ), + uniqueIndex("idx_notifications_kind_created").on(t.kind, t.createdAt), + ] +); + +// --------------------------------------------------------------- +// 9. Donations & Fiat Origins +// --------------------------------------------------------------- +export const fiatOrigins = pgTable("fiat_origins", { + id: bigserial("id", { mode: "number" }).primaryKey(), + donorEmail: text("donor_email"), + fiatReference: text("fiat_reference"), + fiatCurrency: varchar("fiat_currency", { length: 10 }), + fiatAmount: numeric("fiat_amount", { precision: 20, scale: 2 }), + conversionRate: numeric("conversion_rate", { precision: 20, scale: 8 }), + convertedTokenAddress: text("converted_token_address"), + convertedAmount: numeric("converted_amount", { precision: 38, scale: 18 }), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), +}); + +export const donations = pgTable("donations", { + id: bigserial("id", { mode: "number" }).primaryKey(), + txHash: text("tx_hash").unique(), + donorAddress: text("donor_address").notNull(), + tokenAddress: text("token_address").notNull(), + amount: numeric("amount", { precision: 38, scale: 18 }).notNull(), + fiatOriginId: integer("fiat_origin_id").references(() => fiatOrigins.id), + purpose: text("purpose"), + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), +});