DB Schema

Introduction

The DB Schema tool allows you to design and manage your database structure directly from the CMS.

Using this tool, you can define database tables, columns, relationships, and behaviors without writing SQL migrations or backend code.

Changes made in DB Schema are first saved as definitions, and are only applied to the database when you explicitly choose to apply them.

DB-Schema

Create a New Table

To create a new database table:

  1. Open DB Schema from the left-side navigation.
  2. Click on New Generated Table.
  3. DB-Schema Menu
  4. Fill in the table configuration fields.
  • 1. Table Name
    The name of the table. Must not contain spaces or special characters.
  • 2. Timestamps
    When enabled, created_at and updated_at columns will be added.
  • 3. Soft Deletes
    When enabled, a deleted_at column is added and soft delete behavior is applied to the model.
  • 4. Has Active Flag
    When enabled, an is_active column is added. APIs will return only active records by default.
  • 5. Enable Slugging & Slug Source Field
    Available on edit mode. When enabled, a slug field is added and automatically generated from the selected source field.
DB-Schema

Manage Table Fields

After creating the table, you will be redirected to the table edit page, where you can manage its fields.

Click on New Generated Field to add a new column.

DB-Schema
  • 1. Name
    Column name. Must not contain spaces or special characters.
  • 2. Type
    Defines the data type such as string, text, boolean, integer, etc.
  • 3. Length
    Specifies the maximum length if the selected type supports it.
  • 4. Nullable
    Defines whether the column can accept null values.
  • 5. Default
    Sets a default value for the column.
  • 6. Is Translatable
    When enabled, the field supports multiple language values.
  • 7. Foreign Table
    Select the referenced table if the field is a foreign key.
  • 8. Foreign Key Column
    Select the referenced column from the foreign table.
  • 9. Foreign On Update
    Defines the behavior when the referenced record is updated.
  • 10. Foreign On Delete
    Defines the behavior when the referenced record is deleted.
  • 11. Sort
    Controls the order of fields within the table definition.
DB-Schema

At this stage, no database changes have been applied yet. You are only defining the schema structure.

DB-Schema

Apply Changes to Database

Once you finish defining tables and fields, you can apply the schema to the actual database.

DB-Schema
  • Apply to Database (Safe)
    Applies new tables and fields without physically deleting any existing database structures. Recommended for production environments.
  • Apply to Database (Force)
    Applies the schema exactly as defined, removing any deleted tables or fields from the database. Use only when you are certain no important data will be lost.

Automatic Relations

After applying the schema to the database, Sprintfy automatically generates model relations.

Any field defined as a foreign key will result in a corresponding relation being created automatically.

DB-Schema

These relations become available immediately for use in:

  • Dynamic APIs
  • CMS Pages
  • Dynamic Forms
  • Observers & Automations