Skip to main content

Database Schema

Complete reference for the GSM Middleware database schema, including all tables, columns, indexes, and relationships.

Overview

GSM Middleware uses a dual database architecture:

  1. WordPress Database - Plugin settings and configurations
  2. Tasks Database (rm_* tables) - All sync data, orders, inventory, and sites

The tasks database can be on a different server and is managed via DB Environments, allowing easy switching between development, staging, and production databases.

Core Tables

rm_sites

Purpose: Site configurations, credentials, and sync toggles

Critical: Yes

ColumnTypeDescription
idINTAuto-increment primary key
prefixVARCHAR(10)Site prefix (unique identifier)
platformVARCHAR(20)Platform type ('bigcommerce' or 'woocommerce')
nameVARCHAR(100)Site display name
site_urlVARCHAR(255)Store URL
domainVARCHAR(50)Domain name
is_activeTINYINTActive status (0=disabled, 1=enabled)
stagingTINYINTStaging environment flag
weightVARCHAR(2)Weight unit ('lb' or 'kg')
checkout_domainVARCHAR(80)Checkout domain (if different)

Sync Toggles:

ColumnTypeDescription
inventory_syncTINYINTEnable inventory sync (default: 1)
orders_syncTINYINTEnable order sync (default: 1)
tracking_syncTINYINTEnable tracking sync (default: 1)
bazaarvoice_syncTINYINTEnable Bazaarvoice sync (default: 0)
kit_syncTINYINTEnable kit sync (default: 0)

API Credentials:

ColumnTypeDescription
bc_client_idTEXTBigCommerce client ID (OAuth)
bc_auth_tokenTEXTBigCommerce auth token (encrypted)
bc_store_hashVARCHAR(50)BigCommerce store hash
bc_channel_idVARCHAR(50)BigCommerce channel ID
wc_consumer_keyTEXTWooCommerce consumer key
wc_consumer_secretTEXTWooCommerce consumer secret
nmi_security_keyVARCHAR(100)NMI payment gateway key
kit_builder_api_keyVARCHAR(100)Kit builder API key

Health Check URLs:

ColumnTypeDescription
health_check_urlVARCHAR(255)Base health check URL
health_check_inventory_urlVARCHAR(255)Inventory health endpoint
orders_health_urlVARCHAR(500)Orders health endpoint
inventory_health_urlVARCHAR(500)Inventory health endpoint
tracking_health_urlVARCHAR(500)Tracking health endpoint
bazaarvoice_health_urlVARCHAR(500)Bazaarvoice health endpoint
kit_health_urlVARCHAR(500)Kit health endpoint

Tracking Settings:

ColumnTypeDescription
tracking_status_filtersVARCHAR(100)Status filters for tracking sync
tracking_auto_completeTINYINTAuto-complete orders on tracking
tracking_send_emailTINYINTSend email notification on tracking

Signifyd Integration:

ColumnTypeDescription
signifyd_enabledTINYINTEnable Signifyd fraud protection
signifyd_team_idVARCHAR(128)Signifyd team identifier
signifyd_api_keyTEXTSignifyd API key (encrypted)

Bazaarvoice Integration:

ColumnTypeDescription
bzv_nameVARCHAR(100)Bazaarvoice account name / Client ID
bzv_hostVARCHAR(255)Bazaarvoice SFTP host
bzv_userTEXTBazaarvoice SFTP username
bzv_passTEXTBazaarvoice SFTP password (encrypted)
bzv_urlVARCHAR(255)Bazaarvoice review display URL
bzv_brandVARCHAR(50)Brand identifier
bazaarvoice_syncTINYINTEnable Product Sync to SFTP (default: 0)

BazaarVoice Discovery API:

ColumnTypeDescription
bv_discovery_syncTINYINTEnable Authentic Discovery API sync
bv_discovery_environmentVARCHAR(20)Environment: staging or production
bv_discovery_api_keyTEXTProduction API key (encrypted)
bv_discovery_api_key_stagingTEXTStaging API key (encrypted)
bv_product_id_fieldVARCHAR(20)Product matching: prod_id, sku, or upc

