glimr/db/gen/schema_parser
Schema Parser
Parses schema.gleam files to extract table definitions. This parser handles the list-based schema definition format:
table(name, [ id(), string(“name”), string(“bio”) |> nullable(), boolean(“is_active”) |> default(DefaultBool(True)), timestamps(), ])
Types
Represents a database column with its name, type, nullability, default value, and optional rename tracking.
pub type Column {
Column(
name: String,
column_type: ColumnType,
nullable: Bool,
default: option.Option(DefaultValue),
renamed_from: option.Option(String),
)
}
Constructors
-
Column( name: String, column_type: ColumnType, nullable: Bool, default: option.Option(DefaultValue), renamed_from: option.Option(String), )
Represents the data type of a column. Maps to appropriate SQL types for each database driver.
pub type ColumnType {
Id
String
Text
Int
BigInt
Float
Boolean
Timestamp
UnixTimestamp
Date
Json
Uuid
Foreign(String)
}
Constructors
-
Id -
String -
Text -
Int -
BigInt -
Float -
Boolean -
Timestamp -
UnixTimestamp -
Date -
Json -
Uuid -
Foreign(String)
Represents the default value for a column. Supports boolean, string, integer, float, current timestamp, current unix timestamp, and null defaults.
pub type DefaultValue {
DefaultBool(Bool)
DefaultString(String)
DefaultInt(Int)
DefaultFloat(Float)
DefaultNow
DefaultUnixNow
DefaultAutoUuid
DefaultNull
}
Constructors
-
DefaultBool(Bool) -
DefaultString(String) -
DefaultInt(Int) -
DefaultFloat(Float) -
DefaultNow -
DefaultUnixNow -
DefaultAutoUuid -
DefaultNull