Skip to content

Database ​

Overview ​

The Backend-API stores everything in one MySQL database. This section describes its schema as the migrations build it at commit f517b6b (origin/development). There is no schema dump or live database in the repository, so every table, column, index and foreign key here comes from replaying the 313 migration files in order, and every model relation from app/Models.

Count
Tables created by migrations168 (one, webauthn_credentials, from a package migration whose columns are not in the repo)
Columns1941
Foreign keys246
Extra indexes (unique and plain, not counting primary keys and FK indexes)58
Model-only relations (no foreign key)50
Id columns with no foreign key and no model relation102

Pages in this section:

  • DAM tables: assets, versions, folders, Collages, tags, custom fields, portals, share links, analytics, notifications, asset store.
  • Core tables: workspaces, users, roles, auth and SSO, subscriptions, announcements, logs, queue.
  • LM tables: the Lead Management module.
  • Relationships: every relation in one table, and the issues found.

For the Eloquent side (fillable, casts, scopes) see Models.

Engine and connections ​

The default connection is DB_CONNECTION (default mysql). All three MySQL connections use utf8mb4 / utf8mb4_unicode_ci, engine InnoDB and strict => false, so MySQL runs without strict mode (bad values are truncated or defaulted instead of rejected).

ConnectionDriverHostsUsed by
mysqlmysqlRead hosts from DB_READ_HOST (comma separated, falls back to DB_HOST), write host DB_WRITE_HOST, sticky from DB_STICKY (default true)Default connection. Every model (no model sets $connection), migrations, query builder calls.
mysql_primarymysqlWrite host onlyPassport token tables (config/passport.php, PASSPORT_CONNECTION, default mysql_primary), and the ReindexAssetsByIds / ReindexAssetTagsByAssetIds jobs, which read DigitalAssets::on('mysql_primary') and DigitalAssetsTag::on('mysql_primary') so a just-written row is not missed on a lagging replica.
mysql_queuemysqlWrite host onlyDatabase queue connections database and database_migration (QUEUE_DB_CONNECTION, default mysql_queue) and failed jobs (QUEUE_FAILED_DB_CONNECTION). StatusController::serverPage counts jobs and failed_jobs through it.
sqlite, pgsql, sqlsrvsqlite, pgsql, sqlsrv-Laravel defaults. Nothing references them; the sqlite lines in phpunit.xml are commented out.

Redis (client from REDIS_CLIENT, default phpredis) has two connections: default (REDIS_DB, default 0), used by the redis queue connection, and cache (REDIS_CACHE_DB, default 1), used by the redis cache store. The default cache store (CACHE_DRIVER) and session driver (SESSION_DRIVER) are both file. Environment values are covered in Configuration.

Migrations ​

FolderFilesLoaded by php artisan migrate?
database/migrations152Yes
database/migrations/update161No. Nothing calls loadMigrationsFrom(), so these run only with php artisan migrate --path=database/migrations/update (or --path for both folders).

The two folders interleave by date: update/ holds both column changes from 2021-2026 and every table created after mid-2023 (for example custom_fields, external_users, dam_instance_permissions, workspace_sso_connections). The schema on these pages is the result of running both folders together in filename order. The migration repository table is migrations.

Most migrations use the schema builder. The exceptions:

  • Index migrations from 2026 (add_index_on_file_preview_id, add_weekly_insights_indexes, add_digital_assets_listing_indexes, add_phase2_performance_indexes, extend_da_cat_flags_ws_idx_with_modified_at, add_custom_field_value_index_to_assets_custom_fields, add_indexes_to_assets_custom_fields_table, add_migration_status_to_import_data_table) run ALTER TABLE ... ADD INDEX ..., ALGORITHM=INPLACE, LOCK=NONE through DB::statement, guarded by an information_schema lookup. These were parsed and are included.
  • Backfills with raw UPDATE ... JOIN dam_instances (instance_id on workspace_brandings, share_assets_category, dam_tiles) and the migrate_visibility_to_dam_instance_permissions data copy change data only.
  • update/2026_06_10_* find the foreign key on user_id with Schema::getForeignKeys() and drop it.
  • update/2026_07_09_120000_create_webauthn_credentials_table.php returns the package migration WebAuthnCredential::migration().

Many older migrations wrap Schema::create in if (!Schema::hasTable(...)) and column adds in Schema::hasColumn checks, so they can be re-run on databases that already have the change.

php artisan dam:setup (RemoveOtherData, see Console commands) drops tables at runtime with Schema::dropIfExists: 67 of the 74 LM tables, plus permissions, permission_user, email_modules, email_control_role_wise and email_control_user_wise, plus many old Projects tables that no migration creates any more. It is not a migration, so the migrations still create those tables on a fresh install.

