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:
| Affinity | Type Names | Storage |
|---|---|---|
| INTEGER | int, integer, tinyint, smallint, mediumint, bigint, int2, int8 | Signed integer (1, 2, 3, 4, 6, or 8 bytes) |
| TEXT | text, char, varchar, clob, character, nchar, nvarchar | UTF-8, UTF-16BE, or UTF-16LE string |
| REAL | real, float, double, double precision | 8-byte IEEE floating point |
| BLOB | blob | Raw binary data |
| NUMERIC | numeric, decimal, boolean, date, datetime | Integer 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: booleanType 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: trueExamples
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_timestampNotes
- 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