Skip to main content
Version: Latest

7. Database Tables

All 6 tables live in the Saas schema of the central subscription/Saas database — the same database Shumoul.MultiTenancyApi uses for tenants, subscriptions, and notifications. They do not live inside every tenant database. The actual AppSettings rows these tables eventually influence are applied to each tenant's own resolved database, but only through Shumoul.BackEnd (see Chapter 4 and Chapter 10) — never written directly by Shumoul.MultiTenancyApi.

7.1 Saas.OnboardingSurveyDefinitions

One row per survey version. The seeder ships a single survey, default-business-setup, version 1.

ColumnTypeNotes
IdGuidPK
Codestringe.g. default-business-setup
NameAr / NameEnstringDisplay names
VersionintThe active survey is the highest Version with IsActive = true
IsActive, DisplayOrder(from BaseEntity)

7.2 Saas.OnboardingQuestions

All questions across all survey steps, for all surveys.

ColumnTypeNotes
IdGuidPK
SurveyDefinitionIdGuidFK → OnboardingSurveyDefinitions
KeystringStable key used in AnswersJson and VisibleWhenJson, e.g. activityType
TitleAr / TitleEn, DescriptionAr / DescriptionEnstringDisplay text
TypeOnboardingQuestionType enumSingleChoice, MultiChoice, Boolean
StepNointGroups questions into wizard steps
IsRequiredboolDrives status.currentStep computation
OptionsJsonstringJSON array of {value, labelAr, labelEn} for choice questions
VisibleWhenJsonstringJSON condition — e.g. only show hasTables when activityType == "RestaurantCafe"

7.3 Saas.OnboardingProfiles

The catalog of recommendation outcomes (e.g. RestaurantCafe, Services) a session can be matched to.

ColumnTypeNotes
IdGuidPK
CodestringMatched against TenantOnboardingSessions.RecommendedProfileCode
NameAr / NameEn, DescriptionAr / DescriptionEnstringDisplay text

7.4 Saas.OnboardingRules

Condition → settings-patch mapping the recommendation engine evaluates.

ColumnTypeNotes
IdGuidPK
ProfileCodestring?null = a global/conditional rule evaluated for every session regardless of recommended profile; non-null = a base-profile rule, only evaluated when that profile was recommended
ConditionJsonstringJSON condition evaluated against the session's answers
SettingsPatchJsonstringThe settings-group/property fragment this rule contributes if its condition matches
PriorityintEvaluation/merge order

ProfileCode here and the base-profile activityType answer values are the same value space later formalized as real, FK-able master data — see Saas.BusinessActivities in the Tenant Starter Kit & Product Catalog guide, which every accounting/cost-center/product-catalog starter template is scoped by.

7.5 Saas.TenantOnboardingSessions

One row per tenant per survey — the actual state machine described in Chapter 5.

ColumnTypeNotes
IdGuidPK — this is the sessionId returned by answers and required by apply
TenantIdstringThe tenant this session belongs to — always set from the authenticated user's JWT Tenant claim, never from client input
UserIdGuidThe user who started the session
SurveyDefinitionId, SurveyVersionGuid, intWhich survey this session answers
StatusOnboardingSessionStatus enumNotStarted=1, InProgress=2, Recommended=3, Applied=4, Skipped=5
AnswersJsonstringMerged answers, keyed by question Key
RecommendedProfileCodestringSet by recommendation
GeneratedSettingsPatchJsonstringThe patch apply will send to the internal bridge
GeneratedSummaryJson, GeneratedWarningsJson, GeneratedNextActionsJsonstringHuman-readable recommendation output
CompletedOn, AppliedOn, SkippedOnDateTime?Status-transition timestamps

7.6 Saas.TenantOnboardingApplyLogs

Audit trail — one row per successful apply call.

ColumnTypeNotes
IdGuidPK
TenantIdstring
SessionIdGuidFK → TenantOnboardingSessions
BeforeSettingsJson / AfterSettingsJsonstringFull snapshot of every touched settings group, before and after
AppliedPatchJsonstringOnly the properties that were actually changed
AppliedByGuidThe authenticated user's NameIdentifiernever a system/service-account id (see Chapter 12 verification note)
AppliedOnDateTime
Notesstring?Reserved, currently unused

No apply log row is ever created for a failed apply call — a failure leaves the session at Recommended with no side effects.