Naming conventions ​

  • Table names are mostly snake-case plurals (digital_assets, dam_instances). Exceptions are singular: dam_acl, dam_inquiry, share_assets_category, lead_status, numverify, twilio, device_token, product_alias, lead_email_signature, feedback, email_log, page_data, import_data, email_control_role_wise. Some names carry typos that are now fixed in the schema: announcement_systm_notifications, dealer_ship_communication_preferences, and the columns workspaces.secrete_key, dam_external_apps.secrete, products.descrption, leads.communication_preferance.
  • UI names differ from table names: asset = digital_assets, folder = digital_assets_categories, Collage = dam_collections, portal = dam_instances, share link = share_assets_category, portal user = dealer_users. Older DAM tables start with digital_assets_, newer ones with dam_.
  • Primary keys are bigint unsigned auto increment ($table->id() or bigIncrements). Exceptions: email_log.id is int unsigned, the Passport oauth_* token and code ids are varchar(100), and feedback.id is a uuid (char(36)). leads.id starts at 1000.
  • Foreign key columns are unsignedBigInteger named <thing>_id, with some older names that do not follow the pattern (digital_assets_id, digital_assets_categories_id, sharp_spring_forms_id, product_variants_types_id, and user references named created_by, updated_by, post_by, archive_by, generated_by, send_by).
  • Timestamps: all but 7 tables have created_at / updated_at (the exceptions are email_log, oauth_auth_codes, oauth_refresh_tokens, failed_jobs, jobs_history, page_data; webauthn_credentials is unknown). digital_assets, digital_assets_categories and dam_collections add modified_at, backfilled from updated_at in 2024.
  • Soft deletes (deleted_at): 16 tables: users, dam_acl, digital_assets_categories, share_assets_category, dam_instances, dealers, dealer_users, dam_instances_users, instance_banners, products, dealerships, dam_collections, dam_assets_converts, subscription_user_addons, custom_fields, external_users. digital_assets and assets_versions do not soft delete; trash and archive are flag columns (is_deleted, final_deleted, visible_in_trashed, is_archive).
  • Booleans are boolean (tinyint(1)), tinyInteger, or enum('0','1') / enum('1','0') depending on age, often with a comment() that spells out the values.
  • UUIDs: only feedback.id is a real UUID column. leads.uuid, guest_users.uuid, guest_visit_logs.uuid and contacts.uuid are varchar(255) visitor ids; failed_jobs.uuid is Laravel's.
  • JSON columns (json): users.phone_number_validation_data, leads.open_street_map_address, dealerships.open_street_map_address, sharp_spring_sync_leads_mappings.mappings, lead_custom_field_data.custom_fields, lead_custom_field_data.form_payload, guest_visit_logs.visits, import_data.migration_result, custom_fields.field_settings, workspace_sso_connections.allowed_domains. Many more structured values sit in text / longtext (for example dam_instances.settings, digital_assets.file_meta_data, share_assets_category.assets_id).

Multi-tenancy ​

There is one database for all customers. The tenant is the workspace: 109 tables carry a workspace_id. Scoping is done in code, not by the database or by global scopes (no model registers a workspace global scope):

  • Admin API routes take the workspace slug as url_workspace_id. VerifyUserWithWorkSpace looks up workspaces.url_slug, then requires a workspace_users row for the user and that workspace (and runs the SSO recheck). Controllers then filter by workspace_id themselves.
  • Portal API (dam-api guard) requests are scoped to a portal (dam_instances). DAMAPIMiddleware takes instance_id from the request, the X-Instance-Id header or the portal user's own instance_id, checks the portal is active and that the user has an active dam_instances_users row (backend users skip this), then merges dam_instance_id and dam_workspace_id into the request.
  • Portal-level data carries instance_id (or dam_instance_id): share_assets_category, dealers, dealer_users, dam_instances_users, dealer_user_invitations, instance_banners, dam_collections, dam_tiles, dam_system_notifications, dam_groups, workspace_brandings, transaction_activities, dam_instance_permissions. A portal user (dealer_users) belongs to one portal; the unique key user_instance_id_email_unique is (instance_id, email, is_backend_user).
  • Most workspace_id foreign keys are on delete cascade, so deleting a workspace row removes its assets, folders, versions, portals and most other data through MySQL. 24 tables have workspace_id without a foreign key and are not cleaned up this way (listed on Relationships); 23 tables allow a NULL workspace_id.

Framework tables ​

