Table Configuration - TheNewEconomy/TheNewDBUpdater GitHub Wiki

Table Configurations At A Glance

The table configurations itself are rather basic when compared to that of the columns. The main table configurations consist of two parts, the Settings and the Columns.

Diagram

Tables:
    NameOfTheTableMinusPrefix:

        #The columns for this table
        Columns:

        #The Settings for this table.
        Settings:
Settings:

  Prefix: "This is the prefix that will be placed in front of your tables, you may override this programmatically"

Columns

This essentially holds all the configurations making up your column. See "Configuring Your Columns" below for more about their specific variables.

Settings

For tables, there's 3 settings that are possible. Engine, Charset, and Collate.

  • Engine - The database engine to use, optional.
  • Charset - The default character set to use for the table, optional.
  • Collate - The default collation to use for the table, optional.

Example

Here's an example of some table settings.

    Settings:

      Engine: "INNODB"
      Charset: "utf8mb4"
      Collate: "utf8mb4_unicode_ci"

Configuring your Columns

Columns will make up the bulk of your tables yaml file. Their available configuration options are below, but only one setting, Type, is actually required for every column.

  • Type - The data type of this column(see below for available), required.
  • Increment - A boolean notating if this column should auto increment or not, optional.
  • Optional - A String containing the default value of the column, optional.
  • Length - The max length for this column's data, optional.
  • Null - A boolean telling if this column can accept null values or not, optional.
  • Primary - A boolean notating if this column is a Primary Key, optional.
  • Unique - A boolean notating if this column is Unique, optional.
  • Scale - When using the decimal data type, this is the amount of numbers kept after the period, optional.

Example

Let's take a look at some example columns:


      id:

        Type: "INTEGER"

        Length: 10

        Primary: true

        Increment: true

        Null: false

      trans_id:

        Type: "VARCHAR"

        Length: 36

        Null: false

        Primary: true

      balance:

        Type: "DECIMAL"

        Length: 49

        Scale: 4

Valid Data Types

TYPE Shortcuts
TINYINT TI
SMALLINT SI
INTEGER INT, I
BIGINT BI
DECIMAL
NUMERIC
FLOAT
REAL
BOOLEAN
VARCHAR
TEXT