* Updated the SQL schema to convert all 'boolean' to 'integer' (using 0 for false). Also made all columns NOT NULL, given they should all always have an empty string. The logic behind this was to standardize the code and avoid bugs.
-- each that you plan to link, still use a '*_host_uuid' column (if the data is host-specific). This is
-- needed by the resync method.
-- COLUMN TYPE NOTE!
--
-- To minimize the risk of coding errors translating NULL (versus "") or boolean (1 vs TRUE) in the code and
-- agents, it is recommended to use only 'text' and '[big]int' column types, and that all columns have the
-- 'NOT NULL' constraint. This is a recommendation, not a hard requirement. Remember, reliability comes from
-- simplicity and consistency!
--
-- COLUMN TYPE NOTE!
SETclient_encoding='UTF8';
-- This doesn't work before 9.3 - CREATE SCHEMA IF NOT EXISTS history;
@ -48,9 +57,9 @@ CREATE TABLE users (
user_algorithmtextnotnull,-- This is the algorithm used to encrypt the password and salt.
user_hash_counttextnotnull,-- This is the number of times that the password+salt was re-hashed through the algorithm.
user_languagetextnotnull,-- If set, this will choose a different language over the default.
user_is_adminbooleannotnulldefaultfalse,-- If true, all aspects of the program are available to the user.
user_is_experiencedbooleannotnulldefaultfalse,-- If true, user is allowed to delete a server, alter disk size, alter hardware and do other potentially risky things. They will also get fewer confirmation dialogues.
user_is_trustedbooleannotnulldefaultfalse,-- If true, user is allowed to do things that would cause interruptions, like force-reset and gracefully stop servers, withdraw nodes, and stop the Anvil! entirely.
user_is_adminintegernotnulldefault0,-- If 1, all aspects of the program are available to the user.
user_is_experiencedintegernotnulldefault0,-- If 1, user is allowed to delete a server, alter disk size, alter hardware and do other potentially risky things. They will also get fewer confirmation dialogues.
user_is_trustedintegernotnulldefault0,-- If 1, user is allowed to do things that would cause interruptions, like force-reset and gracefully stop servers, withdraw nodes, and stop the Anvil! entirely.
modified_datetimestampwithtimezonenotnull
);
ALTERTABLEusersOWNERTO#!variable!user!#;
@ -64,9 +73,9 @@ CREATE TABLE history.users (
user_algorithmtext,
user_hash_counttext,
user_languagetext,
user_is_adminboolean,
user_is_experiencedboolean,
user_is_trustedboolean,
user_is_admininteger,
user_is_experiencedinteger,
user_is_trustedinteger,
modified_datetimestampwithtimezonenotnull
);
ALTERTABLEhistory.usersOWNERTO#!variable!user!#;
@ -164,14 +173,14 @@ CREATE TABLE host_variable (
host_variable_uuiduuidnotnullprimarykey,-- This is the single most important record in ScanCore. Everything links back to here.
alert_title_keytextnotnull,-- ScanCore will read in the agents <name>.xml words file and look for this message key
alert_title_variablestext,-- List of variables to substitute into the message key. Format is 'var1=val1 #!# var2 #!# val2 #!# ... #!# varN=valN'.
alert_title_variablestextnotnull,-- List of variables to substitute into the message key. Format is 'var1=val1 #!# var2 #!# val2 #!# ... #!# varN=valN'.
alert_message_keytextnotnull,-- ScanCore will read in the agents <name>.xml words file and look for this message key
alert_message_variablestext,-- List of variables to substitute into the message key. Format is 'var1=val1 #!# var2 #!# val2 #!# ... #!# varN=valN'.
alert_sorttext,-- The alerts will sort on this column. It allows for an optional sorting of the messages in the alert.
alert_headerbooleannotnulldefaultTRUE,-- This can be set to have the alert be printed with only the contents of the string, no headers.
alert_message_variablestextnotnull,-- List of variables to substitute into the message key. Format is 'var1=val1 #!# var2 #!# val2 #!# ... #!# varN=valN'.
alert_sorttextnotnull,-- The alerts will sort on this column. It allows for an optional sorting of the messages in the alert.
alert_headerintegernotnulldefault1,-- This can be set to have the alert be printed with only the contents of the string, no headers.
variable_nametextnotnull,-- This is the 'x::y::z' style variable name.
variable_valuetext,-- It is up to the software to sanity check variable values before they are stored
variable_defaulttext,-- This acts as a reference for the user should they want to roll-back changes.
variable_descriptiontext,-- This is a string key that describes this variable's use.
variable_sectiontext,-- This is a free-form field that is used when displaying the various entries to a user. This allows for the various variables to be grouped into sections.
variable_source_uuidtext,-- Optional; Marks the variable as belonging to a specific X_uuid, where 'X' is a table name set in 'variable_source_table'
variable_source_tabletext,-- Optional; Marks the database table corresponding to the 'variable_source_uuid' value.
variable_valuetextnotnull,-- It is up to the software to sanity check variable values before they are stored
variable_defaulttextnotnull,-- This acts as a reference for the user should they want to roll-back changes.
variable_descriptiontextnotnull,-- This is a string key that describes this variable's use.
variable_sectiontextnotnull,-- This is a free-form field that is used when displaying the various entries to a user. This allows for the various variables to be grouped into sections.
variable_source_uuidtextnotnull,-- Optional; Marks the variable as belonging to a specific X_uuid, where 'X' is a table name set in 'variable_source_table'
variable_source_tabletextnotnull,-- Optional; Marks the database table corresponding to the 'variable_source_uuid' value.
modified_datetimestampwithtimezonenotnull
);
ALTERTABLEvariablesOWNERTO#!variable!user!#;
@ -353,7 +362,7 @@ CREATE TABLE jobs (
job_uuiduuidnotnullprimarykey,--
job_host_uuiduuidnotnull,-- This is the host that requested the job
job_commandtextnotnull,-- This is the command to run (usually a shell call).
job_datatext,-- This is optional data to be used by anvil-data
job_datatextnotnull,-- This is optional data to be used by anvil-data
job_picked_up_bynumericnotnulldefault0,-- This is the PID of the 'anvil-jobs' script that picked up the job.
job_picked_up_atnumericnotnulldefault0,-- This is unix timestamp of when the job was picked up.
job_updatednumericnotnulldefault0,-- This is unix timestamp that is perdiodically updated for jobs that take a long time. It is used to help determine when a job is hung.
network_interface_nametextnotnull,-- This is the current name of the interface.
network_interface_speedbigintnotnull,-- This is the speed, in bits-per-second, of the interface.
network_interface_mtubigint,-- This is the MTU (Maximum Transmitable Size), in bytes, for this interface.
network_interface_mtubigintnotnull,-- This is the MTU (Maximum Transmitable Size), in bytes, for this interface.
network_interface_link_statetextnotnull,-- 0 or 1
network_interface_operationaltextnotnull,-- This is 'up', 'down' or 'unknown'
network_interface_duplextextnotnull,-- This is 'full', 'half' or 'unknown'
network_interface_mediumtext,-- This is 'tp' (twisted pair), 'fiber' or whatever they invent in the future.
network_interface_bond_uuiduuid,-- If this iface is in a bond, this will contain the 'bonds -> bond_uuid' that it is slaved to.
network_interface_bridge_uuiduuid,-- If this iface is attached to a bridge, this will contain the 'bridgess -> bridge_uuid' that it is connected to.
network_interface_mediumtextnotnull,-- This is 'tp' (twisted pair), 'fiber' or whatever they invent in the future.
network_interface_bond_uuiduuidnotnull,-- If this iface is in a bond, this will contain the 'bonds -> bond_uuid' that it is slaved to.
network_interface_bridge_uuiduuidnotnull,-- If this iface is attached to a bridge, this will contain the 'bridgess -> bridge_uuid' that it is connected to.
state_nametextnotnull,-- This is the name of the state (ie: 'migration', etc)
state_host_uuiduuidnotnull,-- The UUID of the machine that the state relates to. In migrations, this is the UUID of the target
state_notetext,-- This is a free-form note section that the application setting the state can use for extra information (like the name of the server being migrated)
state_notetextnotnull,-- This is a free-form note section that the application setting the state can use for extra information (like the name of the server being migrated)