Appearance
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 migrations | 168 (one, webauthn_credentials, from a package migration whose columns are not in the repo) |
| Columns | 1941 |
| Foreign keys | 246 |
| 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 relation | 102 |
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).
| Connection | Driver | Hosts | Used by |
|---|---|---|---|
mysql | mysql | Read 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_primary | mysql | Write host only | Passport 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_queue | mysql | Write host only | Database 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, sqlsrv | sqlite, 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 ​
| Folder | Files | Loaded by php artisan migrate? |
|---|---|---|
database/migrations | 152 | Yes |
database/migrations/update | 161 | No. 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) runALTER TABLE ... ADD INDEX ..., ALGORITHM=INPLACE, LOCK=NONEthroughDB::statement, guarded by aninformation_schemalookup. These were parsed and are included. - Backfills with raw
UPDATE ... JOIN dam_instances(instance_idonworkspace_brandings,share_assets_category,dam_tiles) and themigrate_visibility_to_dam_instance_permissionsdata copy change data only. update/2026_06_10_*find the foreign key onuser_idwithSchema::getForeignKeys()and drop it.update/2026_07_09_120000_create_webauthn_credentials_table.phpreturns the package migrationWebAuthnCredential::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 columnsworkspaces.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 withdigital_assets_, newer ones withdam_. - Primary keys are
bigint unsignedauto increment ($table->id()orbigIncrements). Exceptions:email_log.idisint unsigned, the Passportoauth_*token and code ids arevarchar(100), andfeedback.idis auuid(char(36)).leads.idstarts at 1000. - Foreign key columns are
unsignedBigIntegernamed<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 namedcreated_by,updated_by,post_by,archive_by,generated_by,send_by). - Timestamps: all but 7 tables have
created_at/updated_at(the exceptions areemail_log,oauth_auth_codes,oauth_refresh_tokens,failed_jobs,jobs_history,page_data;webauthn_credentialsis unknown).digital_assets,digital_assets_categoriesanddam_collectionsaddmodified_at, backfilled fromupdated_atin 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_assetsandassets_versionsdo not soft delete; trash and archive are flag columns (is_deleted,final_deleted,visible_in_trashed,is_archive). - Booleans are
boolean(tinyint(1)),tinyInteger, orenum('0','1')/enum('1','0')depending on age, often with acomment()that spells out the values. - UUIDs: only
feedback.idis a real UUID column.leads.uuid,guest_users.uuid,guest_visit_logs.uuidandcontacts.uuidarevarchar(255)visitor ids;failed_jobs.uuidis 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 intext/longtext(for exampledam_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.VerifyUserWithWorkSpacelooks upworkspaces.url_slug, then requires aworkspace_usersrow for the user and that workspace (and runs the SSO recheck). Controllers then filter byworkspace_idthemselves. - Portal API (
dam-apiguard) requests are scoped to a portal (dam_instances).DAMAPIMiddlewaretakesinstance_idfrom the request, theX-Instance-Idheader or the portal user's owninstance_id, checks the portal is active and that the user has an activedam_instances_usersrow (backend users skip this), then mergesdam_instance_idanddam_workspace_idinto the request. - Portal-level data carries
instance_id(ordam_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 keyuser_instance_id_email_uniqueis (instance_id,email,is_backend_user). - Most
workspace_idforeign keys areon delete cascade, so deleting a workspace row removes its assets, folders, versions, portals and most other data through MySQL. 24 tables haveworkspace_idwithout a foreign key and are not cleaned up this way (listed on Relationships); 23 tables allow aNULLworkspace_id.
Framework tables ​
| Table | Purpose | Notes |
|---|---|---|
jobs | Database queue | database and database_migration queue connections on mysql_queue; queues default and migration. |
failed_jobs | Failed jobs | database-uuids driver on mysql_queue. |
oauth_clients, oauth_access_tokens, oauth_refresh_tokens, oauth_auth_codes, oauth_personal_access_clients | Laravel Passport | Guards api (users), dam-api (dealer_users), external-api (dam_external_apps), external-user (external_users) all use the passport driver. Connection mysql_primary. |
webauthn_credentials | Passkeys | From laragear/webauthn. WebAuthn challenges are kept in the cache, not the session (AppServiceProvider). |
email_log | Outgoing mail log | Table from an email-log package migration (2015-2018 files). Nothing in app/ or config/ reads or writes it. |
migrations | Migration repository | Created 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 ​
| Domain | Group | Tables | Examples |
|---|---|---|---|
| DAM | Assets, folders, Collages, tags and custom fields | 10 | digital_assets, assets_versions, digital_assets_categories, digital_assets_digital_assets_categories, digital_assets_tags, custom_fields, ... |
| DAM | Portals and portal users | 10 | dam_instances, dam_instance_permissions, dam_instances_users, dealer_users, dealer_user_invitations, dam_groups, ... |
| DAM | Sharing, analytics, notifications and jobs | 13 | share_assets_category, digital_assets_downloads, transaction_activities, dealer_users_activities, dam_search_histories, recent_searches, ... |
| DAM | Asset store and watermark | 8 | dam_asset_products, dam_asset_product_carts, dam_asset_product_orders, dam_asset_product_order_items, dam_asset_product_order_shippings, dam_user_addresses, ... |
| Core | Workspaces, users, roles and permissions | 20 | workspaces, users, workspace_users, roles, role_user, modules, ... |
| Core | Authentication and SSO | 10 | oauth_clients, oauth_access_tokens, oauth_refresh_tokens, oauth_auth_codes, oauth_personal_access_clients, webauthn_credentials, ... |
| Core | Subscription and billing | 7 | subscriptions, subscription_users, subscription_addons, subscription_user_addons, subscription_user_activities, coupons, ... |
| Core | Notifications, announcements and logs | 13 | announcements, announcement_users, announcement_systm_notifications, email_modules, email_control_role_wise, email_control_user_wise, ... |
| Core | Queue tables | 2 | jobs, failed_jobs |
| Lead Management | Dealers and dealerships | 16 | dealers, dealerships, dealership_users, dealership_designations, dealership_favourite_users, dealership_products, ... |
| Lead Management | Leads | 19 | leads, lead_status, lead_statuses, lead_assign_dealerships, lead_rsm_assigns, lead_products, ... |
| Lead Management | Lead email | 11 | lead_send_emails, lead_emails, lead_email_attachments, lead_receive_emails, lead_receive_email_attachments, lead_email_templates, ... |
| Lead Management | Products | 7 | products, categories, product_images, product_variants, product_variant_options, product_variants_types, ... |
| Lead Management | CRM integrations, tracking and reference data | 21 | workspace_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_idhas no foreign key: it holds ausers.idor, for external uploads, anexternal_users.id.digital_assets.assets_version_id(the current version) has no foreign key in the migrations, whileassets_versions.asset_iddoes.dam_instance_permissionspoints at assets, folders and Collages polymorphically (permissionable_type,permissionable_id).share_assets_categoryhas no relation to the assets, folders or Collages it shares; their ids are stored as lists in text columns.custom_fieldsandassets_custom_fieldsare 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.
| Type | Meaning | Where it comes from | Delete behaviour |
|---|---|---|---|
| FK | Foreign 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 |
| Eloquent | Relation method in a model only | belongsTo, hasMany, hasOne, belongsToMany, morphMany, hasManyThrough in app/Models | Nothing in the database; orphans are possible unless code deletes children |
| Column only | An id column with no foreign key and no model relation | A *_id (or created_by style) column in a migration | Nothing; the target table is only implied by the name |
Related ​
- DAM tables · Core tables · LM tables · Relationships
- Models · Architecture · Configuration · Console commands