BazaarVoice SFTP Feed:

ColumnTypeDescription
bv_sftp_syncTINYINTEnable SFTP Feed Review Import
bv_sftp_last_feed_dateDATEDate of last processed feed file
bv_sftp_last_processed_fileVARCHAR(255)Filename of last processed feed

BazaarVoice Metafield Sync:

ColumnTypeDescription
bv_metafield_syncTINYINTEnable pushing review JSON-LD to BC metafields
bv_schema_last_syncedDATETIMELast schema markup sync to BigCommerce

Webhook Configuration:

ColumnTypeDescription
webhook_secretVARCHAR(255)Webhook signature secret
webhook_idsTEXTJSON array of webhook IDs
webhook_statusENUMStatus: not_configured, active, error
webhook_last_receivedDATETIMELast webhook received timestamp

Sync Timestamps:

ColumnTypeDescription
order_last_runDATETIMELast order sync timestamp
inventory_last_runDATETIMELast inventory sync timestamp
shipping_last_runDATETIMELast shipping sync timestamp

Indexes:

  • PRIMARY KEY (id, prefix)
  • UNIQUE KEY Unique Prefix (prefix)
  • KEY idx_is_active (is_active)
  • KEY idx_platform (platform)

rm_order

Purpose: All orders from all sites

Critical: Yes

ColumnTypeDescription
idBIGINTAuto-increment primary key
siteINTSite ID (FK to rm_sites)
numberVARCHAR(20)Order number from platform
nav_sales_order_numberVARCHAR(20)NAV/BC sales order number
trans_idVARCHAR(150)Transaction/payment ID
shipping_agent_codeVARCHAR(30)Carrier code (e.g., 'FEDEX')
shipping_agent_serviceVARCHAR(80)Service level (e.g., 'GROUND')
dateaddedDATETIMEWhen added to system
dateDATETIMEOrder date from platform
contactidINTContact/customer ID
importedTINYINTImported to BC flag (0=no, 1=yes)
verifiedTINYINTVerified in BC flag (0=no, 1=yes)
ship_statusTINYINTShipped flag (0=not shipped, 1=shipped)

Payment Flags:

ColumnTypeDescription
klarnaTINYINTPaid via Klarna
stripeTINYINTPaid via Stripe
paypalTINYINTPaid via PayPal
credovaTINYINTPaid via Credova
sezzleTINYINTPaid via Sezzle
nmiTINYINTPaid via NMI gateway

Additional Flags:

ColumnTypeDescription
klarna_capturedTINYINTKlarna payment captured
mailing_listTINYINTCustomer opted into mailing list
full_syncedTINYINTFully synced to BC
fully_import_from_websiteTINYINTImport flag
narvar_exportedTINYINTExported to Narvar tracking
orders_expedited_emailTINYINTExpedited email sent
shipping_actual_costDOUBLEActual shipping cost
shipping_imported_to_glewTINYINTImported to Glew analytics
sent_to_paypalTINYINTSent to PayPal

Indexes:

  • PRIMARY KEY (id, site)
  • KEY site (site)
  • KEY rm_order_imported_IDX (imported, verified, fully_import_from_website)
  • KEY rm_order_number_IDX (number)
  • KEY idx_dateadded (dateadded DESC) - Performance index (Migration 011)
  • KEY idx_ship_status (ship_status) - Performance index (Migration 011)
  • KEY idx_site_dateadded (site, dateadded) — Composite index for analytics (Migration 020)

rm_lineitems

Purpose: Order line items (products in orders)

Critical: Yes

ColumnTypeDescription
idBIGINTAuto-increment primary key
orderBIGINTOrder ID (FK to rm_order)
lineINTLine number in order
itemINTItem/product ID (FK to rm_items)
qtyINTQuantity ordered
priceDECIMALUnit price
importedTINYINTImported to BC
verifiedTINYINTVerified in BC
nav_order_numberVARCHAR(20)NAV order reference

