Skip to content

ax.database

Source: gamemode/framework/libraries/sv_database.lua

Database management system for handling connections, schema definitions, and table creation.

Documented functions: 5

Functions


ax.database:AddToSchema(schemaType, field, fieldType)

Add a field to the database schema.

Adds a new field to a specified table schema, handling queuing if database isn't ready.

Realm: server

Parameters

Name Type Description
schemaType string The table name to add the field to
field string The field name to add
fieldType number The ax.type constant for the field type

Usage

ax.database:AddToSchema("ax_characters", "description", ax.type.text)

ax.database:Connect(module, hostname, user, password, database, port)

Connect to the database using specified parameters.

Establishes connection using mysqloo module with configurable database settings.

Realm: server

Parameters

Name Type Description
module string Database module type (default: "sqlite")
hostname string Database hostname (default: "localhost")
user string Database username (default: "root")
password string Database password (default: "")
database string Database name (default: "parallax")
port number Database port (default: 3306)

Usage

ax.database:Connect("mysql", "localhost", "user", "pass", "gamedb")

ax.database:CreateTables()

Create the default database tables for the framework.

Sets up schema tracking, players, characters, and inventories tables.

Realm: server

Usage

ax.database:CreateTables()

ax.database:InsertSchema(schemaType, field, fieldType, callback)

Insert a field into the database schema (internal use).

Directly modifies database schema and table structure.

Realm: server

Parameters

Name Type Description
schemaType string The table name
field string The field name
fieldType number The ax.type constant for the field type
callback function Optional callback to run when schema insert completes

Usage

ax.database:InsertSchema("ax_characters", "description", ax.type.text)

ax.database:MigrateLegacyInventoryOwners(callback)

Back-compat migration: populate owner_kind/owner_id on inventory rows that predate the

ownership model. Older installs linked a character to its inventory only through the legacy

ax_characters.inventory column; the type/ownership rewrite loads inventories by

owner_kind/owner_id instead (see ax.inventory:Restore/RestoreOwner), so those pre-existing

rows - owner columns NULL after the additive ALTER - would never load and every character

would report no valid inventory. This copies each character's legacy link into the owner

columns.

Realm: server

Parameters

Name Type Description
callback function Optional callback run once when the migration has finished dispatching.

Usage

ax.database:MigrateLegacyInventoryOwners()