Databases
RQLite
Column Types

RQLite Column Types

RQLite uses SQLite as its storage engine, so it inherits SQLite's dynamic type system (type affinity). SchemaHero passes your type declarations directly to RQLite.

Type Affinity

RQLite/SQLite determines storage based on type affinity rules:

AffinityType NamesStorage
INTEGERint, integer, tinyint, smallint, mediumint, bigint, int2, int8Signed integer (1, 2, 3, 4, 6, or 8 bytes)
TEXTtext, char, varchar, clob, character, nchar, nvarcharUTF-8, UTF-16BE, or UTF-16LE string
REALreal, float, double, double precision8-byte IEEE floating point
BLOBblobRaw binary data
NUMERICnumeric, decimal, boolean, date, datetimeInteger or real depending on value

Common Types

columns:
  # Integer types
  - name: id
    type: integer
  - name: count
    type: int
  - name: big_num
    type: bigint
 
  # Text types
  - name: name
    type: text
  - name: code
    type: varchar(10)
 
  # Real types
  - name: price
    type: real
  - name: rate
    type: double
 
  # Binary
  - name: data
    type: blob
 
  # Numeric affinity
  - name: amount
    type: numeric
  - name: active
    type: boolean

Type Flexibility

Since RQLite uses SQLite's dynamic typing, SchemaHero accepts any type name:

columns:
  - name: created_at
    type: datetime        # Stored as TEXT, REAL, or INTEGER
  - name: price
    type: decimal(10,2)   # Stored as NUMERIC affinity
  - name: flag
    type: boolean         # Stored as NUMERIC (0 or 1)

Auto-Increment

Auto-increment only works with INTEGER PRIMARY KEY:

schema:
  rqlite:
    primaryKey: [id]
    columns:
      - name: id
        type: integer
        attributes:
          autoIncrement: true

Examples

columns:
  - name: id
    type: integer
    attributes:
      autoIncrement: true
  - name: email
    type: text
    constraints:
      notNull: true
  - name: name
    type: varchar(100)
  - name: active
    type: boolean
    default: "1"
  - name: price
    type: real
  - name: data
    type: blob
  - name: created_at
    type: text
    default: current_timestamp

Notes

  • RQLite inherits all SQLite type behavior
  • Type constraints are not enforced by default
  • Distributed queries are executed on the leader node
  • Data is replicated across the cluster automatically