Skip to main content

Database Design

This document provides a comprehensive and structured overview of the database design for OsmoX. It serves as a reference guide for developers, database administrators, and other stakeholders.
The tables discussed below are created as part of the database migration.

Database Schema

The database schema consists of the following tables:
TableDescription
notify_applicationsDetails about all the current applications
notify_archived_notificationsCompleted notifications that have been archived
notify_master_providersBasic provider types and configuration JSON
notify_migrationsMigration records
notify_notification_retriesDetails of notification retries
notify_notificationsAll notifications created
notify_providersProvider configurations
notify_server_api_keysAPI keys for different applications
notify_usersUser accounts
notify_webhooksWebhook URLs for providers
notify_provider_typesProvider type catalog (e.g., SMS, Email, WhatsApp)
notify_provider_chainsPer-application provider chains by provider type
notify_provider_chain_membersOrdered members within a provider chain
OsmoX Database Schema

Data Dictionary

notify_applications

AttributeData TypeNot NullDefaultDescription
application_idintegerTruePrimary key, unique identifier for the application
namevarchar(255)TrueName of the application
user_idintegerTrueUser ID of the user associated with this application
created_ontimestampTruecurrent_timestamp()Timestamp for the creation
updated_ontimestampTruecurrent_timestamp()Timestamp for the last update
statussmallintTrue1Active(1) or inactive(0)
test_mode_enabledsmallintTrue0Test mode enabled(1) or disabled(0)
whitelist_recipientsjsonbFalseNULLWhitelisted recipients in JSON format

notify_notifications

AttributeData TypeNot NullDefaultDescription
idintegerTruePrimary key
channel_typesmallintTrueForeign Key to master_provider
datajsonbTrueJSON data (from/to addresses, subject, body)
delivery_statussmallintTrue1Current delivery status
resultjsonbFalseNULLJSON result after sending attempt
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
created_byvarchar(255)TrueService/app that created the notification
updated_byvarchar(255)TrueService/app that last updated
statussmallintTrue1Active(1) or inactive(0)
application_idintegerFalseNULLRelated application ID
provider_idintegerFalseNULLForeign key to provider
retry_countintegerTrue0Retry count
notification_sent_ontimestampFalseNULLTime sent to provider

notify_archived_notifications

AttributeData TypeNot NullDefaultDescription
idintegerTruePrimary key
notification_idintegerTrueOriginal notification ID (indexed)
channel_typesmallintTrueForeign Key to master_provider
datajsonbTrueJSON notification data
delivery_statussmallintTrue1Final delivery status (indexed)
resultjsonbFalseNULLJSON result
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
created_byvarchar(255)TrueCreator service/app
updated_byvarchar(255)TrueLast updater service/app
statussmallintTrue1Active(1) or inactive(0)
application_idintegerFalseNULLRelated application ID
provider_idintegerFalseNULLForeign key to provider
retry_countintegerTrue0Retry count
notification_sent_ontimestampFalseNULLTime sent to provider

notify_providers

AttributeData TypeNot NullDefaultDescription
provider_idsmallintTruePrimary key
namevarchar(255)TrueProvider name
channel_typesmallintTrueChannel type for notifications
is_enabledsmallintTrueWhether provider is enabled
configurationjsonbTrueProvider configuration JSON
application_idintegerTrueApplication identifier
user_idintegerTrueAssociated user ID
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
statussmallintTrue1Active(1) or inactive(0)
{
  "SMTP_HOST": "some.smtp.host",
  "SMTP_PORT": 123,
  "SMTP_USERNAME": "someusername",
  "SMTP_PASSWORD": "somepassword"
}

notify_master_providers

AttributeData TypeNot NullDefaultDescription
master_idsmallintTruePrimary key
namevarchar(255)TrueProvider name
provider_typesmallintTrue1Provider type (SMS, Email, etc.)
configurationjsonbTrueMaster configuration JSON
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
statussmallintTrue1Active(1) or inactive(0)
{
  "apikey": {
    "label": "API Key",
    "id": "apikey",
    "pattern": "^[0-19]10$",
    "type": "number"
  }
}

notify_provider_chains

AttributeData TypeNot NullDefaultDescription
chain_idserial4TruePrimary key
chain_namevarchar(255)TrueChain name
application_idint4TrueForeign Key to application
provider_typeint2True1Foreign Key to provider type
descriptiontextFalseOptional description
is_defaultint2True0Whether chain is used by default
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
statussmallintTrue1Active(1) or inactive(0)

notify_provider_chain_members

AttributeData TypeNot NullDefaultDescription
idserial4TruePrimary key
chain_idint4TrueForeign key to chain
provider_idint4TrueForeign key to provider
priority_orderint2TrueProcessing order (1=first, 2=second, etc.)
is_activeint2True1Active(1) or inactive(0)
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
statussmallintTrue1Active(1) or inactive(0)

notify_server_api_keys

AttributeData TypeNot NullDefaultDescription
api_key_idintegerTruePrimary key
api_keyvarchar(255)TrueServer API key (unique per application)
application_idintegerTrueForeign key to application
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
statussmallintTrue1Active(1) or inactive(0)

notify_users

AttributeData TypeNot NullDefaultDescription
user_idintegerTruePrimary key
usernamevarchar(255)TrueUsername
passwordvarchar(255)TrueHashed password
rolesmallintTrue0Role: BASIC (0) or ADMIN (1)
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
statussmallintTrue1Active(1) or inactive(0)

notify_webhooks

AttributeData TypeNot NullDefaultDescription
idintegerTruePrimary key
provider_idintegerTrueForeign key to provider
webhookUrlvarchar(255)FalseNULLWebhook URL to trigger
is_verifiedsmallintTrue0Whether webhook is verified
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
statussmallintTrue1Active(1) or inactive(0)
For details on webhook integration, see the Webhook Guide.

notify_provider_types

AttributeData TypeNot NullDefaultDescription
provider_type_idserial4TruePrimary key
namevarchar(255)TrueProvider type name
descriptiontextFalseOptional description
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
statussmallintTrue1Active(1) or inactive(0)

notify_migrations

AttributeData TypeNot NullDefaultDescription
idintegerTruePrimary key
timestamptimestampTrueMigration creation timestamp
namevarchar(255)TrueMigration name

notify_notification_retries

AttributeData TypeNot NullDefaultDescription
idintegerTruePrimary key
notification_idintegerTrueNotification ID in retry loop
retry_countintegerTrueRetry number
retry_resultjsonbFalseNULLRetry result
created_ontimestampTruecurrent_timestamp()Creation timestamp
updated_ontimestampTruecurrent_timestamp()Last update timestamp
statussmallintTrue1Active(1) or inactive(0)