This directory contains scripts to set up the necessary database tables for the Crypto Payment API.
- virtual_accounts - Stores information about virtual accounts created for users
- pending_crypto_transfers - Tracks pending crypto transfers associated with virtual accounts
- Node.js installed
.envfile with Supabase credentials (SUPABASE_URL and SUPABASE_SERVICE_KEY)
# Install dependencies if needed
npm install @supabase/supabase-js dotenv
# Run the script
node create_tables.js# Install dependencies if needed
npm install axios dotenv
# Run the script
node create_tables_direct.js# Install dependencies if needed
npm install axios dotenv
# Run the script
node create_tables_sql.jsCREATE TABLE public.virtual_accounts (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID NOT NULL REFERENCES public.users(id),
reference VARCHAR NOT NULL,
account_reference VARCHAR NOT NULL,
status VARCHAR NOT NULL,
account_details JSONB NOT NULL,
is_permanent BOOLEAN DEFAULT false,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ,
expires_at TIMESTAMPTZ,
transaction_reference VARCHAR,
paid_at TIMESTAMPTZ
);CREATE TABLE public.pending_crypto_transfers (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID NOT NULL REFERENCES public.users(id),
crypto_type VARCHAR NOT NULL,
wallet_address VARCHAR,
account_number VARCHAR NOT NULL,
status VARCHAR NOT NULL DEFAULT 'pending',
created_at TIMESTAMPTZ DEFAULT NOW(),
completed_at TIMESTAMPTZ,
transaction_id UUID,
error_message TEXT
);If you encounter errors when running the scripts:
- Make sure your Supabase URL and service key are correct in the
.envfile - Check that you have the necessary permissions to create tables in the database
- Try running the SQL statements directly in the Supabase SQL editor
- If using the REST API, ensure your Supabase instance has the SQL API enabled