Indexes:

  • PRIMARY KEY (id)
  • KEY order (order)
  • KEY item (item)
  • KEY idx_item (item) — Performance index for Top Selling Products report (Migration 020)

rm_address

Purpose: Billing and shipping addresses for orders

Critical: Yes

ColumnTypeDescription
idBIGINTAuto-increment primary key
orderBIGINTOrder ID (FK to rm_order)
typeTINYINTAddress type (0=shipping, 1=billing)
firstnameVARCHAR(100)First name
lastnameVARCHAR(100)Last name
addressVARCHAR(255)Address line 1
address2VARCHAR(255)Address line 2
cityVARCHAR(100)City
stateVARCHAR(100)State/province
zipVARCHAR(20)ZIP/postal code
countryVARCHAR(2)Country code (ISO 2-letter)
phoneVARCHAR(20)Phone number
emailVARCHAR(255)Email address

Indexes:

  • PRIMARY KEY (id)
  • KEY order (order)
  • KEY idx_order_type (order, type) — Composite index for Geographic Sales report (Migration 020)

rm_items

Purpose: Product inventory data (quantities, metadata)

Critical: Yes

ColumnTypeDescription
idINTAuto-increment primary key
skuVARCHAR(100)Product SKU
siteINTSite ID (FK to rm_sites)
inventoryINTStock quantity
prod_idVARCHAR(50)Platform product ID
typeVARCHAR(20)Product type
activeTINYINTActive/published status
validTINYINTValidation status
priceDECIMALCurrent price
titleVARCHAR(255)Product title
navision_statusVARCHAR(50)BC sync status

BazaarVoice Aggregate Columns:

ColumnTypeDescription
bv_rating_valueDECIMAL(3,2)Average review rating
bv_review_countINTTotal review count
bv_last_syncedDATETIMELast BV sync timestamp

Indexes:

  • PRIMARY KEY (id)
  • KEY sku (sku)
  • KEY site (site)
  • KEY prod_id (prod_id)
  • KEY idx_sku (sku) — Performance index (Migration 020)

Queue & Webhook Tables

rm_queue

Purpose: Async job queue (order sync, inventory sync, dispute processing)

Critical: Yes

ColumnTypeDescription
idBIGINTAuto-increment primary key
job_typeVARCHAR(100)Job type identifier
payloadLONGTEXTJob data (JSON)
priorityTINYINTPriority (1=highest, 5=default, 10=lowest)
site_idINTSite ID (if applicable)
reference_idVARCHAR(255)Idempotency key (unique per entity)
statusVARCHAR(20)Status: pending, processing, completed, failed
attemptsINTNumber of attempts
error_messageTEXTLast error message
created_atDATETIMEWhen job was created
scheduled_atDATETIMEWhen job should run
started_atDATETIMEWhen processing started
completed_atDATETIMEWhen job completed
failed_atDATETIMEWhen job failed

Indexes:

  • PRIMARY KEY (id)
  • KEY idx_status_priority (status, priority, created_at)
  • KEY idx_job_type (job_type)
  • KEY idx_site_id (site_id)
  • KEY idx_scheduled (scheduled_at)
  • UNIQUE KEY idx_reference_id (reference_id)

rm_webhook_log

Purpose: Incoming product/inventory webhook log with signature validation

Critical: Yes

ColumnTypeDescription
idBIGINTAuto-increment primary key
site_idINTSite ID (FK to rm_sites)
event_typeVARCHAR(100)Event type (e.g., 'product.updated')
payload_hashVARCHAR(64)SHA-256 hash of payload
payloadLONGTEXTComplete webhook payload (JSON)
headersTEXTRequest headers (JSON)
signature_validTINYINTSignature validation result
statusVARCHAR(20)Status: queued, processing, completed, failed
attemptsINTProcessing attempts
error_messageTEXTLast error message
queue_job_idBIGINTFK to rm_queue (if queued)
received_atDATETIMEWhen webhook was received
processed_atDATETIMEWhen processing completed

Indexes:

  • PRIMARY KEY (id)
  • KEY idx_site_event (site_id, event_type)
  • KEY idx_status (status)
  • KEY idx_payload_hash (payload_hash)
  • KEY idx_received_at (received_at)
  • KEY idx_queue_job_id (queue_job_id)
  • FOREIGN KEY (queue_job_id) REFERENCES rm_queue(id) ON DELETE SET NULL

BazaarVoice Tables

rm_item_reviews

Purpose: Individual BazaarVoice review content with deduplication

Critical: No

ColumnTypeDescription
idINTAuto-increment primary key
item_idINTFK to rm_items
review_idVARCHAR(128)BazaarVoice review identifier
ratingTINYINTStar rating (1-5)
titleVARCHAR(500)Review title
review_textTEXTFull review content
reviewer_nameVARCHAR(255)Reviewer display name
submission_timeDATETIMEWhen review was submitted
hashVARCHAR(64)SHA-256 deduplication hash
sourceVARCHAR(32)Source: discovery_api or sftp_feed
created_atTIMESTAMPRow creation time

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY idx_hash (hash)
  • KEY idx_item_id (item_id)

rm_item_schema_markup

Purpose: Generated Schema.org JSON-LD review markup per product

Critical: No

ColumnTypeDescription
idINTAuto-increment primary key
item_idINTFK to rm_items
reviews_jsonldLONGTEXTIndividual reviews JSON-LD
aggregate_jsonldLONGTEXTAggregate rating JSON-LD
review_countINTNumber of reviews included
generated_atDATETIMELast generation timestamp
metafield_last_syncedDATETIMEWhen metafield was last pushed to BigCommerce
created_atTIMESTAMPRow creation time

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY idx_item_id (item_id)
  • KEY idx_generated_at (generated_at)
  • KEY idx_metafield_last_synced (metafield_last_synced)

Reporting & API Tables

rm_api_keys

Purpose: API keys for external order ingestion (Bearer token auth)

Critical: Yes

ColumnTypeDescription
idINTAuto-increment primary key
nameVARCHAR(100)Key name/label
key_hashVARCHAR(64)SHA-256 hash of API key
key_prefixVARCHAR(8)First 8 chars for identification
permissionsVARCHAR(50)Permission scope
is_activeTINYINTActive status
last_used_atDATETIMELast successful use
expires_atDATETIMEExpiration date (NULL = never)
created_atTIMESTAMPWhen key was created

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY idx_key_hash (key_hash)
  • KEY idx_is_active (is_active)

rm_report_configs

Purpose: Automated email report configurations and schedules

Critical: No

ColumnTypeDescription
idINTAuto-increment primary key
report_typeVARCHAR(50)Report identifier slug
nameVARCHAR(100)Report display name
scheduleVARCHAR(50)Cron expression for scheduling
recipientsTEXTComma-separated email addresses
is_activeTINYINTActive status
last_run_atDATETIMELast execution timestamp
created_atTIMESTAMPWhen config was created

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY idx_report_type (report_type)

rm_chargebacks

Purpose: Unified chargeback/dispute management records

Critical: Yes

ColumnTypeDescription
idBIGINTAuto-increment primary key
case_idVARCHAR(50)PayArc case identifier
midVARCHAR(50)Merchant ID
nmi_transaction_idVARCHAR(50)NMI transaction reference
order_numberVARCHAR(50)Matched middleware order number
amountDECIMAL(10,2)Dispute amount
reason_codeVARCHAR(20)Dispute reason code
reason_descTEXTDispute reason description
statusVARCHAR(50)Current dispute status
signifyd_responseLONGTEXTSignifyd API response (JSON)
payarc_responseLONGTEXTPayArc webhook data (JSON)
action_logLONGTEXTChronological action audit trail (JSON)
created_atTIMESTAMPRecord creation timestamp
updated_atTIMESTAMPLast update timestamp

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY idx_case_id (case_id)
  • KEY idx_order_number (order_number)
  • KEY idx_status (status)

Dispute Processing Tables

rm_payarc_dispute_linkages

Purpose: PayArc ↔ NMI transaction linkage audit trail

Critical: Yes

ColumnTypeDescription
idBIGINTAuto-increment primary key
case_idVARCHAR(50)PayArc case ID
case_numberVARCHAR(50)PayArc case number
midVARCHAR(50)Merchant ID
nmi_transaction_idVARCHAR(50)NMI transaction ID
nmi_order_idVARCHAR(50)NMI order ID
order_numberVARCHAR(50)Our order number
match_strategyVARCHAR(50)How match was found
amountDECIMALDispute amount
auth_codeVARCHAR(20)Authorization code
arnVARCHAR(50)Acquirer Reference Number
transaction_dateDATETransaction date
reason_codeVARCHAR(20)Dispute reason code
reason_descTEXTDispute reason description
dispute_statusVARCHAR(50)Current dispute status
payarc_dataLONGTEXTPayArc data (JSON)
nmi_dataLONGTEXTNMI data (JSON)
linked_atDATETIMEWhen linkage was created
created_atTIMESTAMPRecord creation timestamp

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY idx_case_id (case_id)
  • KEY idx_nmi_transaction (nmi_transaction_id)
  • KEY idx_order_number (order_number)

Supporting Tables

rm_carrier_mapping

Purpose: Carrier code mapping (BC → platform carrier codes)

Critical: No

ColumnTypeDescription
idINTAuto-increment primary key
platformVARCHAR(20)Platform ('bigcommerce' or 'woocommerce')
bc_carrier_codeVARCHAR(50)Business Central carrier code
platform_carrier_codeVARCHAR(50)Platform carrier code

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY idx_platform_mapping (platform, bc_carrier_code)

shipments

Purpose: Shipment tracking records from Business Central

Critical: No

ColumnTypeDescription
idBIGINTAuto-increment primary key
order_idBIGINTFK to rm_order
tracking_numberVARCHAR(100)Tracking number
shipping_providerVARCHAR(50)Carrier name
importedTINYINTImported to platform flag
dateDATETIMEShipment date

Indexes:

  • PRIMARY KEY (id)
  • KEY order_id (order_id)
  • KEY tracking_number (tracking_number)
  • KEY idx_order_id (order_id) — Performance index for Shipping Performance (Migration 020)
  • KEY idx_shipping_provider (shipping_provider) — GROUP BY carrier optimization (Migration 020)

rm_kits

Purpose: Kit product structure (parent SKU → component SKUs)

Critical: No

ColumnTypeDescription
parent_skuVARCHAR(100)Kit/bundle parent SKU
skuVARCHAR(100)Component product SKU
qtyINTQuantity of component in kit
site_idINTSite ID (FK to rm_sites)

Indexes:

  • KEY idx_parent_sku (parent_sku)
  • KEY idx_site_id (site_id)

rm_promotions

Purpose: BigCommerce promotion/bundle data

Critical: No

ColumnTypeDescription
idINTAuto-increment primary key
site_idINTSite ID (FK to rm_sites)
bc_promotion_idINTBigCommerce promotion ID
is_bundleTINYINTIs bundle promotion
buy_condition_dataTEXTBuy conditions (JSON)
get_action_dataTEXTGet actions (JSON)

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY idx_site_promotion (site_id, bc_promotion_id)

Schema Verification

The plugin includes a schema verifier that checks:

  • ✅ Table existence
  • ✅ Required columns
  • ✅ Performance indexes
  • ✅ Critical vs optional tables

Run verification:

  1. Go to DB Environments page
  2. Click "Verify Schema"
  3. Review results
  4. Click "Fix All" to apply migrations if issues found

See Database Migrations for migration system details.