TablePurposeNotes
jobsDatabase queuedatabase and database_migration queue connections on mysql_queue; queues default and migration.
failed_jobsFailed jobsdatabase-uuids driver on mysql_queue.
oauth_clients, oauth_access_tokens, oauth_refresh_tokens, oauth_auth_codes, oauth_personal_access_clientsLaravel PassportGuards api (users), dam-api (dealer_users), external-api (dam_external_apps), external-user (external_users) all use the passport driver. Connection mysql_primary.
webauthn_credentialsPasskeysFrom laragear/webauthn. WebAuthn challenges are kept in the cache, not the session (AppServiceProvider).
email_logOutgoing mail logTable from an email-log package migration (2015-2018 files). Nothing in app/ or config/ reads or writes it.
migrationsMigration repositoryCreated by Laravel.

Not created by any migration: sessions and cache (both drivers default to file), password_resets (named in config/auth.php), personal_access_tokens (Sanctum is installed but tokens come from Passport), and telescope_* (config/telescope.php exists but Telescope is not in composer.json).

Domain map ​

DomainGroupTablesExamples
DAMAssets, folders, Collages, tags and custom fields10digital_assets, assets_versions, digital_assets_categories, digital_assets_digital_assets_categories, digital_assets_tags, custom_fields, ...
DAMPortals and portal users10dam_instances, dam_instance_permissions, dam_instances_users, dealer_users, dealer_user_invitations, dam_groups, ...
DAMSharing, analytics, notifications and jobs13share_assets_category, digital_assets_downloads, transaction_activities, dealer_users_activities, dam_search_histories, recent_searches, ...
DAMAsset store and watermark8dam_asset_products, dam_asset_product_carts, dam_asset_product_orders, dam_asset_product_order_items, dam_asset_product_order_shippings, dam_user_addresses, ...
CoreWorkspaces, users, roles and permissions20workspaces, users, workspace_users, roles, role_user, modules, ...
CoreAuthentication and SSO10oauth_clients, oauth_access_tokens, oauth_refresh_tokens, oauth_auth_codes, oauth_personal_access_clients, webauthn_credentials, ...
CoreSubscription and billing7subscriptions, subscription_users, subscription_addons, subscription_user_addons, subscription_user_activities, coupons, ...
CoreNotifications, announcements and logs13announcements, announcement_users, announcement_systm_notifications, email_modules, email_control_role_wise, email_control_user_wise, ...
CoreQueue tables2jobs, failed_jobs
Lead ManagementDealers and dealerships16dealers, dealerships, dealership_users, dealership_designations, dealership_favourite_users, dealership_products, ...
Lead ManagementLeads19leads, lead_status, lead_statuses, lead_assign_dealerships, lead_rsm_assigns, lead_products, ...
Lead ManagementLead email11lead_send_emails, lead_emails, lead_email_attachments, lead_receive_emails, lead_receive_email_attachments, lead_email_templates, ...
Lead ManagementProducts7products, categories, product_images, product_variants, product_variant_options, product_variants_types, ...
Lead ManagementCRM integrations, tracking and reference data21workspace_leads_module_settings, sharp_spring_accounts, sharp_spring_forms, sharp_spring_fields, sharp_spring_global_fields, sharp_spring_column_fields, ...

Core schema ​

The central tables and how they connect. Solid lines are foreign keys; dotted lines are relations defined only in the models. || / |o on the parent side means the referencing column is required / nullable.

Things the diagram shows that are easy to miss:

  • digital_assets.user_id has no foreign key: it holds a users.id or, for external uploads, an external_users.id.
  • digital_assets.assets_version_id (the current version) has no foreign key in the migrations, while assets_versions.asset_id does.
  • dam_instance_permissions points at assets, folders and Collages polymorphically (permissionable_type, permissionable_id).
  • share_assets_category has no relation to the assets, folders or Collages it shares; their ids are stored as lists in text columns.
  • custom_fields and assets_custom_fields are linked only in the models.

Relationship types ​

Every relation on these pages carries one of three labels. The difference matters: only FK relations are enforced and cascade.

TypeMeaningWhere it comes fromDelete behaviour
FKForeign key constraint in MySQL$table->foreign(...)->references(...)->on(...) or foreignId(...)->constrained() in a migration (and not dropped later)on delete as listed (cascade or set null); MySQL rejects rows that point at a missing parent
EloquentRelation method in a model onlybelongsTo, hasMany, hasOne, belongsToMany, morphMany, hasManyThrough in app/ModelsNothing in the database; orphans are possible unless code deletes children
Column onlyAn id column with no foreign key and no model relationA *_id (or created_by style) column in a migrationNothing; the target table is only implied by the name