Skip to main content

Core Tables

Overview

The core tables form the foundation of the Scoriet database, managing user accounts, authentication, projects, and team organization. All other database entities ultimately relate back to these core tables.


users

Stores user account information, authentication credentials, profile data, and subscription details.

Purpose

  • User authentication and authorization
  • User profile and preference management
  • Seller/patron account management
  • Two-factor authentication setup
  • Credit tracking and subscription management

Fields

FieldTypeNullDefaultDescription
idbigIncrementsNOAutoPrimary key
namestringNO-User's full name
emailstring(unique)NO-Unique email address
passwordstringNO-Hashed password
themestring(20)NOdarkUI theme preference (light/dark)
email_verified_attimestampYESNULLEmail verification timestamp
is_inner_corebooleanNOfalseInternal team flag
is_sellerbooleanNOfalseWhether user is a template seller
company_namestringYESNULLBusiness name (for sellers)
company_addresstextYESNULLBusiness address (for sellers)
company_countrystring(2)YESNULLCountry code (ISO 3166-1 alpha-2)
vat_idstring(50)YESNULLVAT identification number
business_registrationstringYESNULLBusiness registration number
tax_idstring(50)YESNULLTax identification number
seller_typeenumYESNULLType of seller (at_business, eu_vat, eu_private, non_eu_business, non_eu_private)
payout_methodenumYESNULLPreferred payout method (bank_transfer, paypal)
paypal_payout_emailstringYESNULLPayPal email for payouts
bank_ibanstring(34)YESNULLIBAN for bank transfers
bank_bicstring(11)YESNULLBIC/SWIFT code
bank_account_holderstringYESNULLAccount holder name
seller_verifiedbooleanNOfalseSeller verification status
seller_verified_attimestampYESNULLSeller verification timestamp
pending_earningsdecimal(10)NO0Unprocessed earnings
total_earningsdecimal(10)NO0Total lifetime earnings
two_factor_secretstringYESNULLTwo-factor authentication secret
two_factor_enabledbooleanNOfalse2FA enabled flag
two_factor_confirmed_attimestampYESNULL2FA confirmation timestamp
two_factor_recovery_codestextYESNULL2FA recovery codes (JSON)
two_factor_trusted_devicestextYESNULLTrusted device list (JSON)
two_factor_last_verified_attimestampYESNULLLast 2FA verification time
usernamestring(unique)YESNULLUnique username handle
user_typeenumNOfreeAccount type (free, patron, system)
is_activebooleanNOtrueAccount active status
languagestring(5)NOenPreferred language (ISO 639-1 + country)
kanban_initialsstring(3)YESNULLUser initials for kanban cards
kanban_colorstring(7)YESNULLColor code for kanban cards (hex)
creditsintegerNO50Current credit balance
last_monthly_credits_attimestampYESNULLLast monthly credit grant timestamp
stripe_customer_idstringYESNULLStripe customer identifier
stripe_subscription_idstringYESNULLStripe subscription identifier
paypal_subscription_idstringYESNULLPayPal subscription identifier
patron_typeenumYESNULLPatron subscription type (annual, monthly)
pending_project_invitation_idunsignedBigInteger(FK)YESNULLFK: projects.id - Pending project invitation
remember_tokenstringYESNULLRemember me token
email_system_notificationsbooleanNOtrueSystem notification email preference
email_user_notificationsbooleanNOtrueUser message email preference
last_login_attimestampYESNULLLast login timestamp
inactivity_warning_1_sent_attimestampYESNULLFirst inactivity warning sent
inactivity_warning_2_sent_attimestampYESNULLSecond inactivity warning sent
inactivity_warning_final_sent_attimestampYESNULLFinal inactivity warning sent
created_attimestampNO-Creation timestamp
updated_attimestampNO-Last update timestamp

Indexes

  • Primary Key: id
  • Unique: email, username
  • Foreign Key: pending_project_invitation_id
  • Composite: (last_login_at, user_type, is_active) - For inactivity queries

Relationships

  • Has Many → Projects (creator)
  • Has Many → Schemas (owner)
  • Has Many → Templates (creator)
  • Has Many → Teams (manager)
  • Has One → User Git Providers

projects

Stores project definitions including deployment configuration, database connection details, and UI settings.

Purpose

  • Project organization and management
  • Database connection configuration
  • Git integration settings
  • Code generation settings and preferences
  • Form and diagram designer settings
  • Deployment configuration (FTP)

Fields

FieldTypeNullDefaultDescription
idbigIncrementsNOAutoPrimary key
namestring(indexed)NO-Project name
descriptiontextYESNULLProject description
owner_idunsignedBigInteger(FK)NO-FK: users.id (CASCADE)
git_provider_idunsignedBigInteger(FK)YESNULLFK: user_git_providers.id
git_repositorystringYESNULLRepository URL or path
git_default_branchstringYESNULLDefault working branch
git_main_branchstringYESNULLMain/production branch
git_target_directorystringYESNULLTarget directory in repository
git_workflowenumNOpush_onlyWorkflow type (push_only, push_and_pr, push_pr_merge)
git_pr_title_templatestringYESNULLPull request title template
git_pr_description_templatetextYESNULLPull request description template
git_auto_delete_branchbooleanNOtrueAuto-delete feature branches
deployment_typestring(10)YESNULLDeployment type (ftp, git, local, etc)
ftp_hoststringYESNULLFTP server hostname
ftp_portintegerYES21FTP port number
ftp_usernamestringYESNULLFTP username
ftp_passwordtextYESNULLFTP password (encrypted)
ftp_directorystringYESNULLTarget directory on FTP server
ftp_passivebooleanNOtrueFTP passive mode
ftp_sslbooleanNOfalseFTP SSL/TLS connection
is_activebooleanNOtrueProject active status
is_publicbooleanNOtrueProject visibility to other users
join_codestring(20, unique)YESNULLCode for joining project
allow_join_requestsbooleanNOfalseAllow user join requests
settingsjsonYESNULLProject-specific settings
database_namestringYESNULLDatabase name for schema import
database_typestringNOMySQLDatabase type (MySQL, PostgreSQL, SQLite, MS-SQL)
database_serverstringNO127.0.0.1Database server hostname/IP
database_portstringNO3306Database port number
database_usernamestringYESNULLDatabase username
database_passwordstringYESNULLDatabase password (encrypted)
diagram_max_tables_per_rowunsignedSmallIntegerNO20Diagram layout setting
diagram_table_widthunsignedSmallIntegerNO280Diagram table width in pixels
diagram_table_heightunsignedSmallIntegerNO450Diagram table height in pixels
diagram_horizontal_spacingunsignedSmallIntegerNO600Horizontal spacing between tables
diagram_vertical_spacingunsignedSmallIntegerNO700Vertical spacing between tables
form_designer_snap_to_gridbooleanNOtrueForm designer grid snap
form_designer_grid_sizeintegerNO20Form designer grid size
project_directorystringYESNULLLocal project directory path
project_urlstringYESNULLProject deployment URL
start_pagestringYESindex.phpDefault start page
default_languagestring(10)YESenDefault UI language
archive_formatenumNOzipArchive format (zip, tar.gz, tar.xz)
filename_short_lengthunsignedTinyIntegerYES2Short filename format length
decimal_separatorstring(1)YES,Number decimal separator
thousands_separatorstring(1)YES.Number thousands separator
date_formatstring(20)YESd.m.YDisplay date format
time_formatstring(20)YESH:i:sDisplay time format
currency_symbolstring(5)YESCurrency symbol display
timezonestring(50)YESEurope/ViennaDefault timezone
enabled_languagesjsonYESNULLList of enabled languages
google_translate_api_keystring(500)YESNULLGoogle Translate API key
created_attimestampNO-Creation timestamp
updated_attimestampNO-Last update timestamp
protected_filesjsonYESNULLFiles that should not be overwritten
install_scriptjsonYESNULLProject installation instructions
update_scriptjsonYESNULLProject update instructions

Indexes

  • Primary Key: id
  • Unique: join_code
  • Regular: name
  • Composite: (git_provider_id, git_repository), (owner_id, is_active)

Relationships

  • Belongs To → Users (owner)
  • Has Many → Project Members
  • Has Many → Project Schemas
  • Has Many → Project Template Usage
  • Has Many → Project Generations
  • Has Many → Project Attachments

teams

Stores team organizational structures within projects.

Purpose

  • Team creation and management
  • Team-based project organization
  • Hierarchical user grouping

Fields

FieldTypeNullDefaultDescription
idbigIncrementsNOAutoPrimary key
namestringNO-Team name
descriptiontextYESNULLTeam description
project_owner_idunsignedBigInteger(FK)NO-FK: users.id (CASCADE) - Project/team owner
is_activebooleanNOtrueTeam active status
created_attimestampNO-Creation timestamp
updated_attimestampNO-Last update timestamp

Relationships

  • Belongs To → Users (owner)
  • Has Many → Team Members
  • Has Many → Team Roles

team_members

Stores user membership in teams with assigned roles.

Purpose

  • Team membership tracking
  • Role assignment within teams
  • Member management

Fields

FieldTypeNullDefaultDescription
idbigIncrementsNOAutoPrimary key
team_idunsignedBigInteger(FK)NO-FK: teams.id (CASCADE)
user_idunsignedBigInteger(FK)NO-FK: users.id (CASCADE)
roleenumNO-Built-in role (owner, admin, member)
team_role_idunsignedBigInteger(FK)YESNULLFK: team_roles.id (CASCADE) - Custom role
joined_attimestampNOCURRENTJoin timestamp
created_attimestampNO-Creation timestamp
updated_attimestampNO-Last update timestamp

Indexes

  • Primary Key: id
  • Unique: (team_id, user_id)
  • Foreign Keys: team_id, user_id, team_role_id

Relationships

  • Belongs To → Teams
  • Belongs To → Users
  • Belongs To → Team Roles (optional)

team_roles

Stores custom role definitions for teams.

Purpose

  • Custom role creation
  • Role-based access control per team
  • Permission management

Fields

FieldTypeNullDefaultDescription
idbigIncrementsNOAutoPrimary key
team_idunsignedBigInteger(FK)NO-FK: teams.id (CASCADE)
namestring(100)NO-Role display name
slugstring(100)NO-Role identifier slug
descriptiontextYESNULLRole description
is_systembooleanNOfalseSystem role flag
sort_orderintegerNO0Display order
created_attimestampNO-Creation timestamp
updated_attimestampNO-Last update timestamp

Indexes

  • Primary Key: id
  • Unique: (team_id, slug)
  • Foreign Key: team_id

Relationships

  • Belongs To → Teams
  • Has Many → Team Role Permissions
  • Has Many → Team Members

team_role_permissions

Stores permission mappings for team roles.

Purpose

  • Permission assignment to roles
  • RBAC implementation for teams

Fields

FieldTypeNullDefaultDescription
idbigIncrementsNOAutoPrimary key
team_role_idunsignedBigInteger(FK)NO-FK: team_roles.id (CASCADE)
permission_idunsignedBigInteger(FK)NO-FK: permissions.id (CASCADE)
created_attimestampNO-Creation timestamp
updated_attimestampNO-Last update timestamp

Indexes

  • Primary Key: id
  • Unique: (team_role_id, permission_id)
  • Foreign Keys: team_role_id, permission_id

Relationships

  • Belongs To → Team Roles
  • Belongs To → Permissions

permissions

Stores system-wide permissions that can be assigned to roles.

Purpose

  • Permission registry for RBAC
  • Permission reference management

Fields

FieldTypeNullDefaultDescription
idbigIncrementsNOAutoPrimary key
namestring(unique)NO-Permission identifier
display_namestringYESNULLHuman-readable name
descriptiontextYESNULLPermission description
categorystringYESNULLPermission category
created_attimestampNO-Creation timestamp
updated_attimestampNO-Last update timestamp

Indexes

  • Primary Key: id
  • Unique: name

Relationships

  • Has Many → Team Role Permissions

user_git_providers

Stores Git provider credentials for users.

Purpose

  • GitHub/GitLab/Bitbucket account linking
  • OAuth token management
  • Repository integration

Fields

FieldTypeNullDefaultDescription
idbigIncrementsNOAutoPrimary key
user_idunsignedBigInteger(FK)NO-FK: users.id (CASCADE)
providerenumNO-Provider type (github, gitlab, bitbucket)
provider_usernamestringNO-Username on the provider
access_tokentextNO-OAuth access token (encrypted)
refresh_tokentextYESNULLOAuth refresh token (encrypted)
token_expires_attimestampYESNULLToken expiration time
scopesstringYESNULLGranted OAuth scopes
is_activebooleanNOtrueConnection active status
created_attimestampNO-Creation timestamp
updated_attimestampNO-Last update timestamp

Indexes

  • Primary Key: id
  • Unique: (user_id, provider)
  • Foreign Key: user_id

Relationships

  • Belongs To → Users

Key Concepts

User Types

  • free: Free tier users with limited credits
  • patron: Paid subscription users (annual or monthly)
  • system: Internal system administrators

Seller Types

  • at_business: Austrian businesses with VAT ID
  • eu_vat: EU businesses with VAT ID
  • eu_private: EU private persons
  • non_eu_business: Non-EU business
  • non_eu_private: Non-EU private person

Payout Methods

  • bank_transfer: Direct bank transfer (IBAN/BIC)
  • paypal: PayPal payout

Git Workflows

  • push_only: Direct commits to main branch
  • push_and_pr: Create pull requests (no auto-merge)
  • push_pr_merge: Create and automatically merge pull requests

Data Integrity Notes

  1. User Deletion: When a user is deleted (owner_id CASCADE), all dependent projects, schemas, and templates are also deleted.

  2. Project Access: Non-owners cannot modify projects unless they are added as project_members with appropriate roles.

  3. Team Structure: Teams can only be created by project owners, maintaining clear ownership hierarchy.

  4. Credit System: Credit balance is tracked at the user level for all transaction types (generation, purchase, sale, etc).

  5. Two-Factor Authentication: Once 2FA is enabled, must be confirmed. Trusted devices bypass 2FA for a period.


  • See Project Relationship Tables for project member and schema associations
  • See User Notification System for email preference handling
  • See Subscription & Credit System for monetization details