Warehouse
Key
warehouse_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
Key
vendor_id    
bigint
nickname    
varchar(55)
warehouse_dba    
varchar
warehouse_location    
varchar
NN
warehouse_name    
text
NN
warehouse_address1    
text
NN
warehouse_address2    
text
NN
warehouse_city    
text
NN
warehouse_state    
text
NN
warehouse_zipcode    
text
NN
warehouse_country    
text
NN
online_inventory_website    
text
online_inventory_username    
varchar
online_inventory_password    
varchar
qbs_warehouse_location_id    
varchar
allow_same_day_orders    
boolean
billable    
boolean
NN
timezone    
integer(2)
NN
fees    
jsonb
lumping_fee    
integer
ctr_unloading_fee    
integer
own_pallet_with_product    
varchar
pallet_exchange    
boolean
rate_sheet    
varchar
warehouse_holidays    
varchar
operation_days    
jsonb
NN
operation_days_roles    
jsonb
warehouse_attributes    
jsonb
is_deleted    
boolean
appointment_website    
text
search_vector    
tsvector
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
modified_at    
timestamptz
Key
modified_by_user_id    
bigint
NN
List of warehouses and Cold Storages. Should have logic in that if a product has a cold storage linked to it, it can't be deleted. Need to link it to a vendor so we can pay them!
Customers
Key
customer_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
customer_name    
varchar(41)
NN
customer_dba    
varchar(41)
customer_name_listed_as    
varchar(41)
nickname    
varchar(40)
used_to_be_called    
varchar(41)
used_to_be_called_date_change    
date
Key
user_id    
bigint
NN
quickbooks_cust_id    
varchar
erp_custom_id    
varchar
Key
customer_type    
bigint
NN
sellable    
boolean
order_frequency    
integer
order_frequency_days    
integer
avg_order_day    
varchar
bill_by_dba    
boolean
our_vendor_number    
varchar(25)
credit_insured    
boolean
credit_limit    
integer(15)
average_pay_time    
integer(3)
current_balance_owed    
integer(18)
Key
default_shipping_vendor_id    
bigint
default_shipping_vendor_instructions    
text
email_sending_category_id    
integer(3)
product_customer_usually_buys    
varchar
Key
accounting_contact    
jsonb
is_deleted    
boolean
status    
varchar(50)
Key
payment_term_id    
bigint
NN
Key
default_ship_terms_id    
bigint
is_tax_exempt    
boolean
tax_exemption_number    
text
tax_exemption_expiry    
date
search_vector    
tsvector
Since ANY and ALL Sales data is listed under the Sales table, it is accessable via the Customer UUID and UUID of the Sale. Therefore, anything that is associated on a separate table will be JOINed together on the frontend. Routing seems hectic, but it makes sense database wise.
Orders
Key
order_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
Key
customer_id    
bigint
NN
customer_billing_city    
varchar(50)
NN
customer_billing_state    
integer
NN
customer_billing_address    
jsonb
NN
customer_po_number    
varchar(25)
NN
Key
warehouse_id    
bigint
NN
Key
order_type_id    
bigint
NN
order_rush    
boolean
order_number    
text
NN
order_sent_on    
timestamptz
NN
Key
trucker_id    
bigint
Key
ship_term    
integer
order_first_created_date    
timestamptz
NN
special_instructions_note    
varchar(300)
Key
payment_terms_id    
bigint
NN
Key
order_status_id    
serial
NN
Key
created_by_user_id    
bigint
NN
created_at    
timestamptz
NN
Key
last_modified_by    
bigint
NN
last_modified    
timestamptz
order_sent_in    
timestamptz
order_confirmed_back    
timestamptz
shipping_bol    
varchar(50)
trucking_po    
bigserial
total_pallets    
numeric(10, 2)
NN
assumed_total_pallets    
numeric(10, 2)
NN
searchable_content    
tsvector
is_voided    
boolean
search_vector    
tsvector
This is the barebones table. It will utilize IDs to make it quick! ANYTHING that is listed in another table can be pulled up from just using the ID from another table and joining the details. Crazy! This means I don't add the following: customer billing city and state, This pertains to the specific details of this order. Order Items pertains to all the products apart of the order! **Since pulling the customer over by the UUID, do I really need to have the data of the following or can I just JOIN or grab it:? Billing City and Billing State ??? Why are there PKs that I can't delete??? Need to do more research on when to PK and Not. Also, need to do FKs, but need to know how to later! Houses details fo the order
Web_App_Customer
Key
web_app_customer_id    
bigserial
NN
external_id    
uuid
NN
company_name    
varchar(41)
NN
name    
varchar(255)
NN
email    
varchar(255)
NN
Key
language_code    
text
created_at    
timestamptz
NN
updated_at    
timestamptz
NN
last_active    
timestamptz
is_inactive    
boolean
inactive_since    
timestamptz
undeleteable    
boolean
payment_status    
varchar
NN
is_on_trial    
boolean
trial_start_date    
timestamptz
trial_end_date    
timestamptz
is_subscription_active    
boolean
Key
subscription_plan_id    
integer
billing_start_date    
timestamptz
NN
billing_end_date    
timestamptz
NN
is_deleted????    
boolean
disk_quota    
bigint
NN
is_anonymized    
boolean
NN
deleted_at    
timestamptz
This is the master list of the web app customers. Company IDs are assigned in here and those are the UUIDs. Allowsing SOFT DELETE for the system. Hard Deteting for select options. Most are SOFT DELETE via is_delete or is_voided
Order_Type
Key
order_type_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
order_type_name    
varchar(30)
description    
text
Roles
Key
role_id    
bigserial
NN
role_name    
varchar(30)
NN
role_permission    
integer
NN
You can name roles here. Need to figure out how it works
Customer_Type
Key
customer_type_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
customer_type_name    
varchar
NN
sellable    
text
customer_type_description    
text
Think this will be a table, but not fully sure. Still processing and thinking things through. Same as Sellable table...
Payment Terms
Key
payment_term_id    
bigserial
NN
Key
web_customer_id    
bigint
NN
payment_name    
integer
NN
payment_days    
integer
NN
payment_description    
text
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
updated_at    
timestamptz
NN
Key
updated_by_user_id    
bigint
NN
Ship_terms
Key
ship_terms_id    
integer
NN
Key
web_app_customer    
bigserial
NN
ship_terms_name    
varchar(20)
NN
ship_terms_description    
text
simply lists it on the order. Not for us, but for them. But, if Pre-Paid, it automatically makes it a custom Trucking PO we make.
Languages
Key
languages_code    
text
NN
language_name    
text
NN
native_name    
text
locale_tag    
text
direction_text    
text
Each section title and any other text can be stored with a language identifier.
Inventory***
Key
inventory_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
Key
product_id    
bigint
NN
Key
purchase_order_id    
bigint
NN
Key
warehouse_id    
bigint
NN
Key
lot_number    
varchar(50)
NN
available_product_quantity    
numeric(10, 2)
NN
on_special    
boolean
case_per pallet    
integer
case_ti    
integer
case_hi    
integer
cost_price    
numeric(10, 2)
NN
anniversary_date    
date
NN
comments    
text
tlc_code    
varchar(255)
pack_date    
date
pack_date_text    
varchar(20)
expire_date    
date
expire_date_text    
varchar(20)
received_in_date    
date
NN
received_in_at    
timestamptz
NN
Key
received_in_by_user_id    
bigint
NN
last_updated    
timestamptz
Key
last_updated_user_id    
bigint
quantity    
integer
NN
lot_hold    
boolean
NN
is_phantom    
boolean
NN
demand_tag    
varchar(50)
search_vector    
tsvector
Products -> These are details that you set and don't change or add to. Inventory-> these are variable details that get assigned to prducts when received in.
Product
Key
product_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
product_sku    
varchar(40)
quickbooks_product_id    
integer
product_size    
varchar
product_family    
varchar
NN
product_short_description    
varchar
NN
product_full_description    
varchar
pack_size    
varchar
Key
product_origin_id    
integer(3)
NN
upc_outer    
varchar
upc_inner    
varchar
partials_per_case    
integer
NN
case_net_weight    
integer
NN
case_gross_weight    
integer
NN
Key
product_utm_id    
varchar(4)
NN
Key
bill_by    
bigint
NN
Key
catch_method    
integer
NN
latin_name    
varchar
FAO    
jsonb
special_import_requirements    
jsonb
dimensions    
jsonb
average_lead_time    
integer
reorder_threshold    
integer
reorder_alert    
integer
low_inventory_alert    
integer
special_import_requirements    
varchar
Key
selling_season    
bigserial
upc_number    
jsonb
dimensions    
jsonb
cooking_instructions    
jsonb
Key
harvest_season_id    
serial
Key
product_photo_id    
uuid
is_deleted    
boolean
Key
product_document_id    
bigserial
Key
chart_of_accounts_type    
bigint
NN
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
Key
last_modified_user_id    
bigint
NN
search_vector    
tsvector
An idea with this is to be able to build a spec sheet if need be for web app customers instead of doing them by hand. A template will need to be made. I would say that anything that is not filled in will not show up on the frontend to the user unless they are in settings of setting up products. Any non usual select queries convert to JSONb (UPCs, Seasons,
Catch_method
Key
catch_method_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
catch_method_name    
varchar
NN
description    
text
Advanced_settings**
Key
advanced_settings_id    
serial
NN
Key
web_app_customer    
bigint
NN
set_po_number_global    
varchar
set_po_number_prefix    
boolean
NN
po_number_prefix_per_user    
boolean
quickbooks_integration_api    
varchar
warehouse_starting_order_number    
varchar
prefix_per_order_number_by_salesman    
boolean
global_snooze_setting    
varchar
will be a work in progress... Divvy up based off Inventory, CRM, etc...
Company_global_settings**
Key
id    
integer
NN
I think I need a global settings table to house customer settings. Advanced settings is for advanced settings that don't belong in standard settings like theme, langauage, time zone, ltr, etc. Global is the DEFAULT settings.
User_settings**
Key
user_settings_id    
serial
NN
Key
web_app_customer    
bigint
NN
salesman_prefix_to_order_number    
varchar(6)
allow_sales_popcards    
boolean
I do want settings for a per user basis. For example, some like a specific theme whereas some like darkmode. I want to be able to offer that to them. Not sure if languages would be for global for the customer or on a per user basis. The issue is how would it be a specific language? Like, global is English, but the user is Spanish. Would an admin or manager be able to add another language description to the product? More things to consider and think out!!
Bill_by** (aka "Sell By")
Key
bill_by_id    
bigserial
NN
Key
product_id    
bigint
NN
Key
web_app_customer    
bigint
NN
bill_by_name    
varchar
NN
description    
text
More in-depth thinking needs to figure what this is for specifically! would we need UTM???
Purchase Order Details
Key
purchase_order_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
Key
vendor_id    
bigint
NN
purchase_order_number    
varchar
NN
pack_date    
date
expiration_date    
date
tlc_code    
varchar(30)
Key
purchase_order_items    
bigserial
purchase_order_type***    
serial
NN
Purchase_order_sent    
timestamptz
NN
expected_bill_total    
numeric(12, 2)
Key
payment_term_id    
bigint
NN
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
Key
last_modified_user_id    
bigint
NN
status    
varchar(20)
NN
Key
destination_country    
integer
NN
freight_cost    
numeric(10,2)
search_vector    
tsvector
Vendors**
Key
vendor_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
vendor_name    
varchar(41)
NN
vendor_dba    
varchar(41)
vendor_nickname    
varchar(41)
preferred_vendor    
boolean
Key
vendor_type_id    
serial
vendor_specialties    
varchar(300)
NN
plant_number    
varchar(20)
plant_code    
varchar(20)
fda_registration_number    
varchar(20)
china_registration_number    
varchar(20)
canadian_registration_number    
varchar(20)
eu_registration_number    
varchar(20)
registration_number    
varchar(20)
Key
accounts_receivable_country_id    
integer(3)
accounts_receivable_zipcode    
varchar(10)
vendor_website    
varchar(100)
vendor_insured    
boolean
vendor_insured_coverage_amount    
varchar
paycargo    
boolean
paycargo_website    
varchar(300)
vendor_login_username    
varchar(100)
vendor_login_password    
varchar(100)
Key
vendor_shipping_destination_id    
serial
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
Key
last_modified_user_id    
bigint
NN
Key
payment_terms_id    
bigint
NN
Key
default_ship_terms_id    
bigint
NN
search_vector    
tsvector
**Need to figure out how to tie products to a specific vendor. Would it be divvy'd up with "vendor details" and "vendor products" I think the details are JOINed together with the Vendors table
Recalls** - NEED HELP
Key
recall_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
recall_real_or_mock    
boolean
NN
Key
inventory_product    
bigint
NN
Key
customer_orders    
bigint
NN
This is for recalls. *Might need to add another table or more for all the things pertaining to one.
Order Line Items
Key
order_item_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
Key
order_id    
bigint
NN
Key
inventory_product_id    
bigint
NN
Key
inventory_lot_number    
varchar
NN
product_quantity    
numeric(10,2)
NN
clean_out    
boolean
product_price    
numeric(10, 6)
price_is_delivered    
boolean
pallets_total    
numeric(10, 2)
NN
Considering it to be named "Order Products" This actually houses the items/products in the actual order. The Order table just houses the order details because customer_orders_id (changing to orders_id) has to be 1 number and it can't repeat. This is where multiple products can be added Same goes for Invoices... Same concept!
invoices
Key
invoice_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
Key
order_id    
bigint
NN
invoice_number    
text
NN
invoice_date    
date
NN
due_date    
date
currency_code**    
varchar(3)
NN
subtotal    
numeric((12, 2))
tax****    
numeric((12, 2))
total_amount    
numeric((12, 2))
order_type_name    
text
NN
payment_status    
text
NN
status    
text
NN
billing_address    
text
shipping_address    
text
Key
created_automatically_by_user_id    
bigint
NN
created_at    
timestamptz
NN
Key
voided_by_user_id    
bigint
voided_at    
timestamptz
voided_reason    
text
customer_billing_address    
jsonb
NN
customer_po    
text
NN
Key
trucker_id    
bigint
Key
salesman    
bigint
NN
searchable_content    
tsvector
Key
last_modified_by_user_id    
bigint
last_modified_at    
timestamptz
is_tax_applied    
boolean
tax_summary    
jsonb
payment_terms_id    
bigint
NN
search_vector    
tsvector
use_fx_conversion    
boolean
converted_amount    
numeric(12, 2)
exchange_rate    
numeric(20, 10)
exchange_rate_date    
date
**How to void?? Need to figure out how to add a constraint as follows: ALTER TABLE invoice ADD CONSTRAINT unique_invoice_number_per_customer UNIQUE (web_app_customer_id, invoice_number);
Global App Settings
Key
setting_id    
serial
NN
Key
setting_name    
varchar(100)
NN
setting_value    
text
NN
description_text    
text
NN
These are the main settings for the actual overall web app.
Popcards
Key
popcard_id    
bigserial
NN
web_app_customer    
bigint
NN
popcard_name    
varchar
NN
popcard_value    
varchar
NN
This is for helping salesmen sell when they might be on a call or selling something to someone or a prospect.
Vendor_type
Key
vendor_type_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
vendor_type_name    
varchar(30)
NN
description    
text
Country
Key
country_id    
serial
NN
country_name    
varchar(50)
NN
country_abreviation    
varchar(3)
NN
Vendor_products
Key
vendor_products_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
Key
vendor_id    
bigint
NN
Key
vendor_products    
bigint
search_vector    
tsvector
Purchase Order Line Items
Key
purchase_order_item_id    
bigserial
NN
Key
purchase_order_id    
bigint
NN
Key
web_app_customer_id    
bigint
NN
Key
product_id    
bigint
Key
service_id    
bigint
quantity    
numeric(10, 2)
NN
total_price    
numeric(10, 2)
NN
unit_price    
numeric(10, 6)
NN
Key
vendor_id    
bigserial
NN
CHECK ( -- Ensure that either product_id or service_id is set, not both (product_id IS NOT NULL AND service_id IS NULL) OR (service_id IS NOT NULL AND product_id IS NULL) This makes sure that either or is NOT NULL. Might need to use "DECIMAL" as the data type.
Session
Key
session_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
created_at    
timestamptz
expires_at    
timestamptz
NN
ip_address    
varchar(45)
NN
user_agent    
text
NN
mfa_verified    
boolean
NN
mfa_verified_at    
timestamptz
NN
This stores sessions for all users. It only stores 1 session per user.
Session Activities
Key
session_id    
uuid
NN
Key
user_id    
bigint
NN
ip_address    
varchar(45)
NN
user_agent    
text
NN
location    
varchar(255)
NN
login_time    
timestamptz
NN
last_activity    
timestamptz
NN
This stores activities of the last 5 or 10(?) sessions of a user to help compare if there is any anomolies to trigger MFA (2-factor authentication).
Sub Accounts
Key
user_id    
bigserial
NN
Key
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
username    
varchar(255)
NN
password_hash    
varchar(255)
NN
Key
user_role    
serial
NN
email    
varchar(100)
NN
cellphone    
varchar(21)
wechat    
varchar(50)
whatsapp    
varchar(50)
Key
language_code    
text
created_at    
timestamptz
is_deleted    
boolean
is_active    
boolean
updated_at    
timestamptz
disk_usage    
bigint
is_anonymized    
boolean
NN
deleted_at    
timestamptz
MFA Token
Key
token_id    
uuid
NN
Key
user_id    
bigint
NN
token    
varchar(6)
NN
expires_at    
timestamptz
NN
is_used    
boolean
NN
created_at    
timestamptz
NN
Backup Codes
Key
code_id    
uuid
NN
Key
user_id    
bigint
NN
backup_code    
varchar(12)
NN
is_used    
boolean
User Role
Key
user_id    
bigint
Key
role_id    
bigint
Settings
Key
setting_id    
bigserial
NN
setting_name    
varchar(100)
NN
setting_value    
text
NN
Role Settings
Key
role_id    
serial
NN
Key
setting_id    
bigint
NN
Using Aproach 2 Conection Limit 5 (max by user_id or by IP). user_id might be best. But maybe 2 or 3 connections max. I would have to see if browser tabs open relate to this max connection. But, it might be based off browser id... Idk?
User Specific Settings
Key
user_id    
bigint
NN
Key
setting_name    
varchar(100)
NN
setting_value    
text(100)
NN
Feature Specific Settings
Key
feature_setting_id    
serial
NN
feature_name    
varchar(100)
NN
setting_name    
varchar(100)
NN
setting_value    
text
NN
description_text    
text
NN
These are module specific settngs. IE: CRM, Inventory, Products Site, Accounting, etc...
System Settings
Key
setting_id    
serial
NN
setting_name    
varchar(100)
NN
setting_value    
text
NN
sensitive    
boolean
NN
description_text    
text
NN
Not sure if I need this. It seems to be a table used for admins for low-level settings. But, IDK...
Customer Contacts
Key
customer_contact_id    
bigserial
NN
external_id    
uuid
NN
Key
customer_id    
bigint
NN
Key
web_app_customer    
bigint
NN
buyer_position    
varchar(50)
buyer_firstname    
varchar(50)
NN
buyer_lastname    
varchar(50)
buyer_email    
varchar(100)
buyer_phone    
varchar(21)
buyer_phone_ext    
varchar(10)
buyer_phone_direct    
varchar(21)
buyer_mobile    
varchar(21)
buyer_mobile_sms    
boolean
buyer_wechat    
varchar(50)
buyer_whatsapp    
varchar(50)
receives_pricelist    
boolean
NN
is_deleted    
boolean
send_order_confirms    
boolean
NN
send_invoices_to    
boolean
NN
search_vector    
tsvector
is_active    
boolean
created_at    
timestamptz
is_user    
boolean
password_hash    
text
last_login    
timestamptz
invited_at    
timestamptz
accepted_invite_at    
timestamptz
UNIQUE (web_app_customer_id, email)
Vendor Contacts
Key
vendor_contact_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
Key
vendor_id    
bigint
NN
vendor_contact_position    
varchar(50)
NN
vendor_contact_nickname    
varchar(50)
vendor_contact_firstname    
varchar(50)
vendor_contact_lastname    
varchar(50)
vendor_contact_phone    
varchar(21)
vendor_contact_phone_ext    
varchar(10)
vendor_contact_cellphone    
varchar(21)
vendor_contact_sms    
boolean
vendor_contact_wechat    
varchar(50)
vendor_contact_whatsapp    
varchar(50)
vendor_contact_email    
varchar(100)
NN
created_at    
timestamptz
NN
Key
created_by_user_id    
bigserial
NN
last_modified    
timestamptz
NN
Key
last_modified_user_id    
bigserial
NN
search_vector    
tsvector
Some of the fields like "created_at" and "last_modified" might be for internal or deeper things for insights in the future...
Vendor Shipping Destination
Key
vendor_shipping destination_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
Key
vendor_shipping_destination    
varchar(100)
NN
search_vector    
tsvector
Product Harvest Season
Key
harvest_season_id    
serial
NN
Key
product_id    
bigint
NN
Key
web_app_customer    
bigint
NN
harvest_season_name    
varchar(40)
NN
harvest_season_start    
varchar(40)
NN
harvest_season_end    
varchar(40)
NN
description    
text
created_at    
timestamptz
Product UOM
Key
product_uom_id    
serial
NN
Key
product_id    
bigint
NN
Key
web_app_customer    
bigint
NN
product_uom_name    
varchar(20)
NN
product_uom_abbv    
varchar(4)
NN
description    
text
Is the product sold by the lb, case, etc.?
Warehouse Contacts
Key
warehouse_contact_type_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
Key
warehouse_id    
bigint
NN
contact_position    
varchar(50)
NN
warehouse_contact_name    
varchar(100)
NN
warehouse_contact_email    
varchar(100)
warehouse_contact_phone    
varchar(21)
warehouse_contact_phone_ext    
varchar(10)
warehouse_contact_mobile_sms    
boolean
warehouse_contact_mobile    
varchar(21)
warehouse_contact_wechat    
varchar(50)
warehouse_contact_whatsapp    
varchar(50)
Reminders
Key
reminders_id    
bigserial
NN
external_id    
uuid
NN
Key
user_id    
bigint
NN
Key
web_app_customer_id    
bigint
NN
reminder_title    
varchar(255)
NN
reminder_description    
text
reminder_time    
timestamptz
NN
is_recurring    
boolean
rexurring_interval    
varchar(50)
reminder_created_at    
timestamptz
is_deleted    
boolean
search_vector    
tsvector
Notifications
Key
notifications_id    
bigserial
NN
Key
reminders_id    
bigint
NN
notification_time    
timestamptz
NN
notification_status    
varchar(50)
search_vector    
tsvector
Subscription Plans
Key
subscription_plans_id    
integer
NN
subscription_plan_name    
varchar(255)
NN
max_sub_accounts    
integer
NN
subscription_price    
money
NN
subscription_duration_in_days    
integer
NN
subscription_start_date    
timestamptz
subscription_end_date    
timestamptz
Key
core_currency_id    
integer
features    
text
core_web_app_currencies
Key
core_currency_id    
serial
NN
currency_code    
varchar(3)
currency_symbol    
varchar(10)
currency_exchange_rate    
integer(10, 6)
NN
Subscription Addons
Key
subscription_addons_id    
serial
NN
addon_name    
varchar(255)
NN
addon_description    
text
addon_price    
money
NN
duration_in_days    
integer
NN
created_at    
timestamptz
updated_at    
timestamptz
EXAMPLE: INSERT INTO subscription_addons (name, description, price, duration_in_days) VALUES ('50 GB Storage', 'Add 50 GB of storage to your plan.', 10.00, 30), ('100 GB Storage', 'Add 100 GB of storage to your plan.', 18.00, 30);
User Subscriptions
Key
user_subscriptions_id    
serial
NN
Key
customer_id    
uuid
Key
subscription_plan_id    
integer
stripe_subscription_id    
varchar(255)
NN
stripe_payment_intent_id    
varchar(255)
amount_paid    
money
NN
Key
core_currency_id    
serial
NN
payment_status    
varchar(50)
NN
billing_start    
timestamptz
NN
billing_end    
timestamptz
NN
created_at    
timestamptz
updated_at    
timestamptz
status    
varchar(50)
disk_quota    
bigint
NN
User Addons
Key
user_addons_id    
serial
NN
Key
user_subscription_id    
integer
Key
subscription_addon_id    
integer
quantity    
integer
created_at    
timestamptz
updated_at    
timestamptz
Chart of Accounts
Key
chart_of_accounts_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
account_name    
varchar(100)
NN
Key
account_category_id    
bigint
NN
account_code    
text
normal_balance_side    
varchar(20)
NN
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
Key
last_modified_user_id    
bigint
NN
search_vector    
tsvector
Order Statuses
Key
order_status_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
status_name    
varchar(255)
NN
status_description    
text
is_active    
boolean
created_at    
timestamptz
Photos
Key
company_photo_id    
bigserial
NN
Key
product_id    
bigint
NN
Key
web_app_customer    
bigint
NN
company_photo_filename    
text
NN
company_photo_filepath    
text
NN
company_photo_original_size    
integer
company_photo_compressed_size    
integer
photo_file_ext    
varchar(10)
Key
photo_type_id    
serial
lot_number    
varchar(50)
photo_category    
text
uploaded_at    
timestamptz
NN
Key
uploaded_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
Key
last_modified_user_id    
bigint
NN
Key
post_id    
bigint
search_vector    
tsvector
**How to resize images to a specific size? Need to use Python app
Documents
Key
product_document_id    
bigserial
NN
Key
product_id    
bigint
NN
Key
web_app_customer    
bigint
NN
product_document_filepath    
varchar(255)
NN
product_document_filename    
varchar(255)
product_document_file_size    
integer
file_type    
text
lot_number    
varchar(50)
uploaded_at    
timestamptz
Key
uploaded_by_user_id    
bigint
NN
last_modified    
timestamptz
Key
last_modified_user_id    
bigint
NN
Key
post_id    
bigserial
search_vector    
tsvector
Photo Types
Key
photo_type_id    
serial
NN
Key
product_id    
bigint
NN
Key
web_app_customer    
bigint
NN
photo_type_name    
varchar(255)
NN
description    
text
created_at    
timestamptz
last_modified    
timestamptz
Used for company internal things. Ex: Logo, trademarks, brands, etc. Sepcial photos...
Notes
Key
note_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
Key
user_id    
bigint
NN
external_id    
uuid
NN
Key
customer_id    
bigint
note_content    
text
NN
created_at    
timestamptz
last_modified    
timestamptz
reminder_at    
timestamp
reminder_triggered    
boolean
search_vector    
tsvector
Blog Posts
Key
post_id    
bigserial
NN
Key
user_id    
bigint
NN
Key
web_app_customer    
bigint
NN
external_id    
uuid
NN
title    
varchar(255)
NN
content    
text
NN
created_at    
timestamptz
updated_at    
timestamptz
published    
boolean
search_vector    
tsvector
This is the equivalent of the Doc's Report on the Products Site.
Post Categories
Key
post_id    
bigint
NN
Key
category_id    
bigint
NN
Key
web_app_customer    
bigserial
NN
search_vector    
tsvector
Tags
Key
tags_id    
bigserial
NN
Key
web_app_customer    
bigint
tags_name    
varchar(100)
NN
search_vector    
tsvector
Post Tags
Key
post_id    
bigint
NN
Key
tag_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
search_vector    
tsvector
Timezones
Key
timezone_id    
integer
NN
timezone_name    
varchar(100)
NN
timezone_offset    
varchar(6)
NN
timezone_translation    
varchar(100)
NN
description    
text
Storage Calculations
Key
id    
integer
NN
Helping figure out storage calculations**
Services***
Key
service_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
quickbooks_service_id    
integer
service_name    
varchar(255)
NN
description    
text
Key
chart_of_accounts_type    
bigint
NN
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
Key
last_modified_user_id    
bigint
NN
search_vector    
tsvector
Need to EXPOUND on this!!! Can't receive it in, but bills can be associated with it. Need to research more!!!
Product Receipts***
Key
product_receipt_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
received_in_at    
timestamptz
NN
Key
received_in_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
Key
last_modified_by_user_id    
bigint
NN
search_vector    
tsvector
This is for receiving in products to "Inventory" and then we push/copy the info over to Inventory.
Journal Entries
Key
journal_entry_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
transaction_date    
timestamptz
NN
description    
text
Key
accounting_period_id    
bigserial
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
Key
last_modified_user_id    
bigint
NN
search_vector    
tsvector
entry_status    
text
NN
Journal Entries Line Items
Key
line_item_id    
bigserial
NN
Key
journal_entry_id    
bigint
NN
Key
web_app_customer_id    
bigint
NN
Key
account_id    
bigint
NN
debit    
numeric(12, 2)
credit    
numeric(12, 2)
memo    
text
department_id    
bigint
location_id    
bigint
currency_code    
varchar(3)
exchange_rate    
numeric(20, 10)
external_reference    
text
created_at    
timestamptz
Key
created_by_user_id    
timestamptz
NN
last_modified    
timestamptz
Key
last_modified_by_user_id    
timestamptz
Need to use DECIMAL
Emails
Key
email_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
recipient    
text
NN
subject    
text
NN
body    
text
NN
sent_at    
timestamptz
NN
reply_token    
uuid
NN
status    
text
NN
is_html    
boolean
Emails Replies
Key
email_reply_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
Key
email_id    
bigint
NN
reply_body    
text
NN
received_at    
timestamptz
NN
is_html    
boolean
Email Accounts
Key
email_accounts_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
email_address    
text
NN
imap_server    
text
NN
imap_port    
integer
NN
smtp_server    
text
NN
smtp_port    
integer
NN
username    
text
NN
password    
text
NN
created_at    
timestamptz
NN
updated_at    
timestamptz
NN
This is for storing the actual email credentials for each web app customer's sub account. Reason why for an individual is that some salesman might be using their own gmail account logins to send emails or own web server sending IMAP settings.
Custom Order Instructions
Key
custom_order_instructions_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
Key
customer_id    
bigint
NN
Key
warehouse_id    
bigint
NN
instructions_text    
text
search_vector    
tsvector
Used for setting up Customer Defaults
Action Logs
Key
action_log_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
action    
varchar(255)
NN
details    
jsonb
created_at    
timestamptz
NN
This is for logging actions for all users. Early on this is crucial. But later on, it will become a pain point. Being able to offload this to some other database might be ideal. This will help keep the database running quickly.
files**** replicate other document table
Key
files_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
file_name    
varchar(255)
NN
file_size    
bigint
NN
file_path    
text
NN
created_at    
timestamptz
NN
modified_at    
timestamptz
User Specific Documents internally** FOREIGN KEY (user_id) REFERENCES Sub Accounts (user_id) ON DELETE CASCADE
Shared Inventory****
Key
shared_intentory_id    
bigserial
NN
external_id    
uuid
NN
web_app_customer_id    
bigint
NN
user_id****    
bigint
NN
public_url    
bigserial
NN
created_at    
timestamptz
NN
name    
text
share_all_products    
boolean
NN
Need help on if we add user who made this, updated, modified it...; maybe even add an audit log table to track who made one and shared it, etc...
Shared Inventory Details
Key
shared_intentory_details_id    
bigserial
NN
Key
shared_inventory_id    
bigint
NN
Key
inventory_id    
bigint
NN
Key
warehouse_id    
bigint
NN
product_details    
varchar(255)
NN
This is able to pull in Inventory which allows you to pull in product details. This is why Relationships exist. To make it faster and have less space. UNIQUE (shared_inventory_id, product_id, warehouse_id)
Data Processing Audit
Key
data_processing_audit_id    
integer
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
action    
varchar(255)
NN
processed_at    
timestamptz
NN
You need a table to track processing activities for personal data. This ensures transparency and records compliance. Use Case: Record every action involving personal data. For example: - File uploads or deletions. - Sub-account creation or deletion. - Changes to user details (e.g., email or username).
Data Deletion Logs
Key
data_deletion_log_id    
integer
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
entity_type    
varchar(50)
NN
entity_id    
bigserial
NN
deletion_reason    
text
deleted_at    
timestamptz
To support the right to erasure (Article 17), log data deletions for accountability. Use Case: This table tracks when and why data was deleted, ensuring compliance with the "right to be forgotten."
User Consents
Key
user_consent_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
consent_type    
varchar(255)
NN
consent_given    
boolean
NN
consented_at    
timestamptz
NN
Purchase Order Vendors
Key
purchase_order_vendors_id    
bigserial
NN
external_id    
uuid
NN
Key
purchase_order_id    
bigint
NN
Key
web_app_customer_id    
bigint
NN
Key
vendor_id    
bigint
NN
vendor_amount    
numeric(10, 2)
NN
status    
varchar(20)
NN
search_vector    
tsvector
This table is to support the ability to do "split-POs". Meaning, havng 2 vendors on the same PO. This is usually an anomoly for us, but, it does happen. This ALSO allows me to convert a single vendor PO into a Split-PO. Pretty trick!
Inventory Revision Log
Key
inventory_revision_log_id    
bigserial
NN
external_id    
uuid
NN
Key
web_customer_id    
bigint
NN
Key
inventory_id    
bigint
NN
Key
product_id    
bigint
NN
old_lot_number    
varchar(20)
NN
new_lot_number    
varchar(20)
NN
quantity    
integer
NN
action    
varchar(50)
NN
change_timestamp    
timestamptz
NN
Key
change_by_user_id    
bigint
NN
search_vector    
tsvector
This is for logging changes to inventory. It is similar to the "Transfer Log" but it tracks other changes. The revision log will record all changes to the inventory table, including the initial receipt and any updates to the lot_number
Transfer Log
Key
transfer_log_id    
bigserial
NN
external_id    
uuid
NN
Key
web_customer_id    
bigint
NN
Key
inventory_id    
bigint
NN
Key
product_id    
bigint
NN
Key
from_warehouse_id    
bigint
NN
Key
to_warehouse_id    
bigint
NN
old_lot_number    
varchar(20)
NN
new_lot_number    
varchar(20)
NN
quantity    
integer
NN
transfer_timestamp    
timestamptz
NN
Key
transferred_by_user_id    
bigint
NN
search_vector    
tsvector
This is for keeping track of what product gets moved to where. Specifically for tracking productv lot# changes and reassigning lot#s to products. (Logs every transfer of inventory between warehouses, including any changes to the lot number.)
order_transactions
Key
transaction_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
Key
order_id    
bigint
NN
Key
order_line_item_id    
bigint
NN
Key
inventory_id    
bigint
NN
transaction_type    
varchar(50)
Key
inventory_adjustments_id    
bigint
NN
quantity_change    
numeric(10, 2)
NN
previous_quantity    
numeric(10, 2)
NN
resulting_quantity    
numeric(10, 2)
NN
Key
performed_by_user_id    
bigint
NN
performed_at    
timestamptz
NN
comment    
text
source    
text
reason_code    
text
search_vector    
tsvector
This table logs every order movement affecting inventory.
Customer Products Pricelist
Key
pricelist_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
Key
user_id    
bigint
NN
Key
customer_id    
bigint
NN
Key
product_id    
bigint
NN
Key
warehouse_id    
bigint
NN
custom_price    
numeric(10, 2)
NN
override_allowed    
boolean
NN
created_at    
timestamptz
NN
updated_at    
timestamptz
NN
I expect this to change. This is a placeholder to figure out how to set this up. The thought process is to mimic our current setup at work and then add to it. Since this is expected to be complicated, it will probably be broken up into different tables. Got to start somewhere!
Pricelist Details
Key
pricelist_details_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
Key
pricelist_id    
bigint
NN
Key
user_id    
bigint
NN
Key
customer_id    
bigint
NN
Pricelist Details - I think the premise for setting this up specifically is that there is the possibility that more than 1 pricelist can be made for a customer. There are multiple buyers, but it might be kind of nice to have a pricelist and then a specials pricelist sent out adjacently.
Product Tariffs
Key
tariff_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
product_id    
bigint
NN
Key
vendor_id    
bigint
NN
Key
country_id    
integer
NN
tariff_name    
text
NN
tariff_rate    
numeric(6, 2)
NN
tariff_description    
text
tariff_type    
text
NN
effective_date    
date
NN
expiration_date    
date
created_at    
timestamptz
NN
Key
created_user_id    
bigserial
NN
last_modified    
timestamptz
NN
Key
last_modified_user_id    
bigserial
NN
This is for housing tariffs and taxes. A product can have MANY different taxes and they should be named and have descriptions. & TAX Tax. Calculations should be made for these, but it will be housed with seeing how many tariffs are for a specific product and whether or not the rate is calculated before or after freight. But there will be many calculations because there has to be. There is many variables.
Shared Inventory Access
Key
shared_inventory_access_id    
bigint
NN
Key
shared_with_web_app_customer_id    
bigint
NN
Key
shared_inventory_id    
bigint
NN
accepted_at    
timestamptz
revoked_at    
timestamptz
invited_by_customer_user_id    
bigint
invited_token    
uuid
created_at    
timestamptz
This is for sharing your inventory with a fellow customer/competitor. *I think forcing the user to amke whom they share a customer makes better sense since you wouldn't technically share this with a competitor unless they were a customer essentially. Also, it will allow you to protect your product from others. UNIQUE (shared_inventory_id, shared_with_customer_id)
Purchase Order Tariffs
Key
tariff_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
purchase_order_id    
bigint
NN
Key
product_id    
bigint
NN
Key
vendor_id    
bigint
NN
country_id    
integer
NN
tariff_name    
text
NN
tariff_rate    
numeric(6, 2)
NN
tariff_description    
text
tariff_type    
text
NN
effective_date    
date
NN
This is for housing tariffs assigned to POs. Helps keep historical data. I think Product Tariffs get copied over at the time of making a PO
demand_tags
Key
demand_tag_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
demand_tag_text    
varchar(50)
NN
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
last_updated_at    
timestamptz
Key
updated_by_user_id    
bigint
search_vector    
tsvector
user defines their demand tags
Warehouse Product Prices
Key
warehouse_product_prices_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
external_id    
uuid
NN
Key
product_id    
bigint
NN
Key
warehouse_id    
bigint
NN
list_price    
numeric(10, 2)
NN
This table will store the price adjustments based on the warehouse for each product:
Product Selling Season
Key
selling_season_id    
bigserial
NN
Key
product_id    
bigint
NN
Key
web_app_customer    
bigint
NN
selling_season_name    
text
NN
selling_season_start_day    
integer
NN
selling_season_end_month    
integer
NN
selling_season_end_day    
integer
NN
selling_season_end_month    
integer
NN
description    
text
created_at    
timestamptz
Weather Conditions
Key
weather_conditions_id    
bigserial
NN
Key
web_app_customer    
bigserial
NN
condition    
text
NN
description    
text
created_at    
timestamptz
NN
last_modified_at    
timestamptz
This is 1 part of a multi-part table to help predict when a product would be great to sell. It could eventually be used as a buide for ML when referencing sales for it.
Product Weather Suitability
Key
product_id    
bigint
NN
Key
web_app_customer    
bigint
NN
Key
weather_condition_id    
bigint
NN
description    
text
created_at    
timestamptz
NN
last_modified_at    
timestamptz
This is 1 part of a multi-part table to help predict when a product would be great to sell. It could eventually be used as a buide for ML when referencing sales for it.
Regions
Key
regions_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
name    
text
NN
description    
text
created_at    
timestamptz
NN
last_modified_at    
timestamptz
This is 1 part of a multi-part table to help predict when a product would be great to sell. It could eventually be used as a buide for ML when referencing sales for it.
Region Weather Alerts
Key
region_id    
bigserial
NN
Key
product_id    
bigint
NN
Key
weather_condition_id    
bigint
NN
Key
web_app_customer    
bigint
NN
recorded_at    
timestamptz
NN
This is 1 part of a multi-part table to help predict when a product would be great to sell. It could eventually be used as a buide for ML when referencing sales for it.
Vendor_vendor_types
Key
vendor_type_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
Key
vendor_id    
bigint
NN
vendor_type_name    
varchar(30)
NN
description    
text
admin_translations
Key
key    
text
NN
Key
language_code    
text
NN
translation    
text
NN
this is for storing special keys; UNIQUE (key, language_code)
product_translations
Key
product_id    
bigint
NN
Key
web_app_customer_id    
bigint
NN
Key
language_code    
text
NN
name    
text
description    
text
search_vector    
tsvector
sellable_audit_log
Key
sellable_audit_log_id    
bigserial
NN
Key
customer_id    
bigint
NN
old_sellable    
boolean
new_sellable    
boolean
Key
changed_by_user_id    
bigint
NN
changed_at    
timestamptz
NN
old_customer_type_id    
bigint
new_customer_type_id    
bigint
change_note    
text
this is for being able to track who does the manual overrides for making customers unsellable.
Customer Addresses
Key
customer_address_id    
bigserial
NN
Key
customer_id    
bigint
NN
Key
web_app_customer_id    
bigint
NN
external_id    
uuid
NN
address_label    
text
NN
address_attn    
text
address_location_name    
text
address1    
text
address2    
text
address_country    
text
address_phone    
varchar(21)
address_phone_ext1    
varchar(10)
address_phone2    
varchar(21)
address_phone_ext2    
varchar(10)
address_email1    
varchar(100)
address_email2    
varchar(100)
appointment_website    
text
is_billing_address    
boolean
Categories
Key
category_id    
bigserial
NN
Key
web_app_customer    
bigint
category_name    
varchar(100)
NN
search_vector    
tsvector
web_app_customer_documents
Key
web_app_customer_document_id    
bigserial
NN
Key
web_app_customer    
bigint
NN
title    
text
description    
text
product_document_filepath    
varchar(255)
NN
product_document_filename    
varchar(255)
product_document_file_size    
integer
file_type    
text
uploaded_at    
timestamptz
Key
uploaded_by_user_id    
bigint
NN
last_modified    
timestamptz
Key
last_modified_user_id    
bigint
NN
search_vector    
tsvector
This is for storing web app customer specific internal documents
web_app_customer_document_tags
Key
web_app_customer_document_tag_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
web_app_customer_document_id    
bigint
tag    
text
NN
invoice_customer_sequences
Key
web_app_customer_id    
bigint
NN
next_invoice_number    
bigint
NN
This is for customers to set their starting invoice number & also to keep track of what their invoice number is so the system can auto increment by 1 up. Should I have a table for prefix or affixed leters???
invoice_line_items
Key
invoice_item_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer    
bigint
NN
Key
invoice_id    
bigint
NN
Key
order_id    
bigint
NN
Key
inventory_product_id    
bigint
NN
Key
inventory_lot_number    
varchar
NN
product_quantity    
numeric(10,2)
NN
clean_out    
boolean
product_price    
numeric(10, 6)
price_is_delivered    
boolean
follows the same rule as Orders and Order Items tables ask chatgpt about inventory table sql and this table to see if i have the right foreign keys or not referenced in here.
inventory_adjustments
Key
inventory_adjustments_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
inventory_id    
bigint
NN
external_id    
uuid
NN
adjustment_change    
numeric(10, 2)
NN
adjustment_reason    
text
NN
reference_type    
text
reference_id    
text
comments    
text
Key
adjusted_by_user_id    
bigint
adjusted_at    
timestamptz
NN
This is very good practice, especially to handle cases like voiding invoices where you need to put products back into inventory and keep a clear audit trail. It allows to: Audit trail: You can track every change made to inventory—whether from sales, returns, voided invoices, manual corrections, etc. Transparency: Know who did what, when, and why. Reconciliation: Helps with inventory reconciliation and troubleshooting discrepancies. Separation of concerns: Keeps inventory transactions separate from core inventory quantities, which are typically calculated or stored elsewhere.
order_customer_sequences
Key
order_customer_sequences_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
warehouse_id    
bigint
next_order_number    
bigint
NN
prefix    
text
suffix    
text
This is for customers to set their starting invoice number & also to keep track of what their invoice number is so the system can auto increment by 1 up. CONSTRAINT unique_customer_warehouse UNIQUE (web_app_customer_id, warehouse_id)
order_approvals
Key
order_approvals_id    
bigserial
NN
Key
order_id    
bigint
NN
external_id    
uuid
NN
Key
approved_by_user_id    
bigint
NN
action    
text
NN
comment    
text
action_timestamp    
timestamptz
being able to have a full audit of approvals for orders if a customer wants this**
customer_po_sequences
Key
web_app_customer_id    
bigint
NN
next_po_number    
bigint
NN
po_prefix    
text
po_suffix    
text
use_user_identifier    
boolean
po_tag_strategy    
text
ability to set the starting PO in the system and also set prefixes to orders by Buyer or by however.
customer_po_user_tags
Key
web_app_customer_id    
bigint
NN
Key
user_id    
integer
NN
user_tag    
text
NN
For example, Corey: user_tag = "C" or Barry as "B". It only applies if web_app_customer user_id has use_user_identification = TRUE
customer_po_order_type_tags
Key
web_app_customer_id    
bigint
NN
Key
order_type    
text
NN
po_tag    
text
NN
Account Categories
Key
category_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
category_name    
text
NN
description    
text
category_type    
text
Key
created_by_user_id    
bigint
NN
created_at    
timestamptz
NN
Key
last_modified_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
search_vector    
tsvector
NN
Ex: Asset, Liability, Equity, Revenue, Expense, Cogs
table1
Key
id    
integer
NN
Currencies
Key
currency_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
currency_code    
varchar(3)
NN
currency_name    
varchar(100)
NN
symbol    
varchar(10)
NN
exchange_rate_to_base    
numeric(10, 2)
NN
is_active    
boolean
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
updated_at    
timestamptz
NN
Key
updated_by_user_id    
bigint
NN
tax_rates
Key
tax_rate_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
name    
text
NN
jurisdiction    
text
NN
rate_percentage    
numeric(5, 4)
NN
applies_to    
text
effective_date    
date
NN
end_date    
date
NN
compund    
boolean
inclusive    
boolean
Key
created_by_user_id    
bigint
NN
created_at    
timestamptz
Key
modified_by_user_id    
bigint
NN
last_modified    
timestamptz
Vendor Bills
Key
vendor_bill_id    
bigserial
NN
web_app_customer_id    
bigint
NN
bill_number    
varchar(50)
NN
vendor_id    
bigint
NN
bill date    
date
NN
Vendor Payment Terms
Key
payment_term_id    
bigserial
NN
Key
web_customer_id    
bigint
NN
payment_name    
integer
NN
payment_days    
integer
NN
payment_description    
text
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
updated_at    
timestamptz
NN
Key
updated_by_user_id    
bigint
NN
customer_accounting_mappings
Key
accounting_mapping_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
company_ledger_id    
bigint
NN
external_id    
uuid
NN
secondary_key    
text
metadata    
jsonb
This is the behind the scenes mapping of different companyies to ERP softwares. Like this being linked to QBs UNIQUE (customer_id, ledger_id)
company_ledgers
Key
company_ledger_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
system    
text
NN
name    
text
NN
credentials    
jsonb
NN
last_synced    
timestamptz
is_active    
boolean
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
last_modified    
timestamptz
NN
Key
modified_by_user_id    
bigint
NN
This is the behind the scenes mapping of different companyies to ERP softwares. Like this being linked to QBs
tax_rates_zones
Key
tax_rate_zone_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
name    
text
NN
description    
text
NN
Key
created_by_user_id    
bigint
NN
created_at    
timestamptz
Key
modified_by_user_id    
bigint
NN
last_modified    
timestamptz
tax_rate_zone_regions
Key
tax_rate_region_zone_id    
bigserial
NN
Key
tax_rate_zone_id    
bigint
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
country_code    
text
NN
region_code    
text
postal_code_prefix    
text
Key
created_by_user_id    
bigint
NN
created_at    
timestamptz
Key
modified_by_user_id    
bigint
NN
last_modified    
timestamptz
product_tax_exemptions
Key
product_tax_exemptions_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
product_id    
bigint
NN
country_code    
text
NN
region_code    
text
is_exempt    
boolean
NN
reason    
text
effective_date    
date
NN
end_date    
date
Key
ceated_by_user_id    
bigint
NN
created_at    
timestamptz
NN
Key
modified_by_user_id    
bigint
NN
modified_at    
timestamptz
NN
customer_tax_exemptions
Key
customer_tax_exemptions_id    
bigserial
NN
web_app_customer_id    
bigint
NN
Key
customer_id    
bigint
NN
country_code    
text
NN
region_code    
text
exemption_type    
text
certificate_number    
text
expiration_date    
date
verified    
boolean
notes    
text
uploaded_certificate_url    
text
ceated_by_user_id    
bigint
NN
created_at    
timestamptz
NN
modified_by_user_id    
bigint
NN
modified_at    
timestamptz
NN
bills
Key
bill_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
Key
vendor_id    
bigint
NN
bill_number    
text
NN
bill_date    
date
NN
due_date    
date
NN
total_amount    
numeric(10, 2)
NN
Key
currency_id****???    
bigint
NN
status    
text
NN
purchase_order_id    
bigint
notes    
text
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
updated_at    
timestamptz
Key
updated_by_user_id    
bigint
search_vector    
tsvector
These are bills from vendors
bill_line_items
Key
bill_line_item_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
external_id    
uuid
NN
Key
bill_id    
bigint
NN
description    
text
NN
quantity    
numeric(10, 2)
NN
unit_cost    
numeric(10, 6)
NN
line_total    
numeric(12, 2)
Key
chart of accounts_id    
bigint
NN
inventory_id    
bigint
received_date    
date
notes    
text
payments
Key
payment_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
payment_type    
text
NN
customer_paye_id    
bigint
vendor_payee_id    
bigint
payment_method_id    
bigint
NN
reference_number    
text
NN
payment_date    
date
NN
amount    
numeric(12, 2)
NN
Key
payment_method_id    
bigint
NN
Key
currency_code***    
varchar(3)
NN
applied    
boolean
applied_on    
timestamptz
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
updated_at    
timestamptz
Key
last_modified_by_user_id    
bigint
use_fx_conversion    
boolean
exchange_rates****??
Key
exchange_rate_id    
bigserial
NN
source_currency    
varchar(3)
NN
target_currency    
varchar(3)
NN
rate    
numeric(20, 10)
NN
rate_timestamp    
timestamptz
NN
provider    
text
UNIQUE(source_currency, target_currency, rate_timestamp)
payment_applications
Key
payment_application_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
Key
payment_id    
bigint
NN
target_type    
text
NN
target_id    
bigint
NN
applied_amount    
numeric(12, 2)
applied_on    
timestamptz
NN
This table enables partial payments, multi-invoice application, and auditability.
payment_methods
Key
payment_method_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
method_code    
text
NN
method_name    
text
NN
country_code    
varchar(2)
Key
currency_code***???    
varchar(3)
default_payment_term_id    
bigint
is_enabled    
boolean
sort_order    
bigint
integration_metadata    
jsonb
instructions    
text
custom_fields    
jsonb
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
updated_at    
timestamptz
Key
updated_by_user_id    
bigint
NN
UNIQUE(web_app_customer_id, method_code)
account_periods
Key
accounting_period_id    
bigserial
NN
external_id    
uuid
NN
Key
web_app_customer_id    
bigint
NN
fiscal_year    
bigint
NN
fiscal_period    
bigint
NN
fiscal_quarter    
bigint
period_start_date    
date
NN
period_end_date    
date
NN
is_closed    
boolean
locked_at    
timestamptz
Key
locked_by_user_id    
bigint
search_vector    
tsvector
Key
idx_accounting_periods_date_lookup
the concept of accounting_period_id and an accounting_periods table is foundational in any accounting system. It gives you control over how you group, close, report, and validate financial activity over time. UNIQUE (web_app_customer_id, fiscal_year, fiscal_period) fiscal_year: e.g., 2025 fiscal_period: e.g., 1 = Jan, 2 = Feb — or week number in 4-4-5 systems is_closed: Lets you prevent any further entries from being posted locked_by_user_id: Audit trail
bank_accounts
Key
bank_account_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
account_name    
varchar(255)
NN
account_number    
varchar(50)
NN
routing_number    
varchar(50)
swift_code    
varchar(11)
iban    
varchar(34)
bank_name    
varchar(255)
NN
bank_address    
jsonb
Key
currency_code*****???    
varchar(3)
NN
account_type    
varchar(50)
NN
is_active    
boolean
NN
is_deleted    
boolean
NN
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
updated_at    
timestamptz
NN
Key
updated_by_user_id    
bigint
NN
deleted_at    
timestamptz
Key
idx_bank_accounts_customer_id
Key
idx_bank_accounts_account_number
Key
idx_bank_accounts_is_active
Key
idx_bank_accounts_is_deleted
CONSTRAINT unique_account_per_customer UNIQUE (web_app_customer_id, account_number) Use pgcrypto to encrypt: account_number, routing_number, iban, swift_code
bank_transactions
Key
bank_transaction_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
bank_account_id    
bigint
NN
transaction_type    
varchar(50)
NN
transaction_date    
timestamptz
NN
amount    
numeric(12, 2)
NN
Key
currency_code    
varchar(3)
NN
original_amount    
numeric(12, 2)
NN
original_currency_code    
varchar(3)
fx_rate***???    
numeric(20, 10)
NN
fx_applied    
boolean
NN
description    
text
reference_number    
varchar(100)
linked_entity_type    
varchar(50)
linked_entity_id    
bigint
is_reconciled    
boolean
NN
Key
bank_reconciliation_id    
bigint
NN
reconciled_at    
timestamptz
Key
reconciled_by_user_id    
bigint
is_deleted    
boolean
NN
deleted_at    
timestamptz
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
updated_at    
timestamptz
NN
Key
updated_by_user_id    
bigint
NN
Key
idx_bank_transactions_customer_id
Key
idx_bank_transactions_bank_account_id
Key
idx_bank_transactions_reconciliation_status
Key
idx_bank_transactions_transaction_date
bank_reconciliations
Key
bank_reconciliation_id    
bigserial
NN
Key
web_app_customer_id    
bigint
NN
Key
bank_account_id    
bigint
NN
statement_start_date    
date
NN
statement_end_date    
date
NN
statement_closing_balance    
numeric(12, 2)
NN
calculated_ending_balance    
numeric(12, 2)
difference    
numeric(12, 2)
is_finalized    
boolean
NN
finalized    
timestamptz
finalized_by_user_id    
bigint
notes    
text
reconciliation_date    
timestamptz
NN
is_deleted    
boolean
NN
deleted_at    
timestamptz
created_at    
timestamptz
NN
Key
created_by_user_id    
bigint
NN
updated_at    
timestamptz
NN
Key
updated_by_user_id    
bigint
NN
recalculated_balance    
numeric(12, 2)
balance_difference    
numeric(12, 2)
last_calculated_at    
timestamptz
anomaly_detected    
boolean
Key
idx_bank_reconciliations_customer_id
Key
idx_bank_reconciliations_bank_account_id
Key
idx_bank_reconciliations_reconciliation_date
reconciliation_anomalies
Key
anomaly_id    
bigserial
NN
Key
web_app_customer_id    
bigserial
NN
Key
bank_reconciliation_id    
bigint
NN
previous_difference    
numeric(10, 2)
new_difference    
numeric(10, 2)
detected_at    
timestamptz
reported    
boolean
anomaly_type    
text
resolved_by_user_id    
bigint
resolved_at    
timestamptz
Key
idx_anomalies_reported_detected
NEED TO DO THIS --> ALTER TABLE reconciliation_anomalies ADD CONSTRAINT fk_anomalies_reconciliation FOREIGN KEY (bank_reconciliation_id) REFERENCES bank_reconciliations(bank_reconciliation_id);
alert_events
Key
alert_id    
bigserial
NN
web_app_customer_id    
bigserial
NN
alert_type    
text
Key
anomaly_id    
bigint
message    
text
sent_at    
timestamptz
recipient    
text
audit_events
Key
id    
integer
NN
notifications
Key
id    
integer
NN
reconciliation_lines
Key
reconciliation_line_id    
bigserial
NN
Key
bank_reconciliation_id    
bigint
NN
Key
web_app_customer_id    
bigint
NN
transaction_date    
date
NN
amount    
numeric(12, 2)
NN
cleared    
boolean
cleared_at    
timestamptz
cleared_by_user_id    
bigint
source_type    
text
source_id    
bigint
description    
text
created_at    
timestamptz

*Add Primary Keys,

They don't need a relation to them to be one!

*Will need to revise PKs and FKs

How to do double-entry

for inventory???

Double Entry Accounting

Add external_id to all tables.

Replace UUID for customer_id with bigserial


This is known as the "Hybrid Approach"

*Reminders need to use TIMESTAMP

They are in "local time". No sense utilizing TIMESTAMPZ.

*Scheduling stuff would be in TIMESTAMP as well

They are in "local time". No sense utilizing TIMESTAMPZ.

**Pricelist Sending TIMESTAMPZ

They traverse multiple times.

**Sending emails in the web app use TIMESTAMP

Local time is what is needed

Pricelist Portion

Add: ^^^^^

user_id for any table; and for any table that has "last_modified" & "created_at" in it. This is used to track changes made by users and any potential for users to "self sabotage a company" and who maybe did an order.

*We will be going with 3 databases

Primary & Replica

We will route writes to PRIMARY and Reads to REPLICA.

This will further make it super fast!


REPLICA Copy so in case we have a failure of Primary, we move Replica1 to Primary and Replica2 to Replica and then Primary to Replica2 position.

Redundancy

Then backups to like RackSpace in case of an accidental erase!

Explore more options for JSONB

in this table & apply to others.

NEED TO ASK CHATGPT ON THESE TABLES FOR REFERENCING AND BIGSERIAL AND BIGINT!?

-->

-->

-->

-->

-->

-->

USER SERIAL OR BIGSERIAL ON THE OG TABLE AND THEN USE BIGINT ON THE TABLES WHERE IT IS REFERENCED.

any serial field auto-increments and this is an issue when it gets referenced in another table...

-->

-->

-->

-->

-->

Not following through on a comment system for blog posts. Don't want to give away customers.

What about chart of accounts for warehouses??

*Ask about whether to have NN for "created_by_user" columns?

Currencies referenced from another table.

Need more help! ChatGPT has it, but I don't get it!!

Materialized view
Last 30 Days Orders
This is for querying orders done in the last 30 days so it is quickly pulled up. SELECT * FROM orders_last_30_days WHERE customer_id = '12345'; Here is a revised script to look at and revise currnt scrip to it: CREATE MATERIALIZED VIEW fast_orders AS SELECT id, status, web_app_customer_id, created_at FROM orders WHERE created_at > NOW() - INTERVAL '30 days';
Materialized view
Last 90 Days Orders
This is for querying orders done in the last 90 days so it is quickly pulled up. SELECT * FROM orders_last_30_days WHERE customer_id = '12345';
Materialized view
Last 60 Days Orders
This is for querying orders done in the last 60 days so it is quickly pulled up. SELECT * FROM orders_last_30_days WHERE customer_id = '12345';
Materialized view
Top Customers
Need to figure out the script, but this is for knowing who our top custoemrs are for each web apop customer, Maybe sort of like a Top 10
Materialized view
Top Products
Need to figure out the script, but this is for knowing what our top products are that we sell ad a company. it grabs it from Orders because that's where we sell. Maybe sort of like a Top 10
Materialized view
Top Truckers
Need to figure out the script, but this is for knowing who our top Trucking companies are. Maybe a top 10 or top 5. These are our Go To's. It is dependent on how many POs we cut to a specific vendor based off the Chart of Accounts (transportation services). I think it should be based off the last 12 months. Maybe it should show their "deemed" location that they service. Sort of like a Quick View and maybe have it posted to see who to use, but also allow you to click it and add them to the Trucking PO if you so choose that. It will also display contact details. A kicker is to have the previous trucker that was on the last order be listed on top or in a section that says "Previous Trucker."
Materialized view
Top 5 Vendors
Need to figure out the script, but this is for knowing who our top vendors that we order from. These are our Go To's. It is dependent on how many POs we cut to a specific vendor based off the Chart of Accounts (cost of goods sold). I think it should be based off the last 12 months.
Materialized view
Inventory Turnover
Need to figure out the script, but this is helping us see how long it takes for product to come in and then sell out. It will gather info over the last 12 months It will be based off product being received in on a purchase order at a specific date & then orders against that product in the specific lot & till the remaining quantity is 0 and it grabs that date & then
Materialized view
Weekly Moving
Need to figure out the script, but this is helping us see what our weekly movement is for our products. It would take what we had sold for our products the last 7 days for a specific lot.
Materialized view
Average Monthly Moving
Need to figure out the script, but this is helping us see what our monthly movement is for our products. It would take what we had sold for our products the last 30 days for a specific lot. Example Script (need to refine): CREATE MATERIALIZED VIEW monthly_product_sales AS SELECT product_id, SUM(quantity) AS total_monthly_sold FROM order_items WHERE web_app_customer_id = app.current_customer order_date >= date_trunc('month', CURRENT_DATE) AND order_date < date_trunc('month', CURRENT_DATE + interval '1 month') GROUP BY product_id; REFRESH MATERIALIZED VIEW monthly_product_sales;
Materialized view
Average 3-Monthly Moving
Need to figure out the script, but this is helping us see what our monthly movement is for our products. It would take what we had sold for our products the last 90 days for a specific lot.
Materialized view
Average 6-Monthly Moving
Need to figure out the script, but this is helping us see what our monthly movement is for our products. It would take what we had sold for our products the last 180 days for a specific lot.
Materialized view
Average 12-Monthly Moving
Need to figure out the script, but this is helping us see what our monthly movement is for our products. It would take what we had sold for our products the last 360 days for a specific lot.
Materialized view
Average Weekly Usage
Need to figure out the script, but this is helping us see what our weekly usage is for a product. This takes the monthly materialized view and divides the number by 4 (weeks) to determine the average usage for the product each week. Example Script (need to refine): CREATE MATERIALIZED VIEW weekly_avg_product_sales AS SELECT product_id, ROUND(total_monthly_sold / 4.0, 2) AS weekly_avg_sold WHERE web_app_customer_id = app.current_customer FROM monthly_product_sales; REFRESH MATERIALIZED VIEW weekly_avg_product_sales;
Materialized view
Inventory_recomputed_quantity
This constantly recalculates the inventory based off transactions of orders in order_transactions. It's best to have multiple ways to compute inventory because you don't want errors... REFRESH MATERIALIZED VIEW CONCURRENTLY inventory_recomputed_quantity;
View
Reconcilation Report
This is for Inventory
Function
Automated Reconciliation Job
This is an example of a function
View
Live Inventory
Function
Automatically setting "accounting_period_id"
View
journal_entry_balances
This view that automatically checks if each journal entry is balanced (i.e., total debits = total credits). This is a simple but powerful tool to validate your general ledger.
Function
validate_journal_entry_balance
Trigger
check_journal_entry_balance
View
current_reconciliation_status
Function
is_reconciled
View
reconciliation_with_anomalies
Documentation for project Inventory 2
Inventory 2
Project
Name
Inventory 2
Description
Version 2 since version 1 was locked...
Diagram
Name
Main Diagram
Report
Generated
6/5/2025 | 11:22:13 PM
tables
Name
Warehouse
Description
List of warehouses and Cold Storages. Should have logic in that if a product has a cold storage linked to it, it can't be deleted. Need to link it to a vendor so we can pay them!
Columns
Name
Data type
Param
Key
Not Null
warehouse_id
bigserial
Yes
Yes
Description
*Thought is to use this for the Customer's ID in the system.
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
Description
This makes the database automatically generate a UUID
web_app_customer
bigint
Yes
vendor_id
bigint
Description
this allows us to associate FreezPak Logistics multiple warehouse locations and trucking service to be billed as 1 entitiy instead of multiple entities.
nickname
varchar
55
warehouse_dba
varchar
warehouse_location
varchar
Yes
warehouse_name
text
Yes
warehouse_address1
text
Yes
warehouse_address2
text
Yes
warehouse_city
text
Yes
warehouse_state
text
Yes
warehouse_zipcode
text
Yes
warehouse_country
text
Yes
online_inventory_website
text
online_inventory_username
varchar
online_inventory_password
varchar
qbs_warehouse_location_id
varchar
allow_same_day_orders
boolean
Description
false = no, true = yes
billable
boolean
Yes
Description
Yes allows you to bill them as a customer in an unlikely event. No removes them from the billing when it comes to customers. This can be set as yes and no at anytime. No is the default. **It would be cool to be able to switch them on and off even if you have billed them in the past. Will need to see if that's possible or if possible to select a checkmark for billing vendors or have vendors listed at the bottom and they can't be "instant searched" when billing a customer. Sort of like an entry on the dropdown at the very bottom.
timezone
integer
2
Yes
fees
jsonb
Description
DEFAULT '[]' Ability to list certain fees as "attributes"
lumping_fee
integer
ctr_unloading_fee
integer
own_pallet_with_product
varchar
pallet_exchange
boolean
rate_sheet
varchar
warehouse_holidays
varchar
operation_days
jsonb
Yes
Description
DEFAULT '[]' I imagine a list of days of the week and the user can set the shipping hours for the days of the week, the receiving hours, and the customer service hours.
operation_days_roles
jsonb
Description
DEFAULT '[]' settings roles for the certain schedules: - Customer Service - Receiving - Shipping
warehouse_attributes
jsonb
Description
DEFAULT '[]' Attributes such as: - Dry Ice - repacking_capabilities - Relabeling abilities - Damage Control -
is_deleted
boolean
Default value
false
Description
DEFAULT FALSE This allows us to hide/archive for auditing purposes in the future
appointment_website
text
search_vector
tsvector
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
modified_at
timestamptz
modified_by_user_id
bigint
Yes
Keys
Warehouse_pkey
Column in Warehouse_pkey
warehouse_id
Name
Customers
Description
Since ANY and ALL Sales data is listed under the Sales table, it is accessable via the Customer UUID and UUID of the Sale. Therefore, anything that is associated on a separate table will be JOINed together on the frontend. Routing seems hectic, but it makes sense database wise.
Columns
Name
Data type
Param
Key
Not Null
customer_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
Description
This makes the database automatically generate a UUID
web_app_customer
bigint
Yes
Description
Might need to change the label of this, but for now it is listed as this.
customer_name
varchar
41
Yes
customer_dba
varchar
41
customer_name_listed_as
varchar
41
nickname
varchar
40
Description
allows you to give them a nickname. Maybe the name of the buyer to help search for their company. Ex: We refer to Canammeats as "Mauro" or Sunnyvale as "Henry" This is sort of like a shortcut.
used_to_be_called
varchar
41
used_to_be_called_date_change
date
user_id
bigint
Yes
Description
salesman
quickbooks_cust_id
varchar
erp_custom_id
varchar
customer_type
bigint
Yes
sellable
boolean
Description
DEFAULT TRUE But this is for a manager to manually override it if it comes down to an issue. The customer might be credit underwritten, but a manager deems thm as an issue and "bars" them from being able to get product.
order_frequency
integer
order_frequency_days
integer
avg_order_day
varchar
bill_by_dba
boolean
our_vendor_number
varchar
25
credit_insured
boolean
credit_limit
integer
15
average_pay_time
integer
3
current_balance_owed
integer
18
default_shipping_vendor_id
bigint
default_shipping_vendor_instructions
text
email_sending_category_id
integer
3
product_customer_usually_buys
varchar
Description
This runs a check and see what is the usual product they buy. But should I factor in how many times it appears on an order or base it by cases? I think base it by order as the best thing.
accounting_contact
jsonb
Description
DEFAULT '[]'; This is for being able to have more than 1 accounting contact. Sometimes their is a general contact and then a backup. The more the merrier because the 1st one will fail you at some point. Fields Needing: - Label - Contact Name - Phone# - Phone Ext - Email
is_deleted
boolean
Default value
false
Description
DEFAULT FALSE This allows us to hide/archive for auditing purposes in the future
status
varchar
50
payment_term_id
bigint
Yes
default_ship_terms_id
bigint
is_tax_exempt
boolean
Default value
TRUE
tax_exemption_number
text
tax_exemption_expiry
date
search_vector
tsvector
Keys
Customers_pkey
Column in Customers_pkey
customer_id
Customers_key
Customers_key1
Column in Customers_key1
web_app_customer
Customers_key2
Column in Customers_key2
web_app_customer
Customers_key3
Column in Customers_key3
web_app_customer
Customers_key4
Customers_key5
Customers_key6
Column in Customers_key6
accounting_contact
Name
Orders
Description
This is the barebones table. It will utilize IDs to make it quick! ANYTHING that is listed in another table can be pulled up from just using the ID from another table and joining the details. Crazy! This means I don't add the following: customer billing city and state, This pertains to the specific details of this order. Order Items pertains to all the products apart of the order! **Since pulling the customer over by the UUID, do I really need to have the data of the following or can I just JOIN or grab it:? Billing City and Billing State ??? Why are there PKs that I can't delete??? Need to do more research on when to PK and Not. Also, need to do FKs, but need to know how to later! Houses details fo the order
Columns
Name
Data type
Param
Key
Not Null
order_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
Description
This makes the database automatically generate a UUID
web_app_customer
bigint
Yes
customer_id
bigint
Yes
customer_billing_city
varchar
50
Yes
customer_billing_state
integer
Yes
customer_billing_address
jsonb
Yes
Description
Look at this towards the bottom to know how to copy over the customer_addresses billing address based off the "is_billing_address" to to TRUE. This is a snap shot because data integrity is key and it can change over tme. https://chatgpt.com/share/682558f0-9444-8006-b436-298cc475cb80
customer_po_number
varchar
25
Yes
warehouse_id
bigint
Yes
order_type_id
bigint
Yes
order_rush
boolean
Description
DEFAULT FALSE
order_number
text
Yes
order_sent_on
timestamptz
Yes
Description
same as order date. This is when it was actually sent in.
trucker_id
bigint
Description
this is the vendor ID, but specifically vendors that are SHIPPERS
ship_term
integer
Description
need to see how to grab defaults from a specific customer and add it into here...
order_first_created_date
timestamptz
Yes
Default value
now()
special_instructions_note
varchar
300
payment_terms_id
bigint
Yes
Description
-- Set default from customer at order creation
order_status_id
serial
Yes
created_by_user_id
bigint
Yes
created_at
timestamptz
Yes
Default value
now()
last_modified_by
bigint
Yes
last_modified
timestamptz
order_sent_in
timestamptz
order_confirmed_back
timestamptz
shipping_bol
varchar
50
trucking_po
bigserial
Description
Need to figure out how to associate a Trucking PO with this since I'm thinking of just doing a PO system for ALL instead of separate... Truckers are vendors and they provide for a service... Maybe have "Service POs"??
total_pallets
numeric
10, 2
Yes
Description
total pallets are the combinations of anything over .1 = 1 pallet. Therefore, it totals all pallets for the Line Items.
assumed_total_pallets
numeric
10, 2
Yes
Description
This takes the pallet decimal total and it adds it up in totality to show the entire pallet total. Then that number that is over .1 is considered a full other pallet. Have a note disclosure of "*If everything is combined on a pallet, then the total is this."
searchable_content
tsvector
is_voided
boolean
Description
DEFAULT FALSE This allows us to hide/archive the order for auditing purposes in the future
search_vector
tsvector
Keys
customers_uuid
Column in customers_uuid
order_id
Orders - COME BACK TO! NEED MORE WORK!_key
Column in Orders - COME BACK TO! NEED MORE WORK!_key
web_app_customer
Order Details - COME BACK TO! NEED MORE WORK!_key
Column in Order Details - COME BACK TO! NEED MORE WORK!_key
order_status_id
Name
Web_App_Customer
Description
This is the master list of the web app customers. Company IDs are assigned in here and those are the UUIDs. Allowsing SOFT DELETE for the system. Hard Deteting for select options. Most are SOFT DELETE via is_delete or is_voided
Columns
Name
Data type
Param
Key
Not Null
web_app_customer_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
company_name
varchar
41
Yes
name
varchar
255
Yes
email
varchar
255
Yes
Description
UNIQUE --? But what if someone has multiple email accounts for the same company...???
language_code
text
created_at
timestamptz
Yes
Default value
now()
updated_at
timestamptz
Yes
last_active
timestamptz
Description
DEFAULT TIMESTAMPZ
is_inactive
boolean
Description
DEFAULT FALSE
inactive_since
timestamptz
Description
INACTIVE in general is for the system to automatically delete users who have not used the system for a set period of time. In this case, it would be the company that has users and the activity is based off them interacting with the system. I'm thinking after 18 months or 24 months is when we delete them entirely. We will have to ustilize ON CASCADE DELETE as the logic to do this for us. Best practice is to send a warning email to the company admin notifying them that they have 30 days in order to re-active their account. In our case, we are paid and we need to have a column attached to this to be another indicator on not to delete them out of the system.
undeleteable
boolean
Description
This is so we can have a demo or our own company on here that will never be deleted and is a master list/record account.
payment_status
varchar
Yes
Description
deciding if I need this, but the thought is to have a status for a customer. ie: current, trial, defaulted, etc. current - paid, trial - 30 days (need to know how to do this...), defaulted - payment did not go through (need a grace period of a week so they are not screwed if they have money problems.
is_on_trial
boolean
Description
DEFAULT TRUE -- Tracks whether the main customer is on trial
trial_start_date
timestamptz
Description
DEFAULT CURRENT_TIMESTAMPZ -- Start date of the trial
trial_end_date
timestamptz
Description
-- End date of the trial (30 days from start)
is_subscription_active
boolean
Description
DEFAULT FALSE -- Whether the customer has an active subscription
subscription_plan_id
integer
billing_start_date
timestamptz
Yes
billing_end_date
timestamptz
Yes
is_deleted????
boolean
Description
DEFAULT FALSE This allows us to hide/archive for auditing purposes in the future. Also allows us to RESTORE a user if they accidentally deleted their account or went dormant at a certain point. ****Thinking to replace this with "deleted_at" to be compatible with GDPR.
disk_quota
bigint
Yes
Description
DEFAULT 0
is_anonymized
boolean
Yes
Description
DEFAULT FALSE Instead of fully deleting users, replace personal identifiers (e.g., username, email) with placeholders and set is_anonymized = TRUE.
deleted_at
timestamptz
Description
GDPR requires defining retention periods for personal data (e.g., files, logs, or user accounts). Add a deleted_at column to relevant tables to mark when records are soft-deleted. ****Soft-Deletion is the name of the game. Then a 30 Day added to this is when the deltion occurs. I think maybe 31 days as a grace period is what might be better. But, idk. 30 Days would be the default. Multiple emails and 2 stage verification to ensure deletion should be required! Sort of like delting a domain name.
Keys
Web_App_Customer_pkey
Column in Web_App_Customer_pkey
web_app_customer_id
Web_App_Customer_key
Column in Web_App_Customer_key
subscription_plan_id
Relations
Name
Parent
Child
Name
Order_Type
Columns
Name
Data type
Param
Key
Not Null
order_type_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
order_type_name
varchar
30
description
text
Keys
Order_Type_pkey
Column in Order_Type_pkey
order_type_id
Name
Roles
Description
You can name roles here. Need to figure out how it works
Columns
Name
Data type
Param
Key
Not Null
role_id
bigserial
Yes
Yes
role_name
varchar
30
Yes
role_permission
integer
Yes
Description
need to see how to give or add more permissions to a specific role.... Or if integer is the right value
Keys
Roles_pkey
Column in Roles_pkey
role_id
Name
Customer_Type
Description
Think this will be a table, but not fully sure. Still processing and thinking things through. Same as Sellable table...
Columns
Name
Data type
Param
Key
Not Null
customer_type_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
customer_type_name
varchar
Yes
sellable
text
customer_type_description
text
Keys
Customer_Type_pkey
Column in Customer_Type_pkey
customer_type_id
Name
Payment Terms
Columns
Name
Data type
Param
Key
Not Null
payment_term_id
bigserial
Yes
Yes
web_customer_id
bigint
Yes
payment_name
integer
Yes
payment_days
integer
Yes
payment_description
text
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
updated_at
timestamptz
Yes
updated_by_user_id
bigint
Yes
Keys
Customer Payment Terms_pkey
Column in Customer Payment Terms_pkey
payment_term_id
Name
Ship_terms
Description
simply lists it on the order. Not for us, but for them. But, if Pre-Paid, it automatically makes it a custom Trucking PO we make.
Columns
Name
Data type
Param
Key
Not Null
ship_terms_id
integer
Yes
Yes
web_app_customer
bigserial
Yes
ship_terms_name
varchar
20
Yes
ship_terms_description
text
Keys
Ship_terms_pkey
Column in Ship_terms_pkey
ship_terms_id
Name
Languages
Description
Each section title and any other text can be stored with a language identifier.
Columns
Name
Data type
Param
Key
Not Null
languages_code
text
Yes
Yes
Description
CHECK (char_length(language_code) <= 10),
language_name
text
Yes
native_name
text
locale_tag
text
direction_text
text
Description
DEFAULT 'ltr'
Keys
Languages_pkey1
Column in Languages_pkey1
languages_code
Name
Inventory***
Description
Products -> These are details that you set and don't change or add to. Inventory-> these are variable details that get assigned to prducts when received in.
Columns
Name
Data type
Param
Key
Not Null
inventory_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer
bigint
Yes
product_id
bigint
Yes
purchase_order_id
bigint
Yes
warehouse_id
bigint
Yes
lot_number
varchar
50
Yes
available_product_quantity
numeric
10, 2
Yes
Description
DEFAULT 0
on_special
boolean
case_per pallet
integer
case_ti
integer
case_hi
integer
cost_price
numeric
10, 2
Yes
anniversary_date
date
Yes
comments
text
tlc_code
varchar
255
pack_date
date
pack_date_text
varchar
20
expire_date
date
expire_date_text
varchar
20
received_in_date
date
Yes
Default value
now()
received_in_at
timestamptz
Yes
Default value
now()
received_in_by_user_id
bigint
Yes
last_updated
timestamptz
last_updated_user_id
bigint
quantity
integer
Yes
lot_hold
boolean
Yes
Description
DEFAULT FALSE
is_phantom
boolean
Yes
Description
DEFAULT FALSE
demand_tag
varchar
50
search_vector
tsvector
Keys
Inventory***_pkey
Column in Inventory***_pkey
inventory_id
Inventory***_key
Column in Inventory***_key
lot_number
Name
Product
Description
An idea with this is to be able to build a spec sheet if need be for web app customers instead of doing them by hand. A template will need to be made. I would say that anything that is not filled in will not show up on the frontend to the user unless they are in settings of setting up products. Any non usual select queries convert to JSONb (UPCs, Seasons,
Columns
Name
Data type
Param
Key
Not Null
product_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
Description
This makes the database automatically generate a UUID
web_app_customer_id
bigint
Yes
product_sku
varchar
40
Description
This is an internal product id. We have a shortened version for our pricelist program, others use UPC codes, etc. This is the all intensive purpose on "Item/Product Code"
quickbooks_product_id
integer
product_size
varchar
product_family
varchar
Yes
product_short_description
varchar
Yes
Description
This is what will be on the header of the pricelist sections. Probably having an example for reference like a photo would be helpful.
product_full_description
varchar
Description
This field will be used in invoicing customers. Similar to qbs.
pack_size
varchar
product_origin_id
integer
3
Yes
upc_outer
varchar
upc_inner
varchar
partials_per_case
integer
Yes
case_net_weight
integer
Yes
case_gross_weight
integer
Yes
product_utm_id
varchar
4
Yes
Description
bill by and unit of measure?? keep or get rid of?
bill_by
bigint
Yes
Description
might need to make a separate table for this and use integers as IDs - ???
catch_method
integer
Yes
latin_name
varchar
FAO
jsonb
special_import_requirements
jsonb
dimensions
jsonb
average_lead_time
integer
Description
how many days (divide by 7 to get weeks) are needed to produce the order
reorder_threshold
integer
Description
set what is deemed "re-order threshold" so it sends an alert to an admin or manager or "buyer"
reorder_alert
integer
Description
expressed in days (weeks is divide by 7)
low_inventory_alert
integer
Description
set what is deemed "low inventory" so it sends an alert to an admin or manager or "buyer"
special_import_requirements
varchar
selling_season
bigserial
Description
DEFAULT '[]' Imagine it listing out: - Like Summer - Start Date: May - End Date: Septmeber
upc_number
jsonb
Description
DEFAULT '[]' Imagine it listing out: - Outer UPC - UPC#
dimensions
jsonb
Description
DEFAULT '[]' Imagine it listing out: - Master Case - Length - Width - Height
cooking_instructions
jsonb
Description
can store multiple cooking instructions here
harvest_season_id
serial
product_photo_id
uuid
is_deleted
boolean
Description
DEFAULT FALSE This allows us to hide/archive for auditing purposes in the future or be able to restore a product in the future
product_document_id
bigserial
chart_of_accounts_type
bigint
Yes
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
last_modified_user_id
bigint
Yes
search_vector
tsvector
Keys
Product_pkey
Column in Product_pkey
product_id
Products***_key
Column in Products***_key
web_app_customer_id
Product***_key
Column in Product***_key
web_app_customer_id
Product***_key1
Column in Product***_key1
web_app_customer_id
Product***_key2
Column in Product***_key2
product_utm_id
Product***_key3
Column in Product***_key3
product_photo_id
Product***_key4
Column in Product***_key4
harvest_season_id
Product***_key5
Column in Product***_key5
product_document_id
Product_key
Relations
Name
Parent
Child
Name
Catch_method
Columns
Name
Data type
Param
Key
Not Null
catch_method_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
catch_method_name
varchar
Yes
description
text
Keys
Catch_method_pkey
Column in Catch_method_pkey
catch_method_id
Name
Advanced_settings**
Description
will be a work in progress... Divvy up based off Inventory, CRM, etc...
Columns
Name
Data type
Param
Key
Not Null
advanced_settings_id
serial
Yes
Yes
web_app_customer
bigint
Yes
set_po_number_global
varchar
set_po_number_prefix
boolean
Yes
po_number_prefix_per_user
boolean
quickbooks_integration_api
varchar
warehouse_starting_order_number
varchar
prefix_per_order_number_by_salesman
boolean
global_snooze_setting
varchar
Description
can take in "3 hours, 2 hours, 1 hour, 30 minutes, 15 minutes, 5 minutes"
Keys
Advanced_settings**_pkey
Column in Advanced_settings**_pkey
advanced_settings_id
Name
Company_global_settings**
Description
I think I need a global settings table to house customer settings. Advanced settings is for advanced settings that don't belong in standard settings like theme, langauage, time zone, ltr, etc. Global is the DEFAULT settings.
Columns
Name
Data type
Param
Key
Not Null
id
integer
Yes
Yes
Keys
Company_global_settings**_pkey
Column in Company_global_settings**_pkey
id
Name
User_settings**
Description
I do want settings for a per user basis. For example, some like a specific theme whereas some like darkmode. I want to be able to offer that to them. Not sure if languages would be for global for the customer or on a per user basis. The issue is how would it be a specific language? Like, global is English, but the user is Spanish. Would an admin or manager be able to add another language description to the product? More things to consider and think out!!
Columns
Name
Data type
Param
Key
Not Null
user_settings_id
serial
Yes
Yes
web_app_customer
bigint
Yes
salesman_prefix_to_order_number
varchar
6
allow_sales_popcards
boolean
Keys
User_settings**_pkey
Column in User_settings**_pkey
user_settings_id
Name
Bill_by** (aka "Sell By")
Description
More in-depth thinking needs to figure what this is for specifically! would we need UTM???
Columns
Name
Data type
Param
Key
Not Null
bill_by_id
bigserial
Yes
Yes
product_id
bigint
Yes
web_app_customer
bigint
Yes
bill_by_name
varchar
Yes
description
text
Keys
Bill_by** (aka "Sell By")_pkey
Column in Bill_by** (aka "Sell By")_pkey
bill_by_id
Name
Purchase Order Details
Columns
Name
Data type
Param
Key
Not Null
purchase_order_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer
bigint
Yes
vendor_id
bigint
Yes
purchase_order_number
varchar
Yes
pack_date
date
expiration_date
date
tlc_code
varchar
30
Description
"traceability lot code" - FDA Requirement 2026/27
purchase_order_items
bigserial
purchase_order_type***
serial
Yes
Purchase_order_sent
timestamptz
Yes
expected_bill_total
numeric
12, 2
payment_term_id
bigint
Yes
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
last_modified_user_id
bigint
Yes
status
varchar
20
Yes
Description
DEFAULT "Pending"
destination_country
integer
Yes
Description
This is for helping aid in assigning tariffs to a product that is ordered and where it is ultimately going to. Adding tariffs to this is for helping calculate. Most businesses write off tariffs so they just have the cost of the product and then add in their head what the "theoretical cost" is. $1/lb product at 25% tariff is really $0.25/lb. But, for clearing a container, it might be $0.25/lb but there are harbor maintenance fees on top of it, which throw it off. I think being able to add or "USE" the calculated cost including tariffs to use as the Theoretical Cost.
freight_cost
numeric
10,2
search_vector
tsvector
Keys
Purchase Order Details_pkey
Column in Purchase Order Details_pkey
purchase_order_id
Purchase Order Details_key
Column in Purchase Order Details_key
web_app_customer
Purchase Order Details_key1
Column in Purchase Order Details_key1
purchase_order_items
Name
Vendors**
Description
**Need to figure out how to tie products to a specific vendor. Would it be divvy'd up with "vendor details" and "vendor products" I think the details are JOINed together with the Vendors table
Columns
Name
Data type
Param
Key
Not Null
vendor_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer
bigint
Yes
vendor_name
varchar
41
Yes
vendor_dba
varchar
41
vendor_nickname
varchar
41
Description
Example, Rocky is Dalian Gourmet Foods. Or Ian is Dalian Zhengjun Foodstuff Search will index nicknames up to 3 letters at a minimum
preferred_vendor
boolean
vendor_type_id
serial
vendor_specialties
varchar
300
Yes
Description
Might be indexable for helping search for a vendor in the system that specializes in something you need. Like a trucker for an area or a vendor that sell a certain product.
plant_number
varchar
20
plant_code
varchar
20
fda_registration_number
varchar
20
china_registration_number
varchar
20
canadian_registration_number
varchar
20
eu_registration_number
varchar
20
registration_number
varchar
20
accounts_receivable_country_id
integer
3
accounts_receivable_zipcode
varchar
10
vendor_website
varchar
100
vendor_insured
boolean
vendor_insured_coverage_amount
varchar
paycargo
boolean
paycargo_website
varchar
300
vendor_login_username
varchar
100
vendor_login_password
varchar
100
vendor_shipping_destination_id
serial
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
last_modified_user_id
bigint
Yes
payment_terms_id
bigint
Yes
default_ship_terms_id
bigint
Yes
search_vector
tsvector
Keys
Vendors**_pkey
Column in Vendors**_pkey
vendor_id
Vendors**_key
Column in Vendors**_key
web_app_customer
Vendors**_key1
Column in Vendors**_key1
web_app_customer
Vendors**_key2
Column in Vendors**_key2
web_app_customer
Vendors**_key3
Column in Vendors**_key3
web_app_customer
Vendors**_key4
Column in Vendors**_key4
web_app_customer
Vendors**_key5
Vendors**_key6
Vendors**_key7
Vendors**_key8
Column in Vendors**_key8
vendor_shipping_destination_id
Name
Recalls** - NEED HELP
Description
This is for recalls. *Might need to add another table or more for all the things pertaining to one.
Columns
Name
Data type
Param
Key
Not Null
recall_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
recall_real_or_mock
boolean
Yes
inventory_product
bigint
Yes
Description
links to inventory_id
customer_orders
bigint
Yes
Description
links to order_id for all orders that pertain to this specific product in inventory (present, past)
Keys
Recalls** - NEED HELP_pkey
Column in Recalls** - NEED HELP_pkey
recall_id
Name
Order Line Items
Description
Considering it to be named "Order Products" This actually houses the items/products in the actual order. The Order table just houses the order details because customer_orders_id (changing to orders_id) has to be 1 number and it can't repeat. This is where multiple products can be added Same goes for Invoices... Same concept!
Columns
Name
Data type
Param
Key
Not Null
order_item_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer
bigint
Yes
order_id
bigint
Yes
inventory_product_id
bigint
Yes
inventory_lot_number
varchar
Yes
product_quantity
numeric
10,2
Yes
clean_out
boolean
Description
????? Would it technically calculate it after? or would it have to have an ASYNC operation to arrive at this conclusion??
product_price
numeric
10, 6
price_is_delivered
boolean
pallets_total
numeric
10, 2
Yes
Keys
Order Line Items_pkey
Column in Order Line Items_pkey
order_item_id
Name
invoices
Description
**How to void?? Need to figure out how to add a constraint as follows: ALTER TABLE invoice ADD CONSTRAINT unique_invoice_number_per_customer UNIQUE (web_app_customer_id, invoice_number);
Columns
Name
Data type
Param
Key
Not Null
invoice_id
bigserial
Yes
Yes
external_id
uuid
Yes
web_app_customer_id
bigint
Yes
order_id
bigint
Yes
invoice_number
text
Yes
invoice_date
date
Yes
Default value
CURRENT_DATE
due_date
date
currency_code**
varchar
3
Yes
Default value
'USD'
Description
Need to see about referencing an FK for this. Consult ChatGPT!!!
subtotal
numeric
(12, 2)
tax****
numeric
(12, 2)
Description
there are no taxes for wholesaling, but might need to add this for future...
total_amount
numeric
(12, 2)
order_type_name
text
Yes
payment_status
text
Yes
Default value
'unpaid'
status
text
Yes
Default value
'active'
Description
could be 'voided'
billing_address
text
shipping_address
text
created_automatically_by_user_id
bigint
Yes
created_at
timestamptz
Yes
Default value
now()
voided_by_user_id
bigint
Description
Not sure if i need to reference this or not. I think so, but not sure.
voided_at
timestamptz
voided_reason
text
customer_billing_address
jsonb
Yes
customer_po
text
Yes
trucker_id
bigint
salesman
bigint
Yes
searchable_content
tsvector
last_modified_by_user_id
bigint
last_modified_at
timestamptz
is_tax_applied
boolean
Default value
FALSE
tax_summary
jsonb
Default value
'{}'
payment_terms_id
bigint
Yes
Description
-- Set from order, but editable
search_vector
tsvector
use_fx_conversion
boolean
Default value
FALSE
converted_amount
numeric
12, 2
exchange_rate
numeric
20, 10
exchange_rate_date
date
Keys
invoices_pkey
Column in invoices_pkey
invoice_id
Name
Global App Settings
Description
These are the main settings for the actual overall web app.
Columns
Name
Data type
Param
Key
Not Null
setting_id
serial
Yes
Yes
setting_name
varchar
100
Yes
Yes
Description
UNIQUE
setting_value
text
Yes
description_text
text
Yes
Keys
Global App Settings_pkey
Column in Global App Settings_pkey
setting_id
Column in Global App Settings_pkey
setting_name
Name
Popcards
Description
This is for helping salesmen sell when they might be on a call or selling something to someone or a prospect.
Columns
Name
Data type
Param
Key
Not Null
popcard_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
popcard_name
varchar
Yes
popcard_value
varchar
Yes
Description
will need to elaborate on this. Need to figure out if I need to add more columns or whatnot.
Keys
Popcards_pkey
Column in Popcards_pkey
popcard_id
Name
Vendor_type
Columns
Name
Data type
Param
Key
Not Null
vendor_type_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
vendor_type_name
varchar
30
Yes
description
text
Keys
Vendor_type_pkey
Column in Vendor_type_pkey
vendor_type_id
Name
Country
Columns
Name
Data type
Param
Key
Not Null
country_id
serial
Yes
Yes
country_name
varchar
50
Yes
country_abreviation
varchar
3
Yes
Keys
Country_pkey
Column in Country_pkey
country_id
Name
Vendor_products
Columns
Name
Data type
Param
Key
Not Null
vendor_products_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
vendor_id
bigint
Yes
vendor_products
bigint
search_vector
tsvector
Keys
Vendor_products_pkey
Name
Purchase Order Line Items
Description
CHECK ( -- Ensure that either product_id or service_id is set, not both (product_id IS NOT NULL AND service_id IS NULL) OR (service_id IS NOT NULL AND product_id IS NULL) This makes sure that either or is NOT NULL. Might need to use "DECIMAL" as the data type.
Columns
Name
Data type
Param
Key
Not Null
purchase_order_item_id
bigserial
Yes
Yes
purchase_order_id
bigint
Yes
web_app_customer_id
bigint
Yes
product_id
bigint
service_id
bigint
quantity
numeric
10, 2
Yes
total_price
numeric
10, 2
Yes
unit_price
numeric
10, 6
Yes
vendor_id
bigserial
Yes
Keys
Purchase Order Line Items_pkey
Column in Purchase Order Line Items_pkey
purchase_order_item_id
Name
Session
Description
This stores sessions for all users. It only stores 1 session per user.
Columns
Name
Data type
Param
Key
Not Null
session_id
uuid
Yes
Yes
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
created_at
timestamptz
Default value
now()
expires_at
timestamptz
Yes
ip_address
varchar
45
Yes
Description
store ip address
user_agent
text
Yes
mfa_verified
boolean
Yes
Description
DEFAULT FALSE
mfa_verified_at
timestamptz
Yes
Keys
Session_pkey
Column in Session_pkey
session_id
Session_key
Column in Session_key
user_id
Name
Session Activities
Description
This stores activities of the last 5 or 10(?) sessions of a user to help compare if there is any anomolies to trigger MFA (2-factor authentication).
Columns
Name
Data type
Param
Key
Not Null
session_id
uuid
Yes
Yes
user_id
bigint
Yes
ip_address
varchar
45
Yes
user_agent
text
Yes
location
varchar
255
Yes
Description
geolocation
login_time
timestamptz
Yes
Default value
now()
last_activity
timestamptz
Yes
Description
DEFAULT NOW()
Keys
Session Activities_pkey
Column in Session Activities_pkey
session_id
Name
Sub Accounts
Columns
Name
Data type
Param
Key
Not Null
user_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
Description
external_id UUID DEFAULT gen_random_uuid() UNIQUE This makes the database automatically generate a UUID
web_app_customer_id
bigint
Yes
username
varchar
255
Yes
Description
UNIQUE
password_hash
varchar
255
Yes
user_role
serial
Yes
email
varchar
100
Yes
Description
UNIQUE
cellphone
varchar
21
wechat
varchar
50
whatsapp
varchar
50
language_code
text
Description
*defaults to the language on the device default language (ie: windows is english, then English it is). You can get this all from browser APIs.
created_at
timestamptz
Default value
now()
is_deleted
boolean
Description
DEFAULT FALSE This allows us to restore a user if need be.
is_active
boolean
Description
DEFAULT TRUE
updated_at
timestamptz
disk_usage
bigint
Description
DEFAULT 0
is_anonymized
boolean
Yes
Description
DEFAULT FALSE
deleted_at
timestamptz
Keys
Sub Accounts_pkey
Column in Sub Accounts_pkey
user_id
Sub Accounts_key
Column in Sub Accounts_key
user_role
Sub Accounts_key1
Column in Sub Accounts_key1
external_id
Relations
Name
Parent
Child
Name
MFA Token
Columns
Name
Data type
Param
Key
Not Null
token_id
uuid
Yes
Yes
user_id
bigint
Yes
token
varchar
6
Yes
expires_at
timestamptz
Yes
is_used
boolean
Yes
Description
DEFAULT FALSE
created_at
timestamptz
Yes
Default value
now()
Keys
MFA Token_pkey
Column in MFA Token_pkey
token_id
Relations
Name
Backup Codes
Columns
Name
Data type
Param
Key
Not Null
code_id
uuid
Yes
Yes
user_id
bigint
Yes
backup_code
varchar
12
Yes
is_used
boolean
Description
DEFAULT FALSE
Keys
Backup Codes_pkey
Column in Backup Codes_pkey
code_id
Name
User Role
Columns
Name
Data type
Param
Key
Not Null
user_id
bigint
Yes
role_id
bigint
Keys
User Role_pkey
Column in User Role_pkey
user_id
Name
Settings
Columns
Name
Data type
Param
Key
Not Null
setting_id
bigserial
Yes
Yes
setting_name
varchar
100
Yes
setting_value
text
Yes
Keys
Settings_pkey
Column in Settings_pkey
setting_id
Name
Role Settings
Description
Using Aproach 2 Conection Limit 5 (max by user_id or by IP). user_id might be best. But maybe 2 or 3 connections max. I would have to see if browser tabs open relate to this max connection. But, it might be based off browser id... Idk?
Columns
Name
Data type
Param
Key
Not Null
role_id
serial
Yes
Yes
setting_id
bigint
Yes
Keys
Role Settings_pkey
Column in Role Settings_pkey
role_id
Name
User Specific Settings
Columns
Name
Data type
Param
Key
Not Null
user_id
bigint
Yes
Yes
setting_name
varchar
100
Yes
Yes
setting_value
text
100
Yes
Keys
User Specific Settings_pkey
Column in User Specific Settings_pkey
setting_name
Column in User Specific Settings_pkey
user_id
Name
Feature Specific Settings
Description
These are module specific settngs. IE: CRM, Inventory, Products Site, Accounting, etc...
Columns
Name
Data type
Param
Key
Not Null
feature_setting_id
serial
Yes
Yes
feature_name
varchar
100
Yes
Description
UNIQUE
setting_name
varchar
100
Yes
setting_value
text
Yes
description_text
text
Yes
Keys
Feature Specific Settings_pkey
Column in Feature Specific Settings_pkey
feature_setting_id
Name
System Settings
Description
Not sure if I need this. It seems to be a table used for admins for low-level settings. But, IDK...
Columns
Name
Data type
Param
Key
Not Null
setting_id
serial
Yes
Yes
setting_name
varchar
100
Yes
Description
UNIQUE
setting_value
text
Yes
sensitive
boolean
Yes
Description
DEFAULT FALSE -- Marks sensitive settings like API keys
description_text
text
Yes
Keys
System Settings_pkey
Column in System Settings_pkey
setting_id
Name
Customer Contacts
Description
UNIQUE (web_app_customer_id, email)
Columns
Name
Data type
Param
Key
Not Null
customer_contact_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
customer_id
bigint
Yes
Yes
web_app_customer
bigint
Yes
buyer_position
varchar
50
Description
aka "role"
buyer_firstname
varchar
50
Yes
buyer_lastname
varchar
50
buyer_email
varchar
100
buyer_phone
varchar
21
buyer_phone_ext
varchar
10
buyer_phone_direct
varchar
21
buyer_mobile
varchar
21
buyer_mobile_sms
boolean
buyer_wechat
varchar
50
buyer_whatsapp
varchar
50
receives_pricelist
boolean
Yes
Default value
true
Description
I think default should be true if they have email address
is_deleted
boolean
Description
DEFAULT FALSE This allows the user to restore the contact in case they deleted them. Sort of like an "undo"
send_order_confirms
boolean
Yes
Default value
FALSE
send_invoices_to
boolean
Yes
Default value
FALSE
search_vector
tsvector
is_active
boolean
Default value
TRUE
created_at
timestamptz
Default value
now()
is_user
boolean
Default value
false
Description
Optional Login Field -- if true, fields below are used
password_hash
text
last_login
timestamptz
invited_at
timestamptz
accepted_invite_at
timestamptz
Keys
Customer Contacts_pkey
Column in Customer Contacts_pkey
customer_contact_id
Column in Customer Contacts_pkey
customer_id
Name
Vendor Contacts
Description
Some of the fields like "created_at" and "last_modified" might be for internal or deeper things for insights in the future...
Columns
Name
Data type
Param
Key
Not Null
vendor_contact_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer
bigint
Yes
vendor_id
bigint
Yes
vendor_contact_position
varchar
50
Yes
vendor_contact_nickname
varchar
50
vendor_contact_firstname
varchar
50
vendor_contact_lastname
varchar
50
vendor_contact_phone
varchar
21
vendor_contact_phone_ext
varchar
10
vendor_contact_cellphone
varchar
21
vendor_contact_sms
boolean
vendor_contact_wechat
varchar
50
vendor_contact_whatsapp
varchar
50
vendor_contact_email
varchar
100
Yes
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigserial
Yes
last_modified
timestamptz
Yes
last_modified_user_id
bigserial
Yes
Description
key'd off when it is made initially and updated later
search_vector
tsvector
Keys
Vendor Contacts_pkey
Column in Vendor Contacts_pkey
vendor_contact_id
Name
Vendor Shipping Destination
Columns
Name
Data type
Param
Key
Not Null
vendor_shipping destination_id
bigserial
Yes
web_app_customer
bigint
Yes
Yes
vendor_shipping_destination
varchar
100
Yes
Yes
search_vector
tsvector
Keys
Vendor Shipping Destination_pkey
Column in Vendor Shipping Destination_pkey
vendor_shipping_destination
Column in Vendor Shipping Destination_pkey
web_app_customer
Name
Product Harvest Season
Columns
Name
Data type
Param
Key
Not Null
harvest_season_id
serial
Yes
Yes
product_id
bigint
Yes
web_app_customer
bigint
Yes
harvest_season_name
varchar
40
Yes
Description
-- optional e.g. "A Season"
harvest_season_start
varchar
40
Yes
harvest_season_end
varchar
40
Yes
description
text
created_at
timestamptz
Default value
now()
Keys
Product Harvest Season_pkey
Column in Product Harvest Season_pkey
harvest_season_id
Name
Product UOM
Description
Is the product sold by the lb, case, etc.?
Columns
Name
Data type
Param
Key
Not Null
product_uom_id
serial
Yes
product_id
bigint
Yes
web_app_customer
bigint
Yes
product_uom_name
varchar
20
Yes
product_uom_abbv
varchar
4
Yes
description
text
Keys
Product UOM_pkey
Name
Warehouse Contacts
Columns
Name
Data type
Param
Key
Not Null
warehouse_contact_type_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer
bigint
Yes
warehouse_id
bigint
Yes
contact_position
varchar
50
Yes
Description
customer sets the type (receiving, manager, gm, customer service, owner, etc.)
warehouse_contact_name
varchar
100
Yes
warehouse_contact_email
varchar
100
warehouse_contact_phone
varchar
21
warehouse_contact_phone_ext
varchar
10
warehouse_contact_mobile_sms
boolean
warehouse_contact_mobile
varchar
21
warehouse_contact_wechat
varchar
50
warehouse_contact_whatsapp
varchar
50
Keys
Warehouse Contact Type_pkey1
Name
Reminders
Columns
Name
Data type
Param
Key
Not Null
reminders_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
Description
This makes the database automatically generate a UUID
user_id
bigint
Yes
web_app_customer_id
bigint
Yes
reminder_title
varchar
255
Yes
reminder_description
text
reminder_time
timestamptz
Yes
is_recurring
boolean
Description
DEFAULT FALSE
rexurring_interval
varchar
50
Description
-- daily, weekly, monthly, etc.
reminder_created_at
timestamptz
Default value
now()
is_deleted
boolean
Description
DEFAULT FALSE This is for auditing purposes so it is actually NOT deleted in the system. SMART!
search_vector
tsvector
Keys
Reminders_pkey
Column in Reminders_pkey
reminders_id
Name
Notifications
Columns
Name
Data type
Param
Key
Not Null
notifications_id
bigserial
Yes
Yes
reminders_id
bigint
Yes
notification_time
timestamptz
Yes
notification_status
varchar
50
Description
DEFAULT 'pending', -- pending, sent, failed
search_vector
tsvector
Keys
Notifications_pkey
Column in Notifications_pkey
notifications_id
Name
Subscription Plans
Columns
Name
Data type
Param
Key
Not Null
subscription_plans_id
integer
Yes
Yes
subscription_plan_name
varchar
255
Yes
max_sub_accounts
integer
Yes
Description
-- Max number of sub-accounts allowed
subscription_price
money
Yes
Description
-- Monthly price
subscription_duration_in_days
integer
Yes
Description
-- Duration of subscription in days
subscription_start_date
timestamptz
Description
-- Start date of the subscription
subscription_end_date
timestamptz
Description
-- End date of the subscription
core_currency_id
integer
Description
EXAMPLE: INSERT INTO subscription_plans (name, max_sub_accounts, price, currency_id, duration_in_days) VALUES ('Basic Plan', 1, 10.00, 1, 30), -- USD ('Standard Plan', 5, 25.00, 1, 30), -- USD ('Premium Plan', 10, 30.00, 2, 30); -- Converted to EUR
features
text
Description
List what features it comes with.
Keys
Subscription Plans_pkey
Column in Subscription Plans_pkey
subscription_plans_id
Subscription Plans_key
Column in Subscription Plans_key
core_currency_id
Name
core_web_app_currencies
Columns
Name
Data type
Param
Key
Not Null
core_currency_id
serial
Yes
Yes
currency_code
varchar
3
Description
UNIQUE -- ISO 4217 currency code (e.g., USD, EUR)
currency_symbol
varchar
10
Description
-- Currency symbol (e.g., $, €)
currency_exchange_rate
integer
10, 6
Yes
Description
*I'm hoping this acts like decimal. If not, change to "decimal" as the type in Postgresql. -- Exchange rate to a base currency (e.g., USD) EXAMPLE: INSERT INTO currencies (code, symbol, exchange_rate) VALUES ('USD', '$', 1.000000), -- Base currency ('EUR', '€', 0.850000), ('GBP', '£', 0.740000);
Keys
Currencies_pkey
Column in Currencies_pkey
core_currency_id
Name
Subscription Addons
Description
EXAMPLE: INSERT INTO subscription_addons (name, description, price, duration_in_days) VALUES ('50 GB Storage', 'Add 50 GB of storage to your plan.', 10.00, 30), ('100 GB Storage', 'Add 100 GB of storage to your plan.', 18.00, 30);
Columns
Name
Data type
Param
Key
Not Null
subscription_addons_id
serial
Yes
Yes
addon_name
varchar
255
Yes
Description
-- Name of the add-on (e.g., "50 GB Storage")
addon_description
text
Description
-- Description of the add-on
addon_price
money
Yes
Description
-- Price of the add-on per billing cycle
duration_in_days
integer
Yes
Description
-- Duration for which the add-on is valid (e.g., 30 days)
created_at
timestamptz
Default value
now()
updated_at
timestamptz
Keys
Subscription Addons_pkey
Column in Subscription Addons_pkey
subscription_addons_id
Name
User Subscriptions
Columns
Name
Data type
Param
Key
Not Null
user_subscriptions_id
serial
Yes
Yes
customer_id
uuid
subscription_plan_id
integer
stripe_subscription_id
varchar
255
Yes
stripe_payment_intent_id
varchar
255
amount_paid
money
Yes
core_currency_id
serial
Yes
payment_status
varchar
50
Yes
Description
-- Payment status (e.g., succeeded, pending)
billing_start
timestamptz
Yes
Description
-- Start of billing cycle
billing_end
timestamptz
Yes
Description
-- End of billing cycle
created_at
timestamptz
Default value
now()
updated_at
timestamptz
status
varchar
50
Description
DEFAULT 'active' -- e.g., 'active', 'cancelled', 'paused'
disk_quota
bigint
Yes
Keys
User Subscriptions_pkey
Column in User Subscriptions_pkey
user_subscriptions_id
Name
User Addons
Columns
Name
Data type
Param
Key
Not Null
user_addons_id
serial
Yes
Yes
user_subscription_id
integer
subscription_addon_id
integer
quantity
integer
Description
DEFAULT 1 -- Optional: Quantity of the add-on
created_at
timestamptz
Default value
now()
updated_at
timestamptz
Keys
User Addons_pkey
Column in User Addons_pkey
user_addons_id
Name
Chart of Accounts
Columns
Name
Data type
Param
Key
Not Null
chart_of_accounts_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
account_name
varchar
100
Yes
account_category_id
bigint
Yes
account_code
text
Description
UNIQUE
normal_balance_side
varchar
20
Yes
Description
specifically specifying whether it is CREDIT or DEBIT or something else.
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
last_modified_user_id
bigint
Yes
search_vector
tsvector
Keys
Chart of Accounts_pkey
Column in Chart of Accounts_pkey
chart_of_accounts_id
Name
Order Statuses
Columns
Name
Data type
Param
Key
Not Null
order_status_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
status_name
varchar
255
Yes
status_description
text
is_active
boolean
Description
DEFAULT TRUE
created_at
timestamptz
Default value
now()
Keys
Order Statuses_pkey
Name
Photos
Description
**How to resize images to a specific size? Need to use Python app
Columns
Name
Data type
Param
Key
Not Null
company_photo_id
bigserial
Yes
product_id
bigint
Yes
web_app_customer
bigint
Yes
company_photo_filename
text
Yes
company_photo_filepath
text
Yes
company_photo_original_size
integer
company_photo_compressed_size
integer
photo_file_ext
varchar
10
photo_type_id
serial
lot_number
varchar
50
photo_category
text
uploaded_at
timestamptz
Yes
Default value
now()
uploaded_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
last_modified_user_id
bigint
Yes
post_id
bigint
search_vector
tsvector
Keys
Photos_pkey
Name
Documents
Columns
Name
Data type
Param
Key
Not Null
product_document_id
bigserial
Yes
product_id
bigint
Yes
web_app_customer
bigint
Yes
product_document_filepath
varchar
255
Yes
product_document_filename
varchar
255
product_document_file_size
integer
file_type
text
lot_number
varchar
50
Description
**Need to think more on this!
uploaded_at
timestamptz
Default value
now()
uploaded_by_user_id
bigint
Yes
last_modified
timestamptz
last_modified_user_id
bigint
Yes
post_id
bigserial
search_vector
tsvector
Keys
Documents_pkey
Name
Photo Types
Description
Used for company internal things. Ex: Logo, trademarks, brands, etc. Sepcial photos...
Columns
Name
Data type
Param
Key
Not Null
photo_type_id
serial
Yes
Yes
product_id
bigint
Yes
web_app_customer
bigint
Yes
photo_type_name
varchar
255
Yes
description
text
created_at
timestamptz
Default value
now()
last_modified
timestamptz
Keys
Photo Types_pkey
Column in Photo Types_pkey
photo_type_id
Name
Notes
Columns
Name
Data type
Param
Key
Not Null
note_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
user_id
bigint
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
customer_id
bigint
note_content
text
Yes
created_at
timestamptz
Default value
now()
last_modified
timestamptz
reminder_at
timestamp
reminder_triggered
boolean
Description
DEFAULT FALSE
search_vector
tsvector
Keys
Notes_pkey
Column in Notes_pkey
note_id
Name
Blog Posts
Description
This is the equivalent of the Doc's Report on the Products Site.
Columns
Name
Data type
Param
Key
Not Null
post_id
bigserial
Yes
Yes
user_id
bigint
Yes
web_app_customer
bigint
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
title
varchar
255
Yes
content
text
Yes
created_at
timestamptz
Default value
now()
updated_at
timestamptz
published
boolean
Description
DEFAULT FALSE
search_vector
tsvector
Keys
Blog Posts_pkey
Column in Blog Posts_pkey
post_id
Name
Post Categories
Columns
Name
Data type
Param
Key
Not Null
post_id
bigint
Yes
Yes
category_id
bigint
Yes
Yes
web_app_customer
bigserial
Yes
search_vector
tsvector
Keys
Post Categories_pkey
Column in Post Categories_pkey
post_id
Name
Tags
Columns
Name
Data type
Param
Key
Not Null
tags_id
bigserial
Yes
Yes
web_app_customer
bigint
tags_name
varchar
100
Yes
Description
UNIQUE
search_vector
tsvector
Keys
Tags_pkey
Column in Tags_pkey
tags_id
Name
Post Tags
Columns
Name
Data type
Param
Key
Not Null
post_id
bigint
Yes
Yes
tag_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
search_vector
tsvector
Keys
Post Tags_pkey
Column in Post Tags_pkey
post_id
Column in Post Tags_pkey
tag_id
Name
Timezones
Columns
Name
Data type
Param
Key
Not Null
timezone_id
integer
Yes
Yes
timezone_name
varchar
100
Yes
Description
America/Los_Angeles
timezone_offset
varchar
6
Yes
Description
-08:00
timezone_translation
varchar
100
Yes
Description
Only do it when it is a foreign country in the specific spelling!
description
text
Description
(UTC-08:00) Pacific Time (US and Canada)
Keys
Timezones_pkey
Column in Timezones_pkey
timezone_id
Name
Storage Calculations
Description
Helping figure out storage calculations**
Columns
Name
Data type
Param
Key
Not Null
id
integer
Yes
Yes
Keys
Storage Calculations_pkey
Column in Storage Calculations_pkey
id
Name
Services***
Description
Need to EXPOUND on this!!! Can't receive it in, but bills can be associated with it. Need to research more!!!
Columns
Name
Data type
Param
Key
Not Null
service_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer
bigint
Yes
quickbooks_service_id
integer
service_name
varchar
255
Yes
description
text
chart_of_accounts_type
bigint
Yes
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
last_modified_user_id
bigint
Yes
search_vector
tsvector
Keys
Services***_pkey
Column in Services***_pkey
service_id
Name
Product Receipts***
Description
This is for receiving in products to "Inventory" and then we push/copy the info over to Inventory.
Columns
Name
Data type
Param
Key
Not Null
product_receipt_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
Description
This makes the database automatically generate a UUID
web_app_customer
bigint
Yes
received_in_at
timestamptz
Yes
Default value
now()
received_in_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
last_modified_by_user_id
bigint
Yes
search_vector
tsvector
Keys
Product Receipts***_pkey
Column in Product Receipts***_pkey
product_receipt_id
Name
Journal Entries
Columns
Name
Data type
Param
Key
Not Null
journal_entry_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
transaction_date
timestamptz
Yes
Description
DEFAULT CURRENT_DATE
description
text
accounting_period_id
bigserial
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
Default value
now()
last_modified_user_id
bigint
Yes
search_vector
tsvector
entry_status
text
Yes
Default value
'draft' CHECK (entry_status IN ('draft', 'posted', 'voided'))
Description
'draft' CHECK (entry_status IN ('draft', 'posted', 'voided'))
Keys
Journal Entries_pkey
Column in Journal Entries_pkey
journal_entry_id
Name
Journal Entries Line Items
Description
Need to use DECIMAL
Columns
Name
Data type
Param
Key
Not Null
line_item_id
bigserial
Yes
Yes
journal_entry_id
bigint
Yes
web_app_customer_id
bigint
Yes
account_id
bigint
Yes
debit
numeric
12, 2
Default value
CHECK (debit >= 0)
Description
CHECK (debit >= 0)
credit
numeric
12, 2
Default value
CHECK (credit >= 0)
Description
CHECK (credit >= 0)
memo
text
department_id
bigint
location_id
bigint
currency_code
varchar
3
exchange_rate
numeric
20, 10
external_reference
text
created_at
timestamptz
Default value
now()
created_by_user_id
timestamptz
Yes
last_modified
timestamptz
Default value
now()
last_modified_by_user_id
timestamptz
Keys
Journal Entries Line Items_pkey
Column in Journal Entries Line Items_pkey
line_item_id
Name
Emails
Columns
Name
Data type
Param
Key
Not Null
email_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
recipient
text
Yes
subject
text
Yes
body
text
Yes
sent_at
timestamptz
Yes
reply_token
uuid
Yes
Description
UNIQUE
status
text
Yes
is_html
boolean
Description
(Optional) Indicates if the body is HTML.
Keys
Emails_pkey
Column in Emails_pkey
email_id
Name
Emails Replies
Columns
Name
Data type
Param
Key
Not Null
email_reply_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
email_id
bigint
Yes
reply_body
text
Yes
received_at
timestamptz
Yes
Default value
now()
is_html
boolean
Description
(Optional) Indicates if the body is HTML.
Keys
Emails Replies_pkey
Column in Emails Replies_pkey
email_reply_id
Name
Email Accounts
Description
This is for storing the actual email credentials for each web app customer's sub account. Reason why for an individual is that some salesman might be using their own gmail account logins to send emails or own web server sending IMAP settings.
Columns
Name
Data type
Param
Key
Not Null
email_accounts_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
email_address
text
Yes
Description
UNIQUE
imap_server
text
Yes
imap_port
integer
Yes
Description
IMAP server port (e.g., 993 for SSL).
smtp_server
text
Yes
smtp_port
integer
Yes
Description
SMTP server port (e.g., 465 for SSL).
username
text
Yes
Description
Username for email authentication. Usually it is an email address.
password
text
Yes
Description
Password for email authentication. ENCRYPTED
created_at
timestamptz
Yes
Default value
now()
updated_at
timestamptz
Yes
Keys
Email Accounts_pkey
Column in Email Accounts_pkey
email_accounts_id
Name
Custom Order Instructions
Description
Used for setting up Customer Defaults
Columns
Name
Data type
Param
Key
Not Null
custom_order_instructions_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
customer_id
bigint
Yes
Yes
warehouse_id
bigint
Yes
instructions_text
text
search_vector
tsvector
Keys
Custom Order Instructions_pkey
Column in Custom Order Instructions_pkey
custom_order_instructions_id
Column in Custom Order Instructions_pkey
customer_id
Name
Action Logs
Description
This is for logging actions for all users. Early on this is crucial. But later on, it will become a pain point. Being able to offload this to some other database might be ideal. This will help keep the database running quickly.
Columns
Name
Data type
Param
Key
Not Null
action_log_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
action
varchar
255
Yes
details
jsonb
Description
Optional: Store additional details in JSON format
created_at
timestamptz
Yes
Default value
now()
Keys
Action Logs_pkey
Column in Action Logs_pkey
action_log_id
Name
files**** replicate other document table
Description
User Specific Documents internally** FOREIGN KEY (user_id) REFERENCES Sub Accounts (user_id) ON DELETE CASCADE
Columns
Name
Data type
Param
Key
Not Null
files_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
file_name
varchar
255
Yes
file_size
bigint
Yes
file_path
text
Yes
created_at
timestamptz
Yes
Default value
now()
modified_at
timestamptz
Keys
files**** replicate other document table_pkey
Column in files**** replicate other document table_pkey
files_id
Name
Shared Inventory****
Description
Need help on if we add user who made this, updated, modified it...; maybe even add an audit log table to track who made one and shared it, etc...
Columns
Name
Data type
Param
Key
Not Null
shared_intentory_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
user_id****
bigint
Yes
Description
need to know if its a sub_account with a lesser role or a speaprate table for shared accounts???
public_url
bigserial
Yes
created_at
timestamptz
Yes
Default value
now()
name
text
share_all_products
boolean
Yes
Default value
false
Keys
Shared Inventory****_pkey
Column in Shared Inventory****_pkey
shared_intentory_id
Name
Shared Inventory Details
Description
This is able to pull in Inventory which allows you to pull in product details. This is why Relationships exist. To make it faster and have less space. UNIQUE (shared_inventory_id, product_id, warehouse_id)
Columns
Name
Data type
Param
Key
Not Null
shared_intentory_details_id
bigserial
Yes
Yes
shared_inventory_id
bigint
Yes
inventory_id
bigint
Yes
warehouse_id
bigint
Yes
product_details
varchar
255
Yes
Keys
Shared Inventory Details_pkey
Column in Shared Inventory Details_pkey
shared_intentory_details_id
Name
Data Processing Audit
Description
You need a table to track processing activities for personal data. This ensures transparency and records compliance. Use Case: Record every action involving personal data. For example: - File uploads or deletions. - Sub-account creation or deletion. - Changes to user details (e.g., email or username).
Columns
Name
Data type
Param
Key
Not Null
data_processing_audit_id
integer
Yes
Yes
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
action
varchar
255
Yes
processed_at
timestamptz
Yes
Keys
Data Processing Audit_pkey
Column in Data Processing Audit_pkey
data_processing_audit_id
Name
Data Deletion Logs
Description
To support the right to erasure (Article 17), log data deletions for accountability. Use Case: This table tracks when and why data was deleted, ensuring compliance with the "right to be forgotten."
Columns
Name
Data type
Param
Key
Not Null
data_deletion_log_id
integer
Yes
Yes
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
entity_type
varchar
50
Yes
Description
-- Type of entity (e.g., "file", "user", "sub_account")
entity_id
bigserial
Yes
Description
-- ID of the deleted entity
deletion_reason
text
Description
-- Reason for deletion (optional)
deleted_at
timestamptz
Keys
Data Deletion Logs_pkey
Column in Data Deletion Logs_pkey
data_deletion_log_id
Name
User Consents
Columns
Name
Data type
Param
Key
Not Null
user_consent_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
consent_type
varchar
255
Yes
Description
-- Type of consent (e.g., "data processing", "email marketing")
consent_given
boolean
Yes
Description
-- Whether consent is given or withdrawn
consented_at
timestamptz
Yes
Default value
now()
Description
DEFAULT CURRENT_TIMESTAMPZ
Keys
User Consents_pkey
Column in User Consents_pkey
user_consent_id
Name
Purchase Order Vendors
Description
This table is to support the ability to do "split-POs". Meaning, havng 2 vendors on the same PO. This is usually an anomoly for us, but, it does happen. This ALSO allows me to convert a single vendor PO into a Split-PO. Pretty trick!
Columns
Name
Data type
Param
Key
Not Null
purchase_order_vendors_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
purchase_order_id
bigint
Yes
web_app_customer_id
bigint
Yes
vendor_id
bigint
Yes
vendor_amount
numeric
10, 2
Yes
status
varchar
20
Yes
Description
DEFAULT "Pending"
search_vector
tsvector
Keys
Purchase Order Vendors_pkey
Column in Purchase Order Vendors_pkey
purchase_order_vendors_id
Name
Inventory Revision Log
Description
This is for logging changes to inventory. It is similar to the "Transfer Log" but it tracks other changes. The revision log will record all changes to the inventory table, including the initial receipt and any updates to the lot_number
Columns
Name
Data type
Param
Key
Not Null
inventory_revision_log_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_customer_id
bigint
Yes
inventory_id
bigint
Yes
product_id
bigint
Yes
old_lot_number
varchar
20
Yes
new_lot_number
varchar
20
Yes
quantity
integer
Yes
action
varchar
50
Yes
change_timestamp
timestamptz
Yes
Default value
now()
change_by_user_id
bigint
Yes
search_vector
tsvector
Keys
Inventory Revision Log_pkey
Column in Inventory Revision Log_pkey
inventory_revision_log_id
Name
Transfer Log
Description
This is for keeping track of what product gets moved to where. Specifically for tracking productv lot# changes and reassigning lot#s to products. (Logs every transfer of inventory between warehouses, including any changes to the lot number.)
Columns
Name
Data type
Param
Key
Not Null
transfer_log_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_customer_id
bigint
Yes
inventory_id
bigint
Yes
product_id
bigint
Yes
from_warehouse_id
bigint
Yes
to_warehouse_id
bigint
Yes
old_lot_number
varchar
20
Yes
new_lot_number
varchar
20
Yes
quantity
integer
Yes
transfer_timestamp
timestamptz
Yes
Default value
now()
transferred_by_user_id
bigint
Yes
search_vector
tsvector
Keys
Transfer Log_pkey
Column in Transfer Log_pkey
transfer_log_id
Name
order_transactions
Description
This table logs every order movement affecting inventory.
Columns
Name
Data type
Param
Key
Not Null
transaction_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
order_id
bigint
Yes
order_line_item_id
bigint
Yes
inventory_id
bigint
Yes
transaction_type
varchar
50
Description
CHECK (transaction_type IN ('allocate', 'ship', 'return', 'cancel', 'adjust')),
inventory_adjustments_id
bigint
Yes
quantity_change
numeric
10, 2
Yes
Description
CHECK (quantity > 0), -- Quantity taken
previous_quantity
numeric
10, 2
Yes
resulting_quantity
numeric
10, 2
Yes
performed_by_user_id
bigint
Yes
performed_at
timestamptz
Yes
Default value
now()
comment
text
source
text
Description
this says if it was a "web, edi, api, etc." order/transaction. Forward thinking
reason_code
text
Description
e.g., short_ship, customer_return, internal_adjustment
search_vector
tsvector
Keys
order_transactions_pkey
Column in order_transactions_pkey
transaction_id
Name
Customer Products Pricelist
Description
I expect this to change. This is a placeholder to figure out how to set this up. The thought process is to mimic our current setup at work and then add to it. Since this is expected to be complicated, it will probably be broken up into different tables. Got to start somewhere!
Columns
Name
Data type
Param
Key
Not Null
pricelist_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
user_id
bigint
Yes
customer_id
bigint
Yes
product_id
bigint
Yes
warehouse_id
bigint
Yes
custom_price
numeric
10, 2
Yes
override_allowed
boolean
Yes
Description
DEFAULT TRUE
created_at
timestamptz
Yes
Default value
now()
updated_at
timestamptz
Yes
Keys
Customer Products Pricelist_pkey
Column in Customer Products Pricelist_pkey
pricelist_id
Name
Pricelist Details
Description
Pricelist Details - I think the premise for setting this up specifically is that there is the possibility that more than 1 pricelist can be made for a customer. There are multiple buyers, but it might be kind of nice to have a pricelist and then a specials pricelist sent out adjacently.
Columns
Name
Data type
Param
Key
Not Null
pricelist_details_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
pricelist_id
bigint
Yes
user_id
bigint
Yes
customer_id
bigint
Yes
Keys
Pricelist Details_pkey
Column in Pricelist Details_pkey
pricelist_details_id
Name
Product Tariffs
Description
This is for housing tariffs and taxes. A product can have MANY different taxes and they should be named and have descriptions. & TAX Tax. Calculations should be made for these, but it will be housed with seeing how many tariffs are for a specific product and whether or not the rate is calculated before or after freight. But there will be many calculations because there has to be. There is many variables.
Columns
Name
Data type
Param
Key
Not Null
tariff_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
product_id
bigint
Yes
vendor_id
bigint
Yes
country_id
integer
Yes
tariff_name
text
Yes
tariff_rate
numeric
6, 2
Yes
tariff_description
text
tariff_type
text
Yes
Description
tariff_type TEXT CHECK (tariff_type IN ('percentage', 'fixed')) NOT NULL,
effective_date
date
Yes
Description
NOT NULL DEFAULT CURRENT_DATE
expiration_date
date
created_at
timestamptz
Yes
Default value
now()
created_user_id
bigserial
Yes
last_modified
timestamptz
Yes
last_modified_user_id
bigserial
Yes
Keys
Product Tariffs_pkey
Column in Product Tariffs_pkey
tariff_id
Name
Shared Inventory Access
Description
This is for sharing your inventory with a fellow customer/competitor. *I think forcing the user to amke whom they share a customer makes better sense since you wouldn't technically share this with a competitor unless they were a customer essentially. Also, it will allow you to protect your product from others. UNIQUE (shared_inventory_id, shared_with_customer_id)
Columns
Name
Data type
Param
Key
Not Null
shared_inventory_access_id
bigint
Yes
Yes
shared_with_web_app_customer_id
bigint
Yes
shared_inventory_id
bigint
Yes
accepted_at
timestamptz
revoked_at
timestamptz
invited_by_customer_user_id
bigint
invited_token
uuid
created_at
timestamptz
Default value
now()
Keys
Shared Inventory Access_pkey
Column in Shared Inventory Access_pkey
shared_inventory_access_id
Name
Purchase Order Tariffs
Description
This is for housing tariffs assigned to POs. Helps keep historical data. I think Product Tariffs get copied over at the time of making a PO
Columns
Name
Data type
Param
Key
Not Null
tariff_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
purchase_order_id
bigint
Yes
product_id
bigint
Yes
vendor_id
bigint
Yes
country_id
integer
Yes
tariff_name
text
Yes
tariff_rate
numeric
6, 2
Yes
tariff_description
text
tariff_type
text
Yes
Description
tariff_type TEXT CHECK (tariff_type IN ('percentage', 'fixed')) NOT NULL,
effective_date
date
Yes
Description
NOT NULL DEFAULT CURRENT_DATE
Keys
Purchase Order Tariffs_pkey
Column in Purchase Order Tariffs_pkey
tariff_id
Purchase Order Tariffs_key
Name
demand_tags
Description
user defines their demand tags
Columns
Name
Data type
Param
Key
Not Null
demand_tag_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
demand_tag_text
varchar
50
Yes
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
last_updated_at
timestamptz
updated_by_user_id
bigint
search_vector
tsvector
Keys
demand_tags_pkey
Column in demand_tags_pkey
demand_tag_id
Name
Warehouse Product Prices
Description
This table will store the price adjustments based on the warehouse for each product:
Columns
Name
Data type
Param
Key
Not Null
warehouse_product_prices_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
external_id
uuid
Yes
Description
external_id UUID DEFAULT gen_random_uuid() UNIQUE This makes the database automatically generate a UUID
product_id
bigint
Yes
warehouse_id
bigint
Yes
list_price
numeric
10, 2
Yes
Keys
Warehouse Product Prices_pkey
Column in Warehouse Product Prices_pkey
warehouse_product_prices_id
Name
Product Selling Season
Columns
Name
Data type
Param
Key
Not Null
selling_season_id
bigserial
Yes
Yes
product_id
bigint
Yes
web_app_customer
bigint
Yes
selling_season_name
text
Yes
Description
-- optional e.g. "Grilling"
selling_season_start_day
integer
Yes
Description
-- 1–31
selling_season_end_month
integer
Yes
Description
-- 1–12
selling_season_end_day
integer
Yes
Description
-- 1–31
selling_season_end_month
integer
Yes
Description
-- 1–12
description
text
created_at
timestamptz
Keys
Product Selling Season_pkey
Column in Product Selling Season_pkey
selling_season_id
Name
Weather Conditions
Description
This is 1 part of a multi-part table to help predict when a product would be great to sell. It could eventually be used as a buide for ML when referencing sales for it.
Columns
Name
Data type
Param
Key
Not Null
weather_conditions_id
bigserial
Yes
Yes
web_app_customer
bigserial
Yes
condition
text
Yes
Description
UNIQUE
description
text
created_at
timestamptz
Yes
Default value
now()
last_modified_at
timestamptz
Keys
Weather Conditions_pkey
Column in Weather Conditions_pkey
weather_conditions_id
Name
Product Weather Suitability
Description
This is 1 part of a multi-part table to help predict when a product would be great to sell. It could eventually be used as a buide for ML when referencing sales for it.
Columns
Name
Data type
Param
Key
Not Null
product_id
bigint
Yes
web_app_customer
bigint
Yes
weather_condition_id
bigint
Yes
Description
UNIQUE
description
text
created_at
timestamptz
Yes
Default value
now()
last_modified_at
timestamptz
Keys
Product Weather Suitability_pkey
Name
Regions
Description
This is 1 part of a multi-part table to help predict when a product would be great to sell. It could eventually be used as a buide for ML when referencing sales for it.
Columns
Name
Data type
Param
Key
Not Null
regions_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
name
text
Yes
Description
UNIQUE
description
text
created_at
timestamptz
Yes
Default value
now()
last_modified_at
timestamptz
Keys
Regions_pkey
Column in Regions_pkey
regions_id
Name
Region Weather Alerts
Description
This is 1 part of a multi-part table to help predict when a product would be great to sell. It could eventually be used as a buide for ML when referencing sales for it.
Columns
Name
Data type
Param
Key
Not Null
region_id
bigserial
Yes
Yes
product_id
bigint
Yes
weather_condition_id
bigint
Yes
Yes
Description
UNIQUE
web_app_customer
bigint
Yes
Yes
recorded_at
timestamptz
Yes
Description
DEFAULT now()
Keys
Region Weather Alerts_pkey
Column in Region Weather Alerts_pkey
region_id
Column in Region Weather Alerts_pkey
weather_condition_id
Column in Region Weather Alerts_pkey
web_app_customer
Name
Vendor_vendor_types
Columns
Name
Data type
Param
Key
Not Null
vendor_type_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
vendor_id
bigint
Yes
Yes
vendor_type_name
varchar
30
Yes
description
text
Keys
Vendor_vendor_types_pkey
Column in Vendor_vendor_types_pkey
vendor_id
Column in Vendor_vendor_types_pkey
vendor_type_id
Name
admin_translations
Description
this is for storing special keys; UNIQUE (key, language_code)
Columns
Name
Data type
Param
Key
Not Null
key
text
Yes
Yes
Description
UNIQUE
language_code
text
Yes
Yes
Description
CHECK (char_length(language_code) <= 10),
translation
text
Yes
Keys
admin_translations_pkey
Column in admin_translations_pkey
key
Column in admin_translations_pkey
language_code
Name
product_translations
Columns
Name
Data type
Param
Key
Not Null
product_id
bigint
Yes
Yes
web_app_customer_id
bigint
Yes
Yes
language_code
text
Yes
Yes
Description
CHECK (char_length(language_code) <= 10)
name
text
description
text
search_vector
tsvector
Keys
product_translations_pkey
Column in product_translations_pkey
product_id
Column in product_translations_pkey
web_app_customer_id
Column in product_translations_pkey
language_code
Name
sellable_audit_log
Description
this is for being able to track who does the manual overrides for making customers unsellable.
Columns
Name
Data type
Param
Key
Not Null
sellable_audit_log_id
bigserial
Yes
Yes
customer_id
bigint
Yes
old_sellable
boolean
new_sellable
boolean
changed_by_user_id
bigint
Yes
changed_at
timestamptz
Yes
Default value
now()
old_customer_type_id
bigint
new_customer_type_id
bigint
change_note
text
Keys
sellable_audit_log_pkey
Column in sellable_audit_log_pkey
sellable_audit_log_id
Name
Customer Addresses
Columns
Name
Data type
Param
Key
Not Null
customer_address_id
bigserial
Yes
Yes
customer_id
bigint
Yes
Yes
web_app_customer_id
bigint
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
address_label
text
Yes
address_attn
text
address_location_name
text
address1
text
address2
text
address_country
text
address_phone
varchar
21
address_phone_ext1
varchar
10
address_phone2
varchar
21
address_phone_ext2
varchar
10
address_email1
varchar
100
address_email2
varchar
100
appointment_website
text
is_billing_address
boolean
Default value
true
Description
defaults to true, but there can only be 1 true billing address. need to figure out how to do this!
Keys
Customer Addresses_pkey
Column in Customer Addresses_pkey
customer_address_id
Column in Customer Addresses_pkey
customer_id
Name
Categories
Columns
Name
Data type
Param
Key
Not Null
category_id
bigserial
Yes
Yes
web_app_customer
bigint
category_name
varchar
100
Yes
Description
UNIQUE
search_vector
tsvector
Keys
Categories_pkey
Column in Categories_pkey
category_id
Name
web_app_customer_documents
Description
This is for storing web app customer specific internal documents
Columns
Name
Data type
Param
Key
Not Null
web_app_customer_document_id
bigserial
Yes
Yes
web_app_customer
bigint
Yes
title
text
description
text
product_document_filepath
varchar
255
Yes
product_document_filename
varchar
255
product_document_file_size
integer
file_type
text
uploaded_at
timestamptz
Default value
now()
uploaded_by_user_id
bigint
Yes
last_modified
timestamptz
last_modified_user_id
bigint
Yes
search_vector
tsvector
Keys
web_app_customer_documents_pkey
Column in web_app_customer_documents_pkey
web_app_customer_document_id
web_app_customer_documents_web_app_customer_document_id_key
Column in web_app_customer_documents_web_app_customer_document_id_key
web_app_customer_document_id
Name
web_app_customer_document_tags
Columns
Name
Data type
Param
Key
Not Null
web_app_customer_document_tag_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
web_app_customer_document_id
bigint
tag
text
Yes
Keys
web_app_customer_document_tags_pkey
Column in web_app_customer_document_tags_pkey
web_app_customer_document_tag_id
Name
invoice_customer_sequences
Description
This is for customers to set their starting invoice number & also to keep track of what their invoice number is so the system can auto increment by 1 up. Should I have a table for prefix or affixed leters???
Columns
Name
Data type
Param
Key
Not Null
web_app_customer_id
bigint
Yes
Yes
next_invoice_number
bigint
Yes
Keys
invoice_customer_sequences_pkey
Column in invoice_customer_sequences_pkey
web_app_customer_id
Name
invoice_line_items
Description
follows the same rule as Orders and Order Items tables ask chatgpt about inventory table sql and this table to see if i have the right foreign keys or not referenced in here.
Columns
Name
Data type
Param
Key
Not Null
invoice_item_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer
bigint
Yes
invoice_id
bigint
Yes
order_id
bigint
Yes
inventory_product_id
bigint
Yes
inventory_lot_number
varchar
Yes
product_quantity
numeric
10,2
Yes
clean_out
boolean
Description
????? Would it technically calculate it after? or would it have to have an ASYNC operation to arrive at this conclusion??
product_price
numeric
10, 6
Description
I want to be able to have more than 4 digits to calculate a price in case it is done in kgs. Might need to increase it actually!
price_is_delivered
boolean
Keys
invoice_line_items_pkey
Column in invoice_line_items_pkey
invoice_item_id
Name
inventory_adjustments
Description
This is very good practice, especially to handle cases like voiding invoices where you need to put products back into inventory and keep a clear audit trail. It allows to: Audit trail: You can track every change made to inventory—whether from sales, returns, voided invoices, manual corrections, etc. Transparency: Know who did what, when, and why. Reconciliation: Helps with inventory reconciliation and troubleshooting discrepancies. Separation of concerns: Keeps inventory transactions separate from core inventory quantities, which are typically calculated or stored elsewhere.
Columns
Name
Data type
Param
Key
Not Null
inventory_adjustments_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
inventory_id
bigint
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
adjustment_change
numeric
10, 2
Yes
Description
-- positive adds stock, negative subtracts
adjustment_reason
text
Yes
Description
-- e.g., 'invoice_voided', 'shipment', 'manual_correction'
reference_type
text
Description
-- e.g., 'invoice', 'order', 'manual'
reference_id
text
Description
-- e.g., invoice_id, order_id, or null for manual
comments
text
adjusted_by_user_id
bigint
adjusted_at
timestamptz
Yes
Default value
now()
Keys
inventory_adjustments_pkey
Column in inventory_adjustments_pkey
inventory_adjustments_id
Name
order_customer_sequences
Description
This is for customers to set their starting invoice number & also to keep track of what their invoice number is so the system can auto increment by 1 up. CONSTRAINT unique_customer_warehouse UNIQUE (web_app_customer_id, warehouse_id)
Columns
Name
Data type
Param
Key
Not Null
order_customer_sequences_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
warehouse_id
bigint
Default value
NULL
Description
-- NULL means global sequence for customer
next_order_number
bigint
Yes
prefix
text
Default value
NULL
suffix
text
Default value
NULL
Keys
invoice_customer_sequences_pkey
Column in invoice_customer_sequences_pkey
order_customer_sequences_id
Name
order_approvals
Description
being able to have a full audit of approvals for orders if a customer wants this**
Columns
Name
Data type
Param
Key
Not Null
order_approvals_id
bigserial
Yes
Yes
order_id
bigint
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
approved_by_user_id
bigint
Yes
action
text
Yes
Description
-- approved, rejected, pending
comment
text
action_timestamp
timestamptz
Default value
now()
Keys
order_approvals_pkey
Column in order_approvals_pkey
order_approvals_id
Name
customer_po_sequences
Description
ability to set the starting PO in the system and also set prefixes to orders by Buyer or by however.
Columns
Name
Data type
Param
Key
Not Null
web_app_customer_id
bigint
Yes
Yes
next_po_number
bigint
Yes
po_prefix
text
Default value
' '
po_suffix
text
Default value
' '
use_user_identifier
boolean
Default value
FALSE
po_tag_strategy
text
Default value
'none'
Description
-- options: 'none', 'user_prefix', 'order_type_suffix', 'custom' Could make this a jsonb and sore more than 1 option.
Keys
customer_po_sequences_pkey
Column in customer_po_sequences_pkey
web_app_customer_id
Name
customer_po_user_tags
Description
For example, Corey: user_tag = "C" or Barry as "B". It only applies if web_app_customer user_id has use_user_identification = TRUE
Columns
Name
Data type
Param
Key
Not Null
web_app_customer_id
bigint
Yes
Yes
user_id
integer
Yes
Yes
user_tag
text
Yes
Keys
customer_po_user_tags_pkey
Column in customer_po_user_tags_pkey
web_app_customer_id
Column in customer_po_user_tags_pkey
user_id
Name
customer_po_order_type_tags
Columns
Name
Data type
Param
Key
Not Null
web_app_customer_id
bigint
Yes
Yes
order_type
text
Yes
Yes
Description
-- e.g., 'domestic', 'foreign'
po_tag
text
Yes
Description
user would set D for domestic or F for foreign (similar to what Sea Port does)
Keys
customer_po_order_type_tags_pkey
Column in customer_po_order_type_tags_pkey
web_app_customer_id
Column in customer_po_order_type_tags_pkey
order_type
Name
Account Categories
Description
Ex: Asset, Liability, Equity, Revenue, Expense, Cogs
Columns
Name
Data type
Param
Key
Not Null
category_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
category_name
text
Yes
description
text
category_type
text
created_by_user_id
bigint
Yes
created_at
timestamptz
Yes
Default value
now()
last_modified_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
search_vector
tsvector
Yes
Keys
Account Categories_pkey
Column in Account Categories_pkey
category_id
Name
table1
Columns
Name
Data type
Param
Key
Not Null
id
integer
Yes
Yes
Keys
table1_pkey
Column in table1_pkey
id
Name
Currencies
Columns
Name
Data type
Param
Key
Not Null
currency_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
currency_code
varchar
3
Yes
currency_name
varchar
100
Yes
symbol
varchar
10
Yes
exchange_rate_to_base
numeric
10, 2
Yes
is_active
boolean
Default value
TRUE
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
updated_at
timestamptz
Yes
updated_by_user_id
bigint
Yes
Keys
Currencies_pkey
Column in Currencies_pkey
currency_id
Currencies_currency_code_key
Column in Currencies_currency_code_key
currency_code
Name
tax_rates
Columns
Name
Data type
Param
Key
Not Null
tax_rate_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
name
text
Yes
Description
-- e.g. "California State Tax", "GST Canada"
jurisdiction
text
Yes
Description
-- e.g. "CA", "NY", "Canada", "EU"
rate_percentage
numeric
5, 4
Yes
Description
-- e.g. 7.2500 (for 7.25%)
applies_to
text
Description
-- e.g. 'product', 'service', 'shipping'
effective_date
date
Yes
Description
-- When this tax rate started
end_date
date
Yes
Description
-- NULL if still active
compund
boolean
Default value
FALSE
inclusive
boolean
Default value
FALSE
created_by_user_id
bigint
Yes
created_at
timestamptz
Default value
now()
modified_by_user_id
bigint
Yes
last_modified
timestamptz
Keys
tax_rates_pkey
Column in tax_rates_pkey
tax_rate_id
Name
Vendor Bills
Columns
Name
Data type
Param
Key
Not Null
vendor_bill_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
bill_number
varchar
50
Yes
Description
vendors invoice#
vendor_id
bigint
Yes
bill date
date
Yes
Keys
Vendor Bills_pkey
Column in Vendor Bills_pkey
vendor_bill_id
Name
Vendor Payment Terms
Columns
Name
Data type
Param
Key
Not Null
payment_term_id
bigserial
Yes
Yes
web_customer_id
bigint
Yes
payment_name
integer
Yes
payment_days
integer
Yes
payment_description
text
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
updated_at
timestamptz
Yes
updated_by_user_id
bigint
Yes
Keys
Customer Payment Terms_pkey
Column in Customer Payment Terms_pkey
payment_term_id
Name
customer_accounting_mappings
Description
This is the behind the scenes mapping of different companyies to ERP softwares. Like this being linked to QBs UNIQUE (customer_id, ledger_id)
Columns
Name
Data type
Param
Key
Not Null
accounting_mapping_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
company_ledger_id
bigint
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
secondary_key
text
Description
Could be for saying the location like "us-west" or "us-east", etc.
metadata
jsonb
Default value
'{}'
Keys
customer_accounting_mappings_pkey
Column in customer_accounting_mappings_pkey
accounting_mapping_id
Name
company_ledgers
Description
This is the behind the scenes mapping of different companyies to ERP softwares. Like this being linked to QBs
Columns
Name
Data type
Param
Key
Not Null
company_ledger_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
system
text
Yes
Description
-- 'qbo', 'xero', 'dynamics_bc'
name
text
Yes
Description
-- Display name like "ACME USA QB"
credentials
jsonb
Yes
Description
-- Encrypted OAuth tokens, refresh tokens, keys
last_synced
timestamptz
is_active
boolean
Default value
TRUE
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
last_modified
timestamptz
Yes
modified_by_user_id
bigint
Yes
Keys
company_ledgers_pkey
Column in company_ledgers_pkey
company_ledger_id
Name
tax_rates_zones
Columns
Name
Data type
Param
Key
Not Null
tax_rate_zone_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
name
text
Yes
Description
-- e.g. "US East", "EU VAT Zone", "Canada GST"
description
text
Yes
created_by_user_id
bigint
Yes
created_at
timestamptz
Default value
now()
modified_by_user_id
bigint
Yes
last_modified
timestamptz
Keys
tax_rates_pkey
Column in tax_rates_pkey
tax_rate_zone_id
Name
tax_rate_zone_regions
Columns
Name
Data type
Param
Key
Not Null
tax_rate_region_zone_id
bigserial
Yes
Yes
tax_rate_zone_id
bigint
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
country_code
text
Yes
Description
-- ISO 3166-1 alpha-2 (e.g. "US", "CA", "DE")
region_code
text
postal_code_prefix
text
created_by_user_id
bigint
Yes
created_at
timestamptz
Default value
now()
modified_by_user_id
bigint
Yes
last_modified
timestamptz
Keys
tax_rate_zone_regions_pkey
Column in tax_rate_zone_regions_pkey
tax_rate_region_zone_id
Name
product_tax_exemptions
Columns
Name
Data type
Param
Key
Not Null
product_tax_exemptions_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
product_id
bigint
Yes
country_code
text
Yes
Description
-- e.g. "US", "DE"
region_code
text
Description
-- Optional: state/province
is_exempt
boolean
Yes
Default value
TRUE
reason
text
Description
-- Optional: "Food item", "Medical device", etc.
effective_date
date
Yes
Default value
CURRENT_DATE
end_date
date
Description
-- Optional
ceated_by_user_id
bigint
Yes
created_at
timestamptz
Yes
Default value
now()
modified_by_user_id
bigint
Yes
modified_at
timestamptz
Yes
Keys
product_tax_exemptions_pkey
Column in product_tax_exemptions_pkey
product_tax_exemptions_id
Name
customer_tax_exemptions
Columns
Name
Data type
Param
Key
Not Null
customer_tax_exemptions_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
customer_id
bigint
Yes
country_code
text
Yes
Description
-- e.g. "US", "DE"
region_code
text
Description
-- Optional: state/province
exemption_type
text
Default value
TRUE
certificate_number
text
expiration_date
date
Default value
CURRENT_DATE
verified
boolean
Default value
FALSE
notes
text
uploaded_certificate_url
text
Description
-- (if you store a scanned document)
ceated_by_user_id
bigint
Yes
created_at
timestamptz
Yes
Default value
now()
modified_by_user_id
bigint
Yes
modified_at
timestamptz
Yes
Keys
product_tax_exemptions_pkey
Column in product_tax_exemptions_pkey
customer_tax_exemptions_id
Name
bills
Description
These are bills from vendors
Columns
Name
Data type
Param
Key
Not Null
bill_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
vendor_id
bigint
Yes
bill_number
text
Yes
bill_date
date
Yes
due_date
date
Yes
total_amount
numeric
10, 2
Yes
currency_id****???
bigint
Yes
Description
Do I reference FK of the ID or FK of the "code"???
status
text
Yes
Description
DEFAULT 'unpaid' - need to know how to do this for "multi-ligual" ??
purchase_order_id
bigint
Description
-- nullable, no FK constraint. Means that a PO# can be linked or not. Works if you are putting in an electric bill, etc.
notes
text
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
updated_at
timestamptz
updated_by_user_id
bigint
search_vector
tsvector
Keys
bills_pkey
Column in bills_pkey
bill_id
Name
bill_line_items
Columns
Name
Data type
Param
Key
Not Null
bill_line_item_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
bill_id
bigint
Yes
description
text
Yes
quantity
numeric
10, 2
Yes
unit_cost
numeric
10, 6
Yes
line_total
numeric
12, 2
Default value
GENERATED ALWAYS AS (quantity * unit_cost) STORED
chart of accounts_id
bigint
Yes
inventory_id
bigint
received_date
date
notes
text
Keys
bill_line_items_pkey
Column in bill_line_items_pkey
bill_line_item_id
Name
payments
Columns
Name
Data type
Param
Key
Not Null
payment_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
payment_type
text
Yes
Default value
CHECK (payment_type IN ('customer', 'vendor'))
Description
CHECK (payment_type IN ('customer', 'vendor'))
customer_paye_id
bigint
Description
-- if payment_type = 'customer', references customers
vendor_payee_id
bigint
Description
-- if payment_type = 'vendor', references vendors
payment_method_id
bigint
Yes
reference_number
text
Yes
Description
-- check #, wire ref, etc.
payment_date
date
Yes
Default value
CURRENT_DATE
amount
numeric
12, 2
Yes
Default value
CHECK (amount > 0)
Description
CHECK (amount > 0)
payment_method_id
bigint
Yes
currency_code***
varchar
3
Yes
Description
Look at others referencing this!!*** More thought needs to be put into this field! Currency as a company and currency as a web app customer are 2 different things!
applied
boolean
Default value
FALSE
Description
-- toggles when it's applied to bills/invoices
applied_on
timestamptz
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
updated_at
timestamptz
last_modified_by_user_id
bigint
use_fx_conversion
boolean
Default value
FALSE
Keys
payments_pkey
Column in payments_pkey
payment_id
Name
exchange_rates****??
Description
UNIQUE(source_currency, target_currency, rate_timestamp)
Columns
Name
Data type
Param
Key
Not Null
exchange_rate_id
bigserial
Yes
Yes
source_currency
varchar
3
Yes
target_currency
varchar
3
Yes
rate
numeric
20, 10
Yes
Description
-- high precision for large invoices
rate_timestamp
timestamptz
Yes
Default value
now()
Description
-- when rate was fetched
provider
text
Keys
exchange_rates****??_pkey
Column in exchange_rates****??_pkey
exchange_rate_id
Name
payment_applications
Description
This table enables partial payments, multi-invoice application, and auditability.
Columns
Name
Data type
Param
Key
Not Null
payment_application_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
payment_id
bigint
Yes
Description
-- if payment_type = 'customer', references customers
target_type
text
Yes
Default value
CHECK (target_type IN ('invoice', 'bill'))
Description
CHECK (target_type IN ('invoice', 'bill'))
target_id
bigint
Yes
Description
-- references invoice_id or bill_id depending on type
applied_amount
numeric
12, 2
Default value
CHECK (applied_amount > 0)
Description
CHECK (applied_amount > 0)
applied_on
timestamptz
Yes
Default value
now()
Keys
payment_applications_pkey
Column in payment_applications_pkey
payment_application_id
Name
payment_methods
Description
UNIQUE(web_app_customer_id, method_code)
Columns
Name
Data type
Param
Key
Not Null
payment_method_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
method_code
text
Yes
Description
-- internal short name, e.g. 'ACH', 'PIX'
method_name
text
Yes
Description
-- display name, e.g. 'Bank Transfer (ACH)'
country_code
varchar
2
Description
-- optional, e.g., 'US', 'BR'
currency_code***???
varchar
3
Description
-- optional, e.g., 'USD', 'BRL'
default_payment_term_id
bigint
is_enabled
boolean
Default value
TRUE
sort_order
bigint
Default value
0
integration_metadata
jsonb
Description
-- holds tokens, API keys, webhook configs, etc. Ex: { "bank_name": "Chase", "routing_number": "021000021", "account_number": "987654321", "account_type": "Checking" }
instructions
text
Description
-- text to show customers (e.g., “Please include invoice #”)
custom_fields
jsonb
Description
-- optional custom fields shown at checkout or billing
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
updated_at
timestamptz
updated_by_user_id
bigint
Yes
Keys
payment_methods_pkey
Column in payment_methods_pkey
payment_method_id
Name
account_periods
Description
the concept of accounting_period_id and an accounting_periods table is foundational in any accounting system. It gives you control over how you group, close, report, and validate financial activity over time. UNIQUE (web_app_customer_id, fiscal_year, fiscal_period) fiscal_year: e.g., 2025 fiscal_period: e.g., 1 = Jan, 2 = Feb — or week number in 4-4-5 systems is_closed: Lets you prevent any further entries from being posted locked_by_user_id: Audit trail
Columns
Name
Data type
Param
Key
Not Null
accounting_period_id
bigserial
Yes
Yes
external_id
uuid
Yes
Default value
gen_random_uuid() UNIQUE
web_app_customer_id
bigint
Yes
fiscal_year
bigint
Yes
fiscal_period
bigint
Yes
Description
-- Usually 1–12, but flexible
fiscal_quarter
bigint
Description
-- Can be 1 to 13 or more
period_start_date
date
Yes
period_end_date
date
Yes
is_closed
boolean
Default value
FALSE
locked_at
timestamptz
Default value
now()
locked_by_user_id
bigint
search_vector
tsvector
Indexes
idx_accounting_periods_date_lookup
Description
CREATE INDEX idx_accounting_periods_date_lookup ON accounting_periods (web_app_customer_id, period_start_date, period_end_date);
Keys
account_periods_pkey
Column in account_periods_pkey
accounting_period_id
Name
bank_accounts
Description
CONSTRAINT unique_account_per_customer UNIQUE (web_app_customer_id, account_number) Use pgcrypto to encrypt: account_number, routing_number, iban, swift_code
Columns
Name
Data type
Param
Key
Not Null
bank_account_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
account_name
varchar
255
Yes
account_number
varchar
50
Yes
routing_number
varchar
50
swift_code
varchar
11
iban
varchar
34
bank_name
varchar
255
Yes
bank_address
jsonb
Description
will have multiple fields
currency_code*****???
varchar
3
Yes
account_type
varchar
50
Yes
Description
-- e.g., Checking, Savings, etc.
is_active
boolean
Yes
Default value
TRUE
is_deleted
boolean
Yes
Default value
FALSE
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
updated_at
timestamptz
Yes
Default value
now()
updated_by_user_id
bigint
Yes
deleted_at
timestamptz
Indexes
idx_bank_accounts_customer_id
Description
CREATE INDEX idx_bank_accounts_customer_id ON bank_accounts(web_app_customer_id);
idx_bank_accounts_account_number
Description
CREATE INDEX idx_bank_accounts_account_number ON bank_accounts(account_number);
idx_bank_accounts_is_active
Description
CREATE INDEX idx_bank_accounts_is_active ON bank_accounts(is_active);
idx_bank_accounts_is_deleted
Description
CREATE INDEX idx_bank_accounts_is_deleted ON bank_accounts(is_deleted);
Keys
bank_accounts_pkey
Column in bank_accounts_pkey
bank_account_id
Name
bank_transactions
Columns
Name
Data type
Param
Key
Not Null
bank_transaction_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
bank_account_id
bigint
Yes
transaction_type
varchar
50
Yes
Default value
CHECK (transaction_type IN ( 'deposit', 'withdrawal', 'transfer_in', 'transfer_out', 'fee', 'interest', 'adjustment' ))
Description
CHECK (transaction_type IN ( 'deposit', 'withdrawal', 'transfer_in', 'transfer_out', 'fee', 'interest', 'adjustment' ))
transaction_date
timestamptz
Yes
Default value
now()
amount
numeric
12, 2
Yes
Default value
CHECK (amount >= 0)
Description
CHECK (amount >= 0)
currency_code
varchar
3
Yes
original_amount
numeric
12, 2
Yes
original_currency_code
varchar
3
fx_rate***???
numeric
20, 10
Yes
fx_applied
boolean
Yes
Default value
FALSE
description
text
reference_number
varchar
100
linked_entity_type
varchar
50
Description
-- e.g., 'invoice', 'bill', 'payment'
linked_entity_id
bigint
is_reconciled
boolean
Yes
Default value
FALSE
bank_reconciliation_id
bigint
Yes
reconciled_at
timestamptz
reconciled_by_user_id
bigint
is_deleted
boolean
Yes
Default value
FALSE
deleted_at
timestamptz
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
updated_at
timestamptz
Yes
Default value
now()
updated_by_user_id
bigint
Yes
Indexes
idx_bank_transactions_customer_id
Description
CREATE INDEX idx_bank_transactions_customer_id ON bank_transactions(web_app_customer_id);
idx_bank_transactions_bank_account_id
Description
CREATE INDEX idx_bank_transactions_bank_account_id ON bank_transactions(bank_account_id);
idx_bank_transactions_reconciliation_status
Description
CREATE INDEX idx_bank_transactions_reconciliation_status ON bank_transactions(is_reconciled);
idx_bank_transactions_transaction_date
Description
CREATE INDEX idx_bank_transactions_transaction_date ON bank_transactions(transaction_date);
Keys
bank_transactions_pkey
Column in bank_transactions_pkey
bank_transaction_id
Name
bank_reconciliations
Columns
Name
Data type
Param
Key
Not Null
bank_reconciliation_id
bigserial
Yes
Yes
web_app_customer_id
bigint
Yes
bank_account_id
bigint
Yes
statement_start_date
date
Yes
statement_end_date
date
Yes
Default value
now()
statement_closing_balance
numeric
12, 2
Yes
Default value
CHECK (amount >= 0)
Description
CHECK (amount >= 0)
calculated_ending_balance
numeric
12, 2
difference
numeric
12, 2
Description
-- Difference between statement and calculated (should be 0 when reconciled)
is_finalized
boolean
Yes
Default value
FALSE
finalized
timestamptz
finalized_by_user_id
bigint
notes
text
Description
-- e.g., 'invoice', 'bill', 'payment'
reconciliation_date
timestamptz
Yes
Default value
now()
is_deleted
boolean
Yes
Default value
FALSE
deleted_at
timestamptz
created_at
timestamptz
Yes
Default value
now()
created_by_user_id
bigint
Yes
updated_at
timestamptz
Yes
Default value
now()
updated_by_user_id
bigint
Yes
recalculated_balance
numeric
12, 2
balance_difference
numeric
12, 2
last_calculated_at
timestamptz
anomaly_detected
boolean
Default value
FALSE
Indexes
idx_bank_reconciliations_customer_id
Description
CREATE INDEX idx_bank_reconciliations_customer_id ON bank_reconciliations(web_app_customer_id);
idx_bank_reconciliations_bank_account_id
Description
CREATE INDEX idx_bank_reconciliations_bank_account_id ON bank_reconciliations(bank_account_id);
idx_bank_reconciliations_reconciliation_date
Description
CREATE INDEX idx_bank_reconciliations_reconciliation_date ON bank_reconciliations(reconciliation_date);
Keys
bank_reconciliations_pkey
Column in bank_reconciliations_pkey
bank_reconciliation_id
Name
reconciliation_anomalies
Description
NEED TO DO THIS --> ALTER TABLE reconciliation_anomalies ADD CONSTRAINT fk_anomalies_reconciliation FOREIGN KEY (bank_reconciliation_id) REFERENCES bank_reconciliations(bank_reconciliation_id);
Columns
Name
Data type
Param
Key
Not Null
anomaly_id
bigserial
Yes
Yes
web_app_customer_id
bigserial
Yes
bank_reconciliation_id
bigint
Yes
previous_difference
numeric
10, 2
new_difference
numeric
10, 2
detected_at
timestamptz
Default value
now()
reported
boolean
Default value
FALSE
anomaly_type
text
Default value
'reconciliation_mismatch'
Description
'reconciliation_mismatch'
resolved_by_user_id
bigint
resolved_at
timestamptz
Indexes
idx_anomalies_reported_detected
Description
CREATE INDEX idx_anomalies_reported_detected ON reconciliation_anomalies(reported, detected_at);
Keys
reconciliation_anomalies_pkey
Column in reconciliation_anomalies_pkey
anomaly_id
Name
alert_events
Columns
Name
Data type
Param
Key
Not Null
alert_id
bigserial
Yes
Yes
web_app_customer_id
bigserial
Yes
alert_type
text
anomaly_id
bigint
message
text
sent_at
timestamptz
Default value
now()
recipient
text
Keys
alert_events_pkey
Column in alert_events_pkey
alert_id
Name
audit_events
Columns
Name
Data type
Param
Key
Not Null
id
integer
Yes
Yes
Keys
audit_events_pkey
Column in audit_events_pkey
id
Name
notifications
Columns
Name
Data type
Param
Key
Not Null
id
integer
Yes
Yes
Keys
notifications_pkey
Column in notifications_pkey
id
Name
reconciliation_lines
Columns
Name
Data type
Param
Key
Not Null
reconciliation_line_id
bigserial
Yes
Yes
bank_reconciliation_id
bigint
Yes
web_app_customer_id
bigint
Yes
transaction_date
date
Yes
amount
numeric
12, 2
Yes
cleared
boolean
Default value
FALSE
cleared_at
timestamptz
cleared_by_user_id
bigint
source_type
text
Description
-- 'payment', 'bill', 'journal_entry', etc.
source_id
bigint
description
text
created_at
timestamptz
Default value
now()
Keys
reconciliation_lines_pkey
Column in reconciliation_lines_pkey
reconciliation_line_id
relationships
Name
Orders_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in Orders
Customers_pkey
customer_id
customer_id
Name
Customers_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Customers
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Orders_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Orders
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Warehouse_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Warehouse
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Orders_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in Orders
Warehouse_pkey
warehouse_id
warehouse_id
Name
Orders_order_type_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Order_Type
Column in Orders
Order_Type_pkey
order_type_id
order_type_id
Name
Customers_payment_term_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Payment Terms
Column in Customers
Customer Payment Terms_pkey
payment_term_id
payment_term_id
Name
Orders_ship_term_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Ship_terms
Column in Orders
Ship_terms_pkey
ship_terms_id
ship_term
Name
Inventory***_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in Inventory***
Warehouse_pkey
warehouse_id
warehouse_id
Name
Product_catch_method_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Catch_method
Column in Product
Catch_method_pkey
catch_method_id
catch_method
Name
Advanced_settings**_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Advanced_settings**
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Product_bill_by_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Bill_by** (aka "Sell By")
Column in Product
Bill_by** (aka "Sell By")_pkey
bill_by_id
bill_by
Name
Inventory***_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Inventory***
Product_pkey
product_id
product_id
Name
Inventory***_purchase_order_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Purchase Order Details
Column in Inventory***
Purchase Order Details_pkey
purchase_order_id
purchase_order_id
Name
Purchase Order Details_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Purchase Order Details
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Vendors**_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Vendors**
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Product_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Product
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Recalls** - NEED HELP_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Recalls** - NEED HELP
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Recalls** - NEED HELP_inventory_product_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in Recalls** - NEED HELP
Inventory***_pkey
inventory_id
inventory_product
Name
Recalls** - NEED HELP_customer_orders_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Orders
Column in Recalls** - NEED HELP
customers_uuid
order_id
customer_orders
Name
Order Line Items_order_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Orders
Column in Order Line Items
customers_uuid
order_id
order_id
Name
Order Line Items_inventory_lot_number_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in Order Line Items
Inventory***_key
lot_number
inventory_lot_number
Name
Order Line Items_inventory_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in Order Line Items
Inventory***_pkey
inventory_id
inventory_product_id
Name
User_settings**_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in User_settings**
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Vendors**_vendor_type_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendor_type
Column in Vendors**
Vendor_type_pkey
vendor_type_id
vendor_type_id
Name
Product_product_origin_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Country
Column in Product
Country_pkey
country_id
product_origin_id
Name
Vendor_products_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Vendor_products
Vendors**_pkey
vendor_id
vendor_id
Name
Vendor_products_vendor_products_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Vendor_products
Product_pkey
product_id
vendor_products
Name
Orders_trucker_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Orders
Vendors**_pkey
vendor_id
trucker_id
Name
Inventory***_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Inventory***
Products***_key
web_app_customer_id
web_app_customer
Name
Vendor_products_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Vendor_products
Vendors**_key
web_app_customer
web_app_customer
Name
Purchase Order Details_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Purchase Order Details
Vendors**_pkey
vendor_id
vendor_id
Name
Purchase Order Line Items_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Purchase Order Details
Column in Purchase Order Line Items
Purchase Order Details_key
web_app_customer
web_app_customer_id
Name
Purchase Order Line Items_purchase_order_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Purchase Order Details
Column in Purchase Order Line Items
Purchase Order Details_pkey
purchase_order_id
purchase_order_id
Name
Purchase Order Line Items_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Purchase Order Line Items
Product_pkey
product_id
product_id
Name
Purchase Order Line Items_purchase_order_item_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Purchase Order Details
Column in Purchase Order Line Items
Purchase Order Details_key1
purchase_order_items
purchase_order_item_id
Name
Session Activities_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Session
Column in Session Activities
Session_key
user_id
user_id
Name
Session Activities_session_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Session
Column in Session Activities
Session_pkey
session_id
session_id
Name
MFA Token_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Session
Column in MFA Token
Session_key
user_id
user_id
Name
Backup Codes_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Backup Codes
Sub Accounts_pkey
user_id
user_id
Name
User Role_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in User Role
Sub Accounts_pkey
user_id
user_id
Name
User Role_role_id_fkey
Description
says to do MANY to MANY relations
Name
Source
Target
Cardinality type:
Many to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Roles
Column in User Role
Roles_pkey
role_id
role_id
Name
Role Settings_role_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Roles
Column in Role Settings
Roles_pkey
role_id
role_id
Name
Role Settings_setting_id_fkey
Description
MANY TO MANY relation
Name
Source
Target
Cardinality type:
Many to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Settings
Column in Role Settings
Settings_pkey
setting_id
setting_id
Name
Sub Accounts_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Sub Accounts
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Sub Accounts_language_code_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Languages
Column in Sub Accounts
Languages_pkey1
languages_code
language_code
Name
User Specific Settings_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in User Specific Settings
Sub Accounts_pkey
user_id
user_id
Name
Customer Contacts_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in Customer Contacts
Customers_key1
web_app_customer
web_app_customer
Name
Vendor Contacts_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Vendor Contacts
Vendors**_key1
web_app_customer
web_app_customer
Name
Vendors**_accounts_receivable_country_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Country
Column in Vendors**
Country_pkey
country_id
accounts_receivable_country_id
Name
Vendor Shipping Destination_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Vendor Shipping Destination
Vendors**_key4
web_app_customer
web_app_customer
Name
Product Harvest Season_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Product Harvest Season
Product***_key
web_app_customer_id
web_app_customer
Name
Product UOM_product_uom_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Product UOM
Product***_key2
product_utm_id
product_uom_id
Name
Product Harvest Season_harvest_season_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Product Harvest Season
Product***_key4
harvest_season_id
harvest_season_id
Name
Vendor Shipping Destination_vendor_shipping destination_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Vendor Shipping Destination
Vendors**_key8
vendor_shipping_destination_id
vendor_shipping destination_id
Name
Reminders_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Reminders
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Notifications_reminders_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Reminders
Column in Notifications
Reminders_pkey
reminders_id
reminders_id
Name
User Role_role_id_fkey1
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in User Role
Sub Accounts_key
user_role
role_id
Name
Subscription Plans_subscription_plans_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Subscription Plans
Web_App_Customer_key
subscription_plan_id
subscription_plans_id
Name
core_web_app_currencies_core_currency_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Subscription Plans
Column in core_web_app_currencies
Subscription Plans_key
core_currency_id
core_currency_id
Name
User Subscriptions_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in User Subscriptions
Web_App_Customer_pkey
web_app_customer_id
customer_id
Name
User Subscriptions_core_currency_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in core_web_app_currencies
Column in User Subscriptions
Currencies_pkey
core_currency_id
core_currency_id
Name
User Addons_user_subscription_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in User Subscriptions
Column in User Addons
User Subscriptions_pkey
user_subscriptions_id
user_subscription_id
Name
User Addons_subscription_addon_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Subscription Addons
Column in User Addons
Subscription Addons_pkey
subscription_addons_id
subscription_addon_id
Name
User Subscriptions_subscription_plan_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Subscription Plans
Column in User Subscriptions
Subscription Plans_pkey
subscription_plans_id
subscription_plan_id
Name
Catch_method_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Catch_method
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Order_Type_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Order_Type
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Order Line Items_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Order Line Items
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Order Statuses_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Order Statuses
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Order Statuses_order_status_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Orders
Column in Order Statuses
Order Details - COME BACK TO! NEED MORE WORK!_key
order_status_id
order_status_id
Name
Photos_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Photos
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Photo Types_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Photo Types
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Photos_photo_type_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Photo Types
Column in Photos
Photo Types_pkey
photo_type_id
photo_type_id
Name
Documents_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Documents
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Ship_terms_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Ship_terms
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Notes_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Notes
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Notes_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Notes
Sub Accounts_pkey
user_id
user_id
Name
Notes_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in Notes
Customers_pkey
customer_id
customer_id
Name
Blog Posts_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Blog Posts
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Blog Posts_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Blog Posts
Sub Accounts_pkey
user_id
user_id
Name
Post Categories_post_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Blog Posts
Column in Post Categories
Blog Posts_pkey
post_id
post_id
Name
Post Categories_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Post Categories
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Tags_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Tags
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Post Tags_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Post Tags
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Post Tags_post_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Blog Posts
Column in Post Tags
Blog Posts_pkey
post_id
post_id
Name
Post Tags_tag_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Tags
Column in Post Tags
Tags_pkey
tags_id
tag_id
Name
Photos_post_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Blog Posts
Column in Photos
Blog Posts_pkey
post_id
post_id
Name
Documents_post_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Blog Posts
Column in Documents
Blog Posts_pkey
post_id
post_id
Name
Customers_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Customers
Sub Accounts_pkey
user_id
user_id
Name
Services***_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Services***
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Purchase Order Line Items_service_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Services***
Column in Purchase Order Line Items
Services***_pkey
service_id
service_id
Name
Chart of Accounts_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Chart of Accounts
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Journal Entries Line Items_journal_entry_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Journal Entries
Column in Journal Entries Line Items
Journal Entries_pkey
journal_entry_id
journal_entry_id
Name
Journal Entries Line Items_account_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Chart of Accounts
Column in Journal Entries Line Items
Chart of Accounts_pkey
chart_of_accounts_id
account_id
Name
Product Receipts***_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Product Receipts***
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Orders_last_modified_by_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Orders
Sub Accounts_pkey
user_id
last_modified_by
Name
Product_chart_of_accounts_type_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Chart of Accounts
Column in Product
Chart of Accounts_pkey
chart_of_accounts_id
chart_of_accounts_type
Name
Services***_chart_of_accounts_type_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Chart of Accounts
Column in Services***
Chart of Accounts_pkey
chart_of_accounts_id
chart_of_accounts_type
Name
Vendor Contacts_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Vendor Contacts
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Inventory***_last_updated_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Inventory***
Sub Accounts_pkey
user_id
last_updated_user_id
Name
Chart of Accounts_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Chart of Accounts
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Vendors**_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Vendors**
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Services***_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Services***
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Purchase Order Details_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Purchase Order Details
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Product_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Product
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Product_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Product
Sub Accounts_pkey
user_id
created_by_user_id
Name
Purchase Order Details_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Purchase Order Details
Sub Accounts_pkey
user_id
created_by_user_id
Name
Services***_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Services***
Sub Accounts_pkey
user_id
created_by_user_id
Name
Vendors**_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Vendors**
Sub Accounts_pkey
user_id
created_by_user_id
Name
Vendor Contacts_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Vendor Contacts
Sub Accounts_pkey
user_id
created_by_user_id
Name
Chart of Accounts_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Chart of Accounts
Sub Accounts_pkey
user_id
created_by_user_id
Name
Inventory***_received_in_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Inventory***
Sub Accounts_pkey
user_id
received_in_by_user_id
Name
Product Receipts***_received_in_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Product Receipts***
Sub Accounts_pkey
user_id
received_in_by_user_id
Name
Product Receipts***_last_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Product Receipts***
Sub Accounts_pkey
user_id
last_modified_by_user_id
Name
Reminders_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Reminders
Sub Accounts_pkey
user_id
user_id
Name
Emails Replies_email_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Emails
Column in Emails Replies
Emails_pkey
email_id
email_id
Name
Emails_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Emails
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Emails Replies_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Emails Replies
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Emails_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Emails
Sub Accounts_pkey
user_id
user_id
Name
Emails Replies_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Emails Replies
Sub Accounts_pkey
user_id
user_id
Name
Email Accounts_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Email Accounts
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Email Accounts_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Email Accounts
Sub Accounts_key1
external_id
user_id
Name
Custom Order Instructions_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Custom Order Instructions
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Custom Order Instructions_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Custom Order Instructions
Sub Accounts_pkey
user_id
user_id
Name
Custom Order Instructions_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in Custom Order Instructions
Customers_pkey
customer_id
customer_id
Name
Custom Order Instructions_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in Custom Order Instructions
Warehouse_pkey
warehouse_id
warehouse_id
Name
Action Logs_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Action Logs
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Action Logs_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Action Logs
Sub Accounts_pkey
user_id
user_id
Name
files**** replicate other document tab_web_app_customer_id_fkey
Key and columns
Key name
Column in Web_App_Customer
Column in files**** replicate other document table
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
files**** replicate other document table_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in files**** replicate other document table
Sub Accounts_pkey
user_id
user_id
Name
Shared Inventory Details_inventory_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in Shared Inventory Details
Inventory***_pkey
inventory_id
inventory_id
Name
Shared Inventory Details_shared_inventory_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Shared Inventory****
Column in Shared Inventory Details
Shared Inventory****_pkey
shared_intentory_id
shared_inventory_id
Name
Data Processing Audit_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Data Processing Audit
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Data Deletion Logs_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Data Deletion Logs
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Data Processing Audit_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Data Processing Audit
Sub Accounts_pkey
user_id
user_id
Name
Data Deletion Logs_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Data Deletion Logs
Sub Accounts_pkey
user_id
user_id
Name
User Consents_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in User Consents
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
User Consents_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in User Consents
Sub Accounts_pkey
user_id
user_id
Name
Session_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Session
Sub Accounts_pkey
user_id
user_id
Name
Session_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Session
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Purchase Order Line Items_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Purchase Order Line Items
Vendors**_pkey
vendor_id
vendor_id
Name
Purchase Order Vendors_purchase_order_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Purchase Order Details
Column in Purchase Order Vendors
Purchase Order Details_pkey
purchase_order_id
purchase_order_id
Name
Purchase Order Vendors_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Purchase Order Vendors
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Purchase Order Vendors_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Purchase Order Vendors
Vendors**_pkey
vendor_id
vendor_id
Name
Inventory Revision Log_change_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Inventory Revision Log
Sub Accounts_pkey
user_id
change_by_user_id
Name
Inventory Revision Log_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Inventory Revision Log
Product_pkey
product_id
product_id
Name
Inventory Revision Log_inventory_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in Inventory Revision Log
Inventory***_pkey
inventory_id
inventory_id
Name
Transfer Log_transferred_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Transfer Log
Sub Accounts_pkey
user_id
transferred_by_user_id
Name
Transfer Log_web_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Transfer Log
Web_App_Customer_pkey
web_app_customer_id
web_customer_id
Name
Transfer Log_from_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in Transfer Log
Warehouse_pkey
warehouse_id
from_warehouse_id
Name
Transfer Log_to_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in Transfer Log
Warehouse_pkey
warehouse_id
to_warehouse_id
Name
Inventory Revision Log_web_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Inventory Revision Log
Web_App_Customer_pkey
web_app_customer_id
web_customer_id
Name
Transfer Log_inventory_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in Transfer Log
Inventory***_pkey
inventory_id
inventory_id
Name
Transfer Log_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Transfer Log
Product_pkey
product_id
product_id
Name
Journal Entries_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Journal Entries
Sub Accounts_pkey
user_id
created_by_user_id
Name
Journal Entries_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Journal Entries
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Journal Entries_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Journal Entries
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Journal Entries Line Items_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Journal Entries Line Items
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
order_transactions_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in order_transactions
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
order_transactions_performed_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in order_transactions
Sub Accounts_pkey
user_id
performed_by_user_id
Name
order_transactions_order_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Orders
Column in order_transactions
customers_uuid
order_id
order_id
Name
Customer Products Pricelist_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Customer Products Pricelist
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Customer Products Pricelist_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Customer Products Pricelist
Sub Accounts_pkey
user_id
user_id
Name
Customer Products Pricelist_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in Customer Products Pricelist
Customers_pkey
customer_id
customer_id
Name
Pricelist Details_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Pricelist Details
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Pricelist Details_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Pricelist Details
Sub Accounts_pkey
user_id
user_id
Name
Pricelist Details_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in Pricelist Details
Customers_pkey
customer_id
customer_id
Name
Pricelist Details_pricelist_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customer Products Pricelist
Column in Pricelist Details
Customer Products Pricelist_pkey
pricelist_id
pricelist_id
Name
Product Tariffs_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Product Tariffs
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Product Tariffs_country_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Country
Column in Product Tariffs
Country_pkey
country_id
country_id
Name
Purchase Order Details_destination_country_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Country
Column in Purchase Order Details
Country_pkey
country_id
destination_country
Name
Documents_product_document_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Documents
Product***_key5
product_document_id
product_document_id
Name
Photos_company_photo_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Photos
Product***_key3
product_photo_id
company_photo_id
Name
Product Tariffs_created_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Product Tariffs
Sub Accounts_pkey
user_id
created_user_id
Name
Product Tariffs_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Product Tariffs
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Documents_uploaded_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Documents
Sub Accounts_pkey
user_id
uploaded_by_user_id
Name
Documents_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Documents
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Product Tariffs_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Product Tariffs
Product_pkey
product_id
product_id
Name
Product Tariffs_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Product Tariffs
Vendors**_pkey
vendor_id
vendor_id
Name
Purchase Order Tariffs_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Purchase Order Tariffs
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Purchase Order Tariffs_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Purchase Order Tariffs
Product_pkey
product_id
product_id
Name
Purchase Order Tariffs_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Purchase Order Tariffs
Vendors**_pkey
vendor_id
vendor_id
Name
Purchase Order Tariffs_purchase_order_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Purchase Order Details
Column in Purchase Order Tariffs
Purchase Order Details_pkey
purchase_order_id
purchase_order_id
Name
demand_tags_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in demand_tags
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
demand_tags_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in demand_tags
Sub Accounts_pkey
user_id
created_by_user_id
Name
demand_tags_updated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in demand_tags
Sub Accounts_pkey
user_id
updated_by_user_id
Name
Customer Products Pricelist_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Customer Products Pricelist
Product_pkey
product_id
product_id
Name
Customer Products Pricelist_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in Customer Products Pricelist
Warehouse_pkey
warehouse_id
warehouse_id
Name
Warehouse Product Prices_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Warehouse Product Prices
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Warehouse Product Prices_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Warehouse Product Prices
Product_pkey
product_id
product_id
Name
Warehouse Product Prices_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in Warehouse Product Prices
Warehouse_pkey
warehouse_id
warehouse_id
Name
Customers_default_shipping_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Customers
Vendors**_pkey
vendor_id
default_shipping_vendor_id
Name
Product_selling_season_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product Selling Season
Column in Product
Product Selling Season_pkey
selling_season_id
selling_season
Name
Product Selling Season_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Product Selling Season
Product_pkey
product_id
product_id
Name
Bill_by** (aka "Sell By")_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Bill_by** (aka "Sell By")
Product_pkey
product_id
product_id
Name
Product UOM_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Product UOM
Product_pkey
product_id
product_id
Name
Product UOM_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Product UOM
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Product Selling Season_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Product Selling Season
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Product Harvest Season_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Product Harvest Season
Product_pkey
product_id
product_id
Name
Photos_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Photos
Product_pkey
product_id
product_id
Name
Documents_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Documents
Product_pkey
product_id
product_id
Name
Photo Types_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Photo Types
Product_pkey
product_id
product_id
Name
Bill_by** (aka "Sell By")_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Bill_by** (aka "Sell By")
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Weather Conditions_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Weather Conditions
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Product Weather Suitability_weather_condition_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Weather Conditions
Column in Product Weather Suitability
Weather Conditions_pkey
weather_conditions_id
weather_condition_id
Name
Product Weather Suitability_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Product Weather Suitability
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Product Weather Suitability_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Product Weather Suitability
Product_pkey
product_id
product_id
Name
Region Weather Alerts_region_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Regions
Column in Region Weather Alerts
Regions_pkey
regions_id
region_id
Name
Region Weather Alerts_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in Region Weather Alerts
Product_pkey
product_id
product_id
Name
Regions_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Regions
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Region Weather Alerts_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Region Weather Alerts
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Region Weather Alerts_weather_condition_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Weather Conditions
Column in Region Weather Alerts
Weather Conditions_pkey
weather_conditions_id
weather_condition_id
Name
Photos_uploaded_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Photos
Sub Accounts_pkey
user_id
uploaded_by_user_id
Name
Photos_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Photos
Sub Accounts_pkey
user_id
last_modified_user_id
Name
Vendor Contacts_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Vendor Contacts
Vendors**_pkey
vendor_id
vendor_id
Name
Vendor_vendor_types_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Vendor_vendor_types
Vendors**_pkey
vendor_id
vendor_id
Name
Vendor_type_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Vendor_type
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Vendor_vendor_types_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Vendor_vendor_types
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Vendor_vendor_types_vendor_type_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendor_type
Column in Vendor_vendor_types
Vendor_type_pkey
vendor_type_id
vendor_type_id
Name
Web_App_Customer_language_code_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Languages
Column in Web_App_Customer
Languages_pkey1
languages_code
language_code
Name
admin_translations_language_code_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Languages
Column in admin_translations
Languages_pkey1
languages_code
language_code
Name
product_translations_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in product_translations
Product_pkey
product_id
product_id
Name
product_translations_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in product_translations
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
product_translations_language_code_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Languages
Column in product_translations
Languages_pkey1
languages_code
language_code
Name
Customer Contacts_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in Customer Contacts
Customers_pkey
customer_id
customer_id
Name
Payment Terms_web_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Payment Terms
Web_App_Customer_pkey
web_app_customer_id
web_customer_id
Name
Warehouse Contacts_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Warehouse Contacts
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Warehouse Contacts_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in Warehouse Contacts
Warehouse_pkey
warehouse_id
warehouse_id
Name
sellable_audit_log_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in sellable_audit_log
Customers_pkey
customer_id
customer_id
Name
sellable_audit_log_changed_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in sellable_audit_log
Sub Accounts_pkey
user_id
changed_by_user_id
Name
Shared Inventory Access_shared_with_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Shared Inventory Access
Web_App_Customer_pkey
web_app_customer_id
shared_with_web_app_customer_id
Name
Customer Addresses_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Customer Addresses
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Customer Addresses_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in Customer Addresses
Customers_pkey
customer_id
customer_id
Name
Customer_Type_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Customer_Type
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Customers_customer_type_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customer_Type
Column in Customers
Customer_Type_pkey
customer_type_id
customer_type
Name
Shared Inventory Details_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in Shared Inventory Details
Warehouse_pkey
warehouse_id
warehouse_id
Name
Shared Inventory Access_shared_inventory_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Shared Inventory****
Column in Shared Inventory Access
Shared Inventory****_pkey
shared_intentory_id
shared_inventory_id
Name
Categories_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Categories
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
Post Categories_category_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Categories
Column in Post Categories
Categories_pkey
category_id
category_id
Name
Warehouse_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in Warehouse
Vendors**_pkey
vendor_id
vendor_id
Name
web_app_customer_document_tags_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in web_app_customer_document_tags
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
web_app_customer_documents_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in web_app_customer_documents
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
web_app_customer_document_tag_web_app_customer_document_id_fkey
Key and columns
Key name
Column in web_app_customer_documents
Column in web_app_customer_document_tags
web_app_customer_documents_web_app_customer_document_id_key
web_app_customer_document_id
web_app_customer_document_id
Name
web_app_customer_documents_uploaded_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in web_app_customer_documents
Sub Accounts_pkey
user_id
uploaded_by_user_id
Name
web_app_customer_documents_last_modified_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in web_app_customer_documents
Sub Accounts_pkey
user_id
last_modified_user_id
Name
invoices_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in invoices
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
invoices_order_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Orders
Column in invoices
customers_uuid
order_id
order_id
Name
invoice_customer_sequences_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in invoice_customer_sequences
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
inventory_adjustments_adjusted_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in inventory_adjustments
Sub Accounts_pkey
user_id
adjusted_by_user_id
Name
inventory_adjustments_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in inventory_adjustments
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
inventory_adjustments_inventory_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in inventory_adjustments
Inventory***_pkey
inventory_id
inventory_id
Name
invoice_line_items_inventory_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in invoice_line_items
Inventory***_pkey
inventory_id
inventory_product_id
Name
invoice_line_items_inventory_lot_number_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in invoice_line_items
Inventory***_key
lot_number
inventory_lot_number
Name
invoice_line_items_web_app_customer_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in invoice_line_items
Web_App_Customer_pkey
web_app_customer_id
web_app_customer
Name
invoice_line_items_order_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Orders
Column in invoice_line_items
customers_uuid
order_id
order_id
Name
invoice_line_items_invoice_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in invoices
Column in invoice_line_items
invoices_pkey
invoice_id
invoice_id
Name
invoices_trucker_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in invoices
Vendors**_pkey
vendor_id
trucker_id
Name
invoices_salesman_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in invoices
Sub Accounts_pkey
user_id
salesman
Name
invoices_voided_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in invoices
Sub Accounts_pkey
user_id
voided_by_user_id
Name
invoices_last_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in invoices
Sub Accounts_pkey
user_id
last_modified_by_user_id
Name
order_customer_sequences_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in order_customer_sequences
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
order_approvals_order_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Orders
Column in order_approvals
customers_uuid
order_id
order_id
Name
order_approvals_approved_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in order_approvals
Sub Accounts_pkey
user_id
approved_by_user_id
Name
customer_po_user_tags_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in customer_po_user_tags
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
customer_po_sequences_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in customer_po_sequences
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
customer_po_user_tags_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in customer_po_user_tags
Sub Accounts_pkey
user_id
user_id
Name
customer_po_order_type_tags_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in customer_po_order_type_tags
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
order_customer_sequences_warehouse_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Warehouse
Column in order_customer_sequences
Warehouse_pkey
warehouse_id
warehouse_id
Name
Chart of Accounts_account_category_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Account Categories
Column in Chart of Accounts
Account Categories_pkey
category_id
account_category_id
Name
Account Categories_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Account Categories
Sub Accounts_pkey
user_id
created_by_user_id
Name
Account Categories_last_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Account Categories
Sub Accounts_pkey
user_id
last_modified_by_user_id
Name
Account Categories_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Account Categories
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Purchase Order Details_payment_term_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendor Payment Terms
Column in Purchase Order Details
Customer Payment Terms_pkey
payment_term_id
payment_term_id
Name
Vendor Payment Terms_web_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Vendor Payment Terms
Web_App_Customer_pkey
web_app_customer_id
web_customer_id
Name
Vendor Payment Terms_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Vendor Payment Terms
Sub Accounts_pkey
user_id
created_by_user_id
Name
Vendor Payment Terms_updated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Vendor Payment Terms
Sub Accounts_pkey
user_id
updated_by_user_id
Name
Currencies_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in Currencies
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
customer_accounting_mappings_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in customer_accounting_mappings
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
company_ledgers_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in company_ledgers
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
Currencies_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Currencies
Sub Accounts_pkey
user_id
created_by_user_id
Name
Currencies_updated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Currencies
Sub Accounts_pkey
user_id
updated_by_user_id
Name
company_ledgers_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in company_ledgers
Sub Accounts_pkey
user_id
created_by_user_id
Name
company_ledgers_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in company_ledgers
Sub Accounts_pkey
user_id
modified_by_user_id
Name
customer_accounting_mappings_company_ledger_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in company_ledgers
Column in customer_accounting_mappings
company_ledgers_pkey
company_ledger_id
company_ledger_id
Name
tax_rates_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in tax_rates
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
invoices_created_automatically_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in invoices
Sub Accounts_pkey
user_id
created_automatically_by_user_id
Name
Payment Terms_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Payment Terms
Sub Accounts_pkey
user_id
created_by_user_id
Name
Payment Terms_updated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Payment Terms
Sub Accounts_pkey
user_id
updated_by_user_id
Name
Orders_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Orders
Sub Accounts_pkey
user_id
created_by_user_id
Name
Warehouse_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Warehouse
Sub Accounts_pkey
user_id
created_by_user_id
Name
Warehouse_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Warehouse
Sub Accounts_pkey
user_id
modified_by_user_id
Name
tax_rates_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in tax_rates
Sub Accounts_pkey
user_id
created_by_user_id
Name
tax_rates_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in tax_rates
Sub Accounts_pkey
user_id
modified_by_user_id
Name
tax_rates_zones_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in tax_rates_zones
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
tax_rates_zones_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in tax_rates_zones
Sub Accounts_pkey
user_id
created_by_user_id
Name
tax_rates_zones_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in tax_rates_zones
Sub Accounts_pkey
user_id
modified_by_user_id
Name
tax_rate_zone_regions_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in tax_rate_zone_regions
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
tax_rate_zone_regions_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in tax_rate_zone_regions
Sub Accounts_pkey
user_id
created_by_user_id
Name
tax_rate_zone_regions_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in tax_rate_zone_regions
Sub Accounts_pkey
user_id
modified_by_user_id
Name
tax_rate_zone_regions_tax_rate_zone_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in tax_rates_zones
Column in tax_rate_zone_regions
tax_rates_pkey
tax_rate_zone_id
tax_rate_zone_id
Name
product_tax_exemptions_ceated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in product_tax_exemptions
Sub Accounts_pkey
user_id
ceated_by_user_id
Name
product_tax_exemptions_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in product_tax_exemptions
Sub Accounts_pkey
user_id
modified_by_user_id
Name
product_tax_exemptions_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in product_tax_exemptions
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
product_tax_exemptions_product_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Product
Column in product_tax_exemptions
Product_pkey
product_id
product_id
Name
customer_tax_exemptions_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Customers
Column in customer_tax_exemptions
Customers_pkey
customer_id
customer_id
Name
Orders_payment_terms_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Payment Terms
Column in Orders
Customer Payment Terms_pkey
payment_term_id
payment_terms_id
Name
Vendors**_payment_terms_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Payment Terms
Column in Vendors**
Customer Payment Terms_pkey
payment_term_id
payment_terms_id
Name
Vendors**_default_ship_terms_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Ship_terms
Column in Vendors**
Ship_terms_pkey
ship_terms_id
default_ship_terms_id
Name
Customers_default_ship_terms_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Ship_terms
Column in Customers
Ship_terms_pkey
ship_terms_id
default_ship_terms_id
Name
order_transactions_order_line_item_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Order Line Items
Column in order_transactions
Order Line Items_pkey
order_item_id
order_line_item_id
Name
order_transactions_inventory_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Inventory***
Column in order_transactions
Inventory***_pkey
inventory_id
inventory_id
Name
order_transactions_inventory_adjustments_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in inventory_adjustments
Column in order_transactions
inventory_adjustments_pkey
inventory_adjustments_id
inventory_adjustments_id
Name
bills_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in bills
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
bills_vendor_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Vendors**
Column in bills
Vendors**_pkey
vendor_id
vendor_id
Name
bills_currency_id****???_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Currencies
Column in bills
Currencies_pkey
currency_id
currency_id****???
Name
bills_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in bills
Sub Accounts_pkey
user_id
created_by_user_id
Name
bills_updated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in bills
Sub Accounts_pkey
user_id
updated_by_user_id
Name
bill_line_items_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in bill_line_items
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
bill_line_items_bill_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in bills
Column in bill_line_items
bills_pkey
bill_id
bill_id
Name
bill_line_items_chart of accounts_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Chart of Accounts
Column in bill_line_items
Chart of Accounts_pkey
chart_of_accounts_id
chart of accounts_id
Name
payments_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in payments
Sub Accounts_pkey
user_id
created_by_user_id
Name
payments_last_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in payments
Sub Accounts_pkey
user_id
last_modified_by_user_id
Name
payments_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in payments
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
payment_applications_payment_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in payments
Column in payment_applications
payments_pkey
payment_id
payment_id
Name
payment_applications_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in payment_applications
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
payment_methods_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in payment_methods
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
payments_payment_method_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in payment_methods
Column in payments
payment_methods_pkey
payment_method_id
payment_method_id
Name
payment_methods_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in payment_methods
Sub Accounts_pkey
user_id
created_by_user_id
Name
payment_methods_updated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in payment_methods
Sub Accounts_pkey
user_id
updated_by_user_id
Name
Journal Entries_accounting_period_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in account_periods
Column in Journal Entries
account_periods_pkey
accounting_period_id
accounting_period_id
Name
account_periods_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in account_periods
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
account_periods_locked_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in account_periods
Sub Accounts_pkey
user_id
locked_by_user_id
Name
Journal Entries Line Items_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Journal Entries Line Items
Sub Accounts_pkey
user_id
created_by_user_id
Name
Journal Entries Line Items_last_modified_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in Journal Entries Line Items
Sub Accounts_pkey
user_id
last_modified_by_user_id
Name
bank_accounts_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in bank_accounts
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
bank_accounts_currency_code*****???_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Currencies
Column in bank_accounts
Currencies_currency_code_key
currency_code
currency_code*****???
Name
payment_methods_currency_code***???_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Currencies
Column in payment_methods
Currencies_currency_code_key
currency_code
currency_code***???
Name
payments_currency_code***_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Currencies
Column in payments
Currencies_currency_code_key
currency_code
currency_code***
Name
bank_accounts_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in bank_accounts
Sub Accounts_pkey
user_id
created_by_user_id
Name
bank_accounts_updated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in bank_accounts
Sub Accounts_pkey
user_id
updated_by_user_id
Name
bank_transactions_bank_account_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in bank_accounts
Column in bank_transactions
bank_accounts_pkey
bank_account_id
bank_account_id
Name
bank_transactions_currency_code_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Currencies
Column in bank_transactions
Currencies_currency_code_key
currency_code
currency_code
Name
bank_transactions_reconciled_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in bank_transactions
Sub Accounts_pkey
user_id
reconciled_by_user_id
Name
bank_transactions_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in bank_transactions
Sub Accounts_pkey
user_id
created_by_user_id
Name
bank_transactions_updated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in bank_transactions
Sub Accounts_pkey
user_id
updated_by_user_id
Name
bank_transactions_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in bank_transactions
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
bank_transactions_bank_reconciliation_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in bank_reconciliations
Column in bank_transactions
bank_reconciliations_pkey
bank_reconciliation_id
bank_reconciliation_id
Name
reconciliation_anomalies_bank_reconciliation_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in bank_reconciliations
Column in reconciliation_anomalies
bank_reconciliations_pkey
bank_reconciliation_id
bank_reconciliation_id
Name
bank_reconciliations_updated_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in bank_reconciliations
Sub Accounts_pkey
user_id
updated_by_user_id
Name
bank_reconciliations_created_by_user_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Sub Accounts
Column in bank_reconciliations
Sub Accounts_pkey
user_id
created_by_user_id
Name
bank_reconciliations_bank_account_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in bank_accounts
Column in bank_reconciliations
bank_accounts_pkey
bank_account_id
bank_account_id
Name
bank_reconciliations_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in bank_reconciliations
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
reconciliation_anomalies_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in reconciliation_anomalies
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Name
alert_events_anomaly_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in reconciliation_anomalies
Column in alert_events
reconciliation_anomalies_pkey
anomaly_id
anomaly_id
Name
reconciliation_lines_bank_reconciliation_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in bank_reconciliations
Column in reconciliation_lines
bank_reconciliations_pkey
bank_reconciliation_id
bank_reconciliation_id
Name
reconciliation_lines_web_app_customer_id_fkey
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in Web_App_Customer
Column in reconciliation_lines
Web_App_Customer_pkey
web_app_customer_id
web_app_customer_id
Other objects
Name
Last 30 Days Orders
Type
MaterializedView
Description
This is for querying orders done in the last 30 days so it is quickly pulled up. SELECT * FROM orders_last_30_days WHERE customer_id = '12345'; Here is a revised script to look at and revise currnt scrip to it: CREATE MATERIALIZED VIEW fast_orders AS SELECT id, status, web_app_customer_id, created_at FROM orders WHERE created_at > NOW() - INTERVAL '30 days';
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Last 90 Days Orders
Type
MaterializedView
Description
This is for querying orders done in the last 90 days so it is quickly pulled up. SELECT * FROM orders_last_30_days WHERE customer_id = '12345';
Code
CREATE MATERIALIZED VIEW orders_last_90_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '90 days';
Name
Last 60 Days Orders
Type
MaterializedView
Description
This is for querying orders done in the last 60 days so it is quickly pulled up. SELECT * FROM orders_last_30_days WHERE customer_id = '12345';
Code
CREATE MATERIALIZED VIEW orders_last_60_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '60 days';
Name
Top Customers
Type
MaterializedView
Description
Need to figure out the script, but this is for knowing who our top custoemrs are for each web apop customer, Maybe sort of like a Top 10
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Top Products
Type
MaterializedView
Description
Need to figure out the script, but this is for knowing what our top products are that we sell ad a company. it grabs it from Orders because that's where we sell. Maybe sort of like a Top 10
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Top Truckers
Type
MaterializedView
Description
Need to figure out the script, but this is for knowing who our top Trucking companies are. Maybe a top 10 or top 5. These are our Go To's. It is dependent on how many POs we cut to a specific vendor based off the Chart of Accounts (transportation services). I think it should be based off the last 12 months. Maybe it should show their "deemed" location that they service. Sort of like a Quick View and maybe have it posted to see who to use, but also allow you to click it and add them to the Trucking PO if you so choose that. It will also display contact details. A kicker is to have the previous trucker that was on the last order be listed on top or in a section that says "Previous Trucker."
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Top 5 Vendors
Type
MaterializedView
Description
Need to figure out the script, but this is for knowing who our top vendors that we order from. These are our Go To's. It is dependent on how many POs we cut to a specific vendor based off the Chart of Accounts (cost of goods sold). I think it should be based off the last 12 months.
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Inventory Turnover
Type
MaterializedView
Description
Need to figure out the script, but this is helping us see how long it takes for product to come in and then sell out. It will gather info over the last 12 months It will be based off product being received in on a purchase order at a specific date & then orders against that product in the specific lot & till the remaining quantity is 0 and it grabs that date & then
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Weekly Moving
Type
MaterializedView
Description
Need to figure out the script, but this is helping us see what our weekly movement is for our products. It would take what we had sold for our products the last 7 days for a specific lot.
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Average Monthly Moving
Type
MaterializedView
Description
Need to figure out the script, but this is helping us see what our monthly movement is for our products. It would take what we had sold for our products the last 30 days for a specific lot. Example Script (need to refine): CREATE MATERIALIZED VIEW monthly_product_sales AS SELECT product_id, SUM(quantity) AS total_monthly_sold FROM order_items WHERE web_app_customer_id = app.current_customer order_date >= date_trunc('month', CURRENT_DATE) AND order_date < date_trunc('month', CURRENT_DATE + interval '1 month') GROUP BY product_id; REFRESH MATERIALIZED VIEW monthly_product_sales;
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Average 3-Monthly Moving
Type
MaterializedView
Description
Need to figure out the script, but this is helping us see what our monthly movement is for our products. It would take what we had sold for our products the last 90 days for a specific lot.
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Average 6-Monthly Moving
Type
MaterializedView
Description
Need to figure out the script, but this is helping us see what our monthly movement is for our products. It would take what we had sold for our products the last 180 days for a specific lot.
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Average 12-Monthly Moving
Type
MaterializedView
Description
Need to figure out the script, but this is helping us see what our monthly movement is for our products. It would take what we had sold for our products the last 360 days for a specific lot.
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Average Weekly Usage
Type
MaterializedView
Description
Need to figure out the script, but this is helping us see what our weekly usage is for a product. This takes the monthly materialized view and divides the number by 4 (weeks) to determine the average usage for the product each week. Example Script (need to refine): CREATE MATERIALIZED VIEW weekly_avg_product_sales AS SELECT product_id, ROUND(total_monthly_sold / 4.0, 2) AS weekly_avg_sold WHERE web_app_customer_id = app.current_customer FROM monthly_product_sales; REFRESH MATERIALIZED VIEW weekly_avg_product_sales;
Code
CREATE MATERIALIZED VIEW orders_last_30_days AS
SELECT * FROM orders
WHERE order_sent_on >= CURRENT_DATE - INTERVAL '30 days';

Name
Inventory_recomputed_quantity
Type
MaterializedView
Description
This constantly recalculates the inventory based off transactions of orders in order_transactions. It's best to have multiple ways to compute inventory because you don't want errors... REFRESH MATERIALIZED VIEW CONCURRENTLY inventory_recomputed_quantity;
Code
SELECT
  inventory_id,
  SUM(quantity_change) AS calculated_quantity
FROM order_transactions
GROUP BY inventory_id;
Name
Reconcilation Report
Type
View
Description
This is for Inventory
Code
SELECT
  i.inventory_id,
  i.available_product_quantity AS stored_quantity,
  v.calculated_quantity,
  (i.available_product_quantity - v.calculated_quantity) AS discrepancy
FROM "Inventory***" i
JOIN inventory_recomputed_quantity v ON i.inventory_id = v.inventory_id
WHERE ABS(i.available_product_quantity - v.calculated_quantity) > 0.01;
Name
Automated Reconciliation Job
Type
Function
Description
This is an example of a function
Code
CREATE OR REPLACE FUNCTION reconcile_inventory_quantities()
RETURNS void AS $$
BEGIN
  UPDATE "inventory" i
  SET available_product_quantity = v.calculated_quantity
  FROM inventory_recomputed_quantity v
  WHERE i.inventory_id = v.inventory_id
    AND i.available_product_quantity != v.calculated_quantity;
END;
$$ LANGUAGE plpgsql;
Name
Live Inventory
Type
View
Code
SELECT
  inventory_id,
  SUM(quantity_change) AS recalculated_quantity
FROM order_transactions
GROUP BY inventory_id;
Name
Automatically setting "accounting_period_id"
Type
Function
Code
CREATE OR REPLACE FUNCTION set_accounting_period() 
RETURNS TRIGGER AS $$
BEGIN
  SELECT period_id INTO NEW.accounting_period_id
  FROM accounting_periods
  WHERE 
    web_app_customer_id = NEW.web_app_customer_id AND
    NEW.transaction_date BETWEEN period_start_date AND period_end_date
    AND is_closed = false
  ORDER BY period_start_date DESC
  LIMIT 1;

  IF NEW.accounting_period_id IS NULL THEN
    RAISE EXCEPTION 'No open accounting period found for this transaction_date and tenant.';
  END IF;

  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER trg_set_accounting_period
BEFORE INSERT ON "Journal Entries"
FOR EACH ROW
EXECUTE FUNCTION set_accounting_period();
Name
journal_entry_balances
Type
View
Description
This view that automatically checks if each journal entry is balanced (i.e., total debits = total credits). This is a simple but powerful tool to validate your general ledger.
Code
CREATE VIEW journal_entry_balances AS
SELECT
  je.journal_entry_id,
  je.transaction_date,
  je.description,
  SUM(COALESCE(li.debit, 0)) AS total_debit,
  SUM(COALESCE(li.credit, 0)) AS total_credit,
  CASE 
    WHEN SUM(COALESCE(li.debit, 0)) = SUM(COALESCE(li.credit, 0)) THEN TRUE
    ELSE FALSE
  END AS is_balanced
FROM journal_entries je
JOIN journal_entry_line_items li ON li.journal_entry_id = je.journal_entry_id
GROUP BY je.journal_entry_id, je.transaction_date, je.description;
Name
validate_journal_entry_balance
Type
Function
Code
CREATE OR REPLACE FUNCTION validate_journal_entry_balance()
RETURNS TRIGGER AS $$
DECLARE
  total_debit NUMERIC(12, 2);
  total_credit NUMERIC(12, 2);
BEGIN
  SELECT 
    SUM(COALESCE(debit, 0)), 
    SUM(COALESCE(credit, 0))
  INTO 
    total_debit, 
    total_credit
  FROM journal_entry_line_items
  WHERE journal_entry_id = NEW.journal_entry_id;

  IF total_debit IS DISTINCT FROM total_credit THEN
    RAISE EXCEPTION 'Unbalanced journal entry: total debit (%.2f) ≠ total credit (%.2f)', total_debit, total_credit;
  END IF;

  RETURN NEW;
END;
$$ LANGUAGE plpgsql;
Name
check_journal_entry_balance
Type
Trigger
Code
CREATE TRIGGER check_journal_entry_balance
AFTER INSERT OR UPDATE
ON journal_entries
FOR EACH ROW
EXECUTE FUNCTION validate_journal_entry_balance();
Name
current_reconciliation_status
Type
View
Code
CREATE VIEW current_reconciliation_status AS
SELECT
  ba.bank_account_id,
  ba.account_name,
  MAX(br.statement_end_date) AS last_reconciled_date,
  SUM(CASE WHEN bt.is_reconciled = FALSE THEN bt.amount ELSE 0 END) AS unreconciled_total,
  COUNT(CASE WHEN bt.is_reconciled = FALSE THEN 1 ELSE NULL END) AS unreconciled_count
FROM bank_accounts ba
LEFT JOIN bank_transactions bt ON ba.bank_account_id = bt.bank_account_id
LEFT JOIN bank_reconciliations br ON bt.bank_reconciliation_id = br.bank_reconciliation_id
GROUP BY ba.bank_account_id, ba.account_name;
Name
is_reconciled
Type
Function
Code
CREATE OR REPLACE FUNCTION auto_set_is_reconciled()
RETURNS TRIGGER AS $$
BEGIN
  IF NEW.bank_reconciliation_id IS NOT NULL THEN
    NEW.is_reconciled := TRUE;
  ELSE
    NEW.is_reconciled := FALSE;
  END IF;
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER trg_auto_set_reconciled
BEFORE INSERT OR UPDATE ON bank_transactions
FOR EACH ROW
EXECUTE FUNCTION auto_set_is_reconciled();
Name
reconciliation_with_anomalies
Type
View
Code
CREATE VIEW reconciliation_with_anomalies AS
SELECT
  br.*,
  ra.anomaly_id,
  ra.detected_at,
  ra.new_difference
FROM bank_reconciliations br
LEFT JOIN reconciliation_anomalies ra
  ON br.bank_reconciliation_id = ra.bank_reconciliation_id
  AND ra.reported = FALSE;
Notes
Name
Text1
Note

*Add Primary Keys,

They don't need a relation to them to be one!

Name
Text2
Note

*Will need to revise PKs and FKs

Name
Text4
Note

How to do double-entry

for inventory???

Name
Text5
Note

Double Entry Accounting

Name
Text6
Note

Add external_id to all tables.

Replace UUID for customer_id with bigserial


This is known as the "Hybrid Approach"

Name
Text7
Note

*Reminders need to use TIMESTAMP

They are in "local time". No sense utilizing TIMESTAMPZ.

Name
Text8
Note

*Scheduling stuff would be in TIMESTAMP as well

They are in "local time". No sense utilizing TIMESTAMPZ.

Name
Text9
Note

**Pricelist Sending TIMESTAMPZ

They traverse multiple times.

Name
Text10
Note

**Sending emails in the web app use TIMESTAMP

Local time is what is needed

Name
Text11
Note

Pricelist Portion

Name
Text12
Note

Add: ^^^^^

user_id for any table; and for any table that has "last_modified" & "created_at" in it. This is used to track changes made by users and any potential for users to "self sabotage a company" and who maybe did an order.

Name
Text13
Note

*We will be going with 3 databases

Primary & Replica

We will route writes to PRIMARY and Reads to REPLICA.

This will further make it super fast!


REPLICA Copy so in case we have a failure of Primary, we move Replica1 to Primary and Replica2 to Replica and then Primary to Replica2 position.

Redundancy

Then backups to like RackSpace in case of an accidental erase!

Name
Text14
Note

Explore more options for JSONB

in this table & apply to others.

Name
Text15
Note

NEED TO ASK CHATGPT ON THESE TABLES FOR REFERENCING AND BIGSERIAL AND BIGINT!?

Name
Text3
Note

-->

Name
Text16
Note

-->

Name
Text17
Note

-->

Name
Text18
Note

-->

Name
Text19
Note

-->

Name
Text20
Note

-->

Name
Text110
Note

USER SERIAL OR BIGSERIAL ON THE OG TABLE AND THEN USE BIGINT ON THE TABLES WHERE IT IS REFERENCED.

any serial field auto-increments and this is an issue when it gets referenced in another table...

Name
Text111
Note

-->

Name
Text112
Note

-->

Name
Text113
Note

-->

Name
Text114
Note

-->

Name
Text115
Note

-->

Name
Text21
Note

Not following through on a comment system for blog posts. Don't want to give away customers.

Name
Text23
Note

What about chart of accounts for warehouses??

Name
Text22
Note

*Ask about whether to have NN for "created_by_user" columns?

Name
Text24
Note

Currencies referenced from another table.

Need more help! ChatGPT has it, but I don't get it!!