diff --git a/src-electron/db/zap-schema.sql b/src-electron/db/zap-schema.sql index 2e1f112f53..29b4a84def 100644 --- a/src-electron/db/zap-schema.sql +++ b/src-electron/db/zap-schema.sql @@ -36,7 +36,7 @@ CREATE TABLE "PACKAGE" ( "VERSION" integer, "CATEGORY" text, "DESCRIPTION" text, - foreign key (PARENT_PACKAGE_REF) references PACKAGE(PACKAGE_ID) + foreign key (PARENT_PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* PACKAGE_OPTION table contains generic 'options' that are encoded from within each packages. @@ -48,7 +48,7 @@ CREATE TABLE "PACKAGE_OPTION" ( "OPTION_CATEGORY" text, "OPTION_CODE" text, "OPTION_LABEL" text, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE(PACKAGE_REF, OPTION_CATEGORY, OPTION_CODE, OPTION_LABEL) ); /* @@ -60,8 +60,8 @@ CREATE TABLE "PACKAGE_OPTION_DEFAULT" ( "PACKAGE_REF" integer, "OPTION_CATEGORY" text, "OPTION_REF" integer, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, - foreign key (OPTION_REF) references PACKAGE_OPTION(OPTION_ID) on delete cascade, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (OPTION_REF) references PACKAGE_OPTION(OPTION_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE(PACKAGE_REF, OPTION_CATEGORY) ); /* @@ -78,7 +78,7 @@ CREATE TABLE "PACKAGE_EXTENSION" ( "CONFIGURABILITY" text, "LABEL" text, "GLOBAL_DEFAULT" text, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE(PACKAGE_REF, ENTITY, PROPERTY) ); /* @@ -93,7 +93,7 @@ CREATE TABLE "PACKAGE_EXTENSION_DEFAULT" ( "PARENT_CODE" integer, "MANUFACTURER_CODE" integer, "VALUE" text, - foreign key (PACKAGE_EXTENSION_REF) references PACKAGE_EXTENSION(PACKAGE_EXTENSION_ID) on delete cascade + foreign key (PACKAGE_EXTENSION_REF) references PACKAGE_EXTENSION(PACKAGE_EXTENSION_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* * @@ -116,7 +116,7 @@ CREATE TABLE IF NOT EXISTS "SPEC" ( "CODE" text NOT NULL, "DESCRIPTION" text, "CERTIFIABLE" integer, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE(PACKAGE_REF, CODE) ); /* @@ -128,8 +128,8 @@ CREATE TABLE IF NOT EXISTS "DOMAIN" ( "PACKAGE_REF" integer, "NAME" text, "LATEST_SPEC_REF" integer, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, - foreign key (LATEST_SPEC_REF) references SPEC(SPEC_ID), + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (LATEST_SPEC_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE(PACKAGE_REF, NAME) ); /* @@ -150,9 +150,9 @@ CREATE TABLE IF NOT EXISTS "CLUSTER" ( "INTRODUCED_IN_REF" integer, "REMOVED_IN_REF" integer, "API_MATURITY" text, - foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID), - foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID), - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade + foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* COMMAND table contains commands contained inside a cluster. @@ -175,11 +175,11 @@ CREATE TABLE IF NOT EXISTS "COMMAND" ( "RESPONSE_NAME" integer, "RESPONSE_REF" integer, "IS_DEFAULT_RESPONSE_ENABLED" integer, - foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID), - foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID), - foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID), - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, - foreign key (RESPONSE_REF) references COMMAND(COMMAND_ID) + foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (RESPONSE_REF) references COMMAND(COMMAND_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* COMMAND_ARG table contains arguments for a command. @@ -201,9 +201,9 @@ CREATE TABLE IF NOT EXISTS "COMMAND_ARG" ( "COUNT_ARG" text, "INTRODUCED_IN_REF" integer, "REMOVED_IN_REF" integer, - foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID), - foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID), - foreign key (COMMAND_REF) references COMMAND(COMMAND_ID) on delete cascade + foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (COMMAND_REF) references COMMAND(COMMAND_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* EVENT table contains events for a given cluster. @@ -223,10 +223,10 @@ CREATE TABLE IF NOT EXISTS "EVENT" ( "PRIORITY" text, "INTRODUCED_IN_REF" integer, "REMOVED_IN_REF" integer, - foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID), - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, - foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID), - foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) + foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* EVENT_FIELD table contains events for a given cluster. @@ -242,9 +242,9 @@ CREATE TABLE IF NOT EXISTS "EVENT_FIELD" ( "IS_OPTIONAL" integer, "INTRODUCED_IN_REF" integer, "REMOVED_IN_REF" integer, - foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID), - foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID), - foreign key (EVENT_REF) references EVENT(EVENT_ID) on delete cascade + foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (EVENT_REF) references EVENT(EVENT_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* ATTRIBUTE table contains attributes for the cluster. @@ -280,10 +280,10 @@ CREATE TABLE IF NOT EXISTS "ATTRIBUTE" ( "INTRODUCED_IN_REF" integer, "REMOVED_IN_REF" integer, "API_MATURITY" text, - foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID), - foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID), - foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID), - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade + foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE UNIQUE("CLUSTER_REF", "PACKAGE_REF", "CODE", "MANUFACTURER_CODE") ); @@ -295,8 +295,8 @@ CREATE TABLE IF NOT EXISTS "ATTRIBUTE_MAPPING" ( "ATTRIBUTE_MAPPING_ID" integer primary key autoincrement, "ATTRIBUTE_LEFT_REF" integer, "ATTRIBUTE_RIGHT_REF" integer, - foreign key (ATTRIBUTE_LEFT_REF) references ATTRIBUTE(ATTRIBUTE_ID) on delete cascade, - foreign key (ATTRIBUTE_RIGHT_REF) references ATTRIBUTE(ATTRIBUTE_ID) on delete cascade + foreign key (ATTRIBUTE_LEFT_REF) references ATTRIBUTE(ATTRIBUTE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (ATTRIBUTE_RIGHT_REF) references ATTRIBUTE(ATTRIBUTE_ID) ON DELETE CASCADE ON UPDATE CASCADE UNIQUE("ATTRIBUTE_LEFT_REF", "ATTRIBUTE_RIGHT_REF") ); /* @@ -315,8 +315,8 @@ CREATE TABLE IF NOT EXISTS "GLOBAL_ATTRIBUTE_DEFAULT" ( "CLUSTER_REF" integer NOT NULL, "ATTRIBUTE_REF" integer NOT NULL, "DEFAULT_VALUE" text, - foreign key(CLUSTER_REF) references CLUSTER(CLUSTER_ID), - foreign key(ATTRIBUTE_REF) references ATTRIBUTE(ATTRIBUTE_ID) on delete cascade + foreign key(CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key(ATTRIBUTE_REF) references ATTRIBUTE(ATTRIBUTE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* GLOBAL_ATTRIBUTE_BIT is carrying information about the mappings of a @@ -332,8 +332,8 @@ CREATE TABLE IF NOT EXISTS "GLOBAL_ATTRIBUTE_BIT" ( "BIT" integer NOT NULL, "VALUE" integer, "TAG_REF" integer NOT NULL, - foreign key(GLOBAL_ATTRIBUTE_DEFAULT_REF) references GLOBAL_ATTRIBUTE_DEFAULT(GLOBAL_ATTRIBUTE_DEFAULT_ID) on delete cascade, - foreign key(TAG_REF) references TAG(TAG_ID) + foreign key(GLOBAL_ATTRIBUTE_DEFAULT_REF) references GLOBAL_ATTRIBUTE_DEFAULT(GLOBAL_ATTRIBUTE_DEFAULT_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key(TAG_REF) references TAG(TAG_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* DEVICE_TYPE table contains device types directly loaded from packages. @@ -350,7 +350,7 @@ CREATE TABLE IF NOT EXISTS "DEVICE_TYPE" ( "CLASS" text, "SCOPE" text, "SUPERSET" text, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* DEVICE_TYPE_CLUSTER contains clusters that belong to the device type. @@ -365,8 +365,8 @@ CREATE TABLE IF NOT EXISTS "DEVICE_TYPE_CLUSTER" ( "INCLUDE_SERVER" integer, "LOCK_CLIENT" integer, "LOCK_SERVER" integer, - foreign key (DEVICE_TYPE_REF) references DEVICE_TYPE(DEVICE_TYPE_ID) on delete cascade, - foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID) + foreign key (DEVICE_TYPE_REF) references DEVICE_TYPE(DEVICE_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* @@ -378,8 +378,8 @@ CREATE TABLE IF NOT EXISTS "DEVICE_TYPE_FEATURE" ( "DEVICE_TYPE_CLUSTER_REF" integer, "FEATURE_REF" integer, "FEATURE_CODE" text, - foreign key (DEVICE_TYPE_CLUSTER_REF) references DEVICE_TYPE_CLUSTER(DEVICE_TYPE_CLUSTER_ID) on delete cascade, - foreign key (FEATURE_REF) references FEATURE(FEATURE_ID) on delete cascade + foreign key (DEVICE_TYPE_CLUSTER_REF) references DEVICE_TYPE_CLUSTER(DEVICE_TYPE_CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (FEATURE_REF) references FEATURE(FEATURE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); @@ -397,8 +397,8 @@ CREATE TABLE IF NOT EXISTS "FEATURE" ( "CONFORMANCE" text, "PACKAGE_REF" integer, "CLUSTER_REF" integer, - foreign key(PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, - foreign key(CLUSTER_REF) references CLUSTER(CLUSTER_ID) on delete cascade + foreign key(PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key(CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* @@ -409,8 +409,8 @@ CREATE TABLE IF NOT EXISTS "DEVICE_TYPE_ATTRIBUTE" ( "DEVICE_TYPE_CLUSTER_REF" integer, "ATTRIBUTE_REF" integer, "ATTRIBUTE_NAME" text, - foreign key (DEVICE_TYPE_CLUSTER_REF) references DEVICE_TYPE_CLUSTER(DEVICE_TYPE_CLUSTER_ID) on delete cascade, - foreign key (ATTRIBUTE_REF) references ATTRIBUTE(ATTRIBUTE_ID) on delete cascade + foreign key (DEVICE_TYPE_CLUSTER_REF) references DEVICE_TYPE_CLUSTER(DEVICE_TYPE_CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (ATTRIBUTE_REF) references ATTRIBUTE(ATTRIBUTE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* DEVICE_TYPE_COMMAND contains attributes that belong to a device type cluster. @@ -420,8 +420,8 @@ CREATE TABLE IF NOT EXISTS "DEVICE_TYPE_COMMAND" ( "DEVICE_TYPE_CLUSTER_REF" integer, "COMMAND_REF" integer, "COMMAND_NAME" text, - foreign key (DEVICE_TYPE_CLUSTER_REF) references DEVICE_TYPE_CLUSTER(DEVICE_TYPE_CLUSTER_ID) on delete cascade, - foreign key (COMMAND_REF) references COMMAND(COMMAND_ID) on delete cascade + foreign key (DEVICE_TYPE_CLUSTER_REF) references DEVICE_TYPE_CLUSTER(DEVICE_TYPE_CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (COMMAND_REF) references COMMAND(COMMAND_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* TAG table contains tags. They can be used for access control and feature maps. @@ -433,8 +433,8 @@ CREATE TABLE IF NOT EXISTS "TAG" ( "CLUSTER_REF" integer, "NAME" text, "DESCRIPTION" text, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, - foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID) on delete cascade + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* * @@ -458,7 +458,7 @@ CREATE TABLE IF NOT EXISTS "DISCRIMINATOR" ( "DISCRIMINATOR_ID" integer NOT NULL PRIMARY KEY autoincrement, "NAME" text, "PACKAGE_REF" integer, - FOREIGN KEY (PACKAGE_REF) REFERENCES PACKAGE(PACKAGE_ID), + FOREIGN KEY (PACKAGE_REF) REFERENCES PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT DISCRIMINATOR_INFO UNIQUE("NAME", "PACKAGE_REF") ); /* @@ -527,7 +527,7 @@ CREATE TABLE IF NOT EXISTS "ATOMIC" ( "IS_LONG" integer default false, "IS_CHAR" integer default false, "IS_SIGNED" integer default false, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* BITMAP table contains the bitmaps directly loaded from packages. @@ -549,7 +549,7 @@ CREATE TABLE IF NOT EXISTS BITMAP_FIELD ( NAME text(100), MASK integer, TYPE text(100), - FOREIGN KEY (BITMAP_REF) REFERENCES BITMAP(BITMAP_ID) + FOREIGN KEY (BITMAP_REF) REFERENCES BITMAP(BITMAP_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* ENUM table contains enums directly loaded from packages. @@ -581,7 +581,7 @@ CREATE TABLE IF NOT EXISTS STRUCT ( STRUCT_ID integer NOT NULL PRIMARY KEY, IS_FABRIC_SCOPED integer, SIZE integer, - FOREIGN KEY (STRUCT_ID) REFERENCES DATA_TYPE(DATA_TYPE_ID) + FOREIGN KEY (STRUCT_ID) REFERENCES DATA_TYPE(DATA_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* STRUCT_ITEM table contains individual struct items. @@ -621,7 +621,7 @@ CREATE TABLE IF NOT EXISTS "OPERATION" ( "PACKAGE_REF" integer, "NAME" text, "DESCRIPTION" text, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS "ROLE"; CREATE TABLE IF NOT EXISTS "ROLE" ( @@ -630,7 +630,7 @@ CREATE TABLE IF NOT EXISTS "ROLE" ( "LEVEL" integer, "NAME" text, "DESCRIPTION" text, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS "ACCESS_MODIFIER"; CREATE TABLE IF NOT EXISTS "ACCESS_MODIFIER" ( @@ -638,7 +638,7 @@ CREATE TABLE IF NOT EXISTS "ACCESS_MODIFIER" ( "PACKAGE_REF" integer, "NAME" text, "DESCRIPTION" text, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS "ACCESS"; CREATE TABLE IF NOT EXISTS "ACCESS" ( @@ -646,45 +646,45 @@ CREATE TABLE IF NOT EXISTS "ACCESS" ( "OPERATION_REF" integer, "ROLE_REF" integer, "ACCESS_MODIFIER_REF" integer, - foreign key (OPERATION_REF) references OPERATION(OPERATION_ID), - foreign key (ROLE_REF) references ROLE(ROLE_ID), - foreign key (ACCESS_MODIFIER_REF) references ACCESS_MODIFIER(ACCESS_MODIFIER_ID) + foreign key (OPERATION_REF) references OPERATION(OPERATION_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (ROLE_REF) references ROLE(ROLE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (ACCESS_MODIFIER_REF) references ACCESS_MODIFIER(ACCESS_MODIFIER_ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS "CLUSTER_ACCESS"; CREATE TABLE IF NOT EXISTS "CLUSTER_ACCESS" ( "CLUSTER_REF" integer, "ACCESS_REF" integer, - foreign key(ACCESS_REF) references ACCESS(ACCESS_ID), - foreign key(CLUSTER_REF) references CLUSTER(CLUSTER_ID) + foreign key(ACCESS_REF) references ACCESS(ACCESS_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key(CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS "ATTRIBUTE_ACCESS"; CREATE TABLE IF NOT EXISTS "ATTRIBUTE_ACCESS" ( "ATTRIBUTE_REF" integer, "ACCESS_REF" integer, - foreign key(ACCESS_REF) references ACCESS(ACCESS_ID), - foreign key(ATTRIBUTE_REF) references ATTRIBUTE(ATTRIBUTE_ID) + foreign key(ACCESS_REF) references ACCESS(ACCESS_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key(ATTRIBUTE_REF) references ATTRIBUTE(ATTRIBUTE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS "COMMAND_ACCESS"; CREATE TABLE IF NOT EXISTS "COMMAND_ACCESS" ( "COMMAND_REF" integer, "ACCESS_REF" integer, - foreign key(ACCESS_REF) references ACCESS(ACCESS_ID), - foreign key(COMMAND_REF) references COMMAND(COMMAND_ID) + foreign key(ACCESS_REF) references ACCESS(ACCESS_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key(COMMAND_REF) references COMMAND(COMMAND_ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS "EVENT_ACCESS"; CREATE TABLE IF NOT EXISTS "EVENT_ACCESS" ( "EVENT_REF" integer, "ACCESS_REF" integer, - foreign key(ACCESS_REF) references ACCESS(ACCESS_ID), - foreign key(EVENT_REF) references EVENT(EVENT_ID) + foreign key(ACCESS_REF) references ACCESS(ACCESS_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key(EVENT_REF) references EVENT(EVENT_ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS "DEFAULT_ACCESS"; CREATE TABLE IF NOT EXISTS "DEFAULT_ACCESS" ( "PACKAGE_REF" integer, "ENTITY_TYPE" text, "ACCESS_REF" integer, - foreign key(ACCESS_REF) references ACCESS(ACCESS_ID), - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade + foreign key(ACCESS_REF) references ACCESS(ACCESS_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* * @@ -721,7 +721,7 @@ CREATE TABLE IF NOT EXISTS "SESSION" ( "CREATION_TIME" integer, "DIRTY" integer default 1, "NEW_NOTIFICATION" integer default 0, - foreign key (USER_REF) references USER(USER_ID), + foreign key (USER_REF) references USER(USER_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE(SESSION_KEY) ); /* @@ -733,7 +733,7 @@ CREATE TABLE IF NOT EXISTS "SESSION_KEY_VALUE" ( "SESSION_REF" integer, "KEY" text, "VALUE" text, - foreign key (SESSION_REF) references SESSION(SESSION_ID) on delete cascade, + foreign key (SESSION_REF) references SESSION(SESSION_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE(SESSION_REF, KEY) ); /* @@ -744,7 +744,7 @@ CREATE TABLE IF NOT EXISTS "SESSION_LOG" ( "SESSION_REF" integer, "TIMESTAMP" text, "LOG" text, - foreign key (SESSION_REF) references SESSION(SESSION_ID) on delete cascade + foreign key (SESSION_REF) references SESSION(SESSION_ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS "SESSION_PARTITION"; @@ -752,7 +752,7 @@ CREATE TABLE IF NOT EXISTS "SESSION_PARTITION" ( "SESSION_PARTITION_ID" integer primary key autoincrement, "SESSION_PARTITION_NUMBER" integer, "SESSION_REF" integer, - foreign key (SESSION_REF) references SESSION(SESSION_ID) on delete cascade + foreign key (SESSION_REF) references SESSION(SESSION_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* @@ -765,8 +765,8 @@ CREATE TABLE IF NOT EXISTS "SESSION_PACKAGE" ( "PACKAGE_REF" integer, "REQUIRED" integer default false, "ENABLED" integer default true, - foreign key (SESSION_PARTITION_REF) references SESSION_PARTITION(SESSION_PARTITION_ID) on delete cascade, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade, + foreign key (SESSION_PARTITION_REF) references SESSION_PARTITION(SESSION_PARTITION_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE(SESSION_PARTITION_REF, PACKAGE_REF) ); /* @@ -777,7 +777,7 @@ CREATE TABLE IF NOT EXISTS "ENDPOINT_TYPE" ( "ENDPOINT_TYPE_ID" integer primary key autoincrement, "SESSION_PARTITION_REF" integer, "NAME" text, - foreign key (SESSION_PARTITION_REF) references SESSION_PARTITION(SESSION_PARTITION_ID) on delete cascade + foreign key (SESSION_PARTITION_REF) references SESSION_PARTITION(SESSION_PARTITION_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* ENDPOINT_TYPE_DEVICE: many-to-many relationship between endpoint type and @@ -791,9 +791,9 @@ CREATE TABLE IF NOT EXISTS "ENDPOINT_TYPE_DEVICE" ( "DEVICE_TYPE_ORDER" INTEGER, "DEVICE_IDENTIFIER" INTEGER, "DEVICE_VERSION" INTEGER, - foreign key(DEVICE_TYPE_REF) references DEVICE_TYPE(DEVICE_TYPE_ID) on delete cascade, + foreign key(DEVICE_TYPE_REF) references DEVICE_TYPE(DEVICE_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE, foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) on delete - set NULL, + set NULL ON UPDATE CASCADE, UNIQUE("ENDPOINT_TYPE_REF", "DEVICE_TYPE_REF") ); /** @@ -865,10 +865,10 @@ CREATE TABLE IF NOT EXISTS "ENDPOINT" ( "ENDPOINT_IDENTIFIER" integer, "NETWORK_IDENTIFIER" integer, "PARENT_ENDPOINT_REF" integer NULL, - foreign key (SESSION_REF) references SESSION(SESSION_ID) on delete cascade, - foreign key (PARENT_ENDPOINT_REF) references ENDPOINT(ENDPOINT_ID) on delete set NULL, + foreign key (SESSION_REF) references SESSION(SESSION_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (PARENT_ENDPOINT_REF) references ENDPOINT(ENDPOINT_ID) on delete set NULL ON UPDATE CASCADE, foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) on delete - set NULL + set NULL ON UPDATE CASCADE ); /* SESSION_CLUSTER contains the on/off values for cluster. @@ -882,8 +882,8 @@ CREATE TABLE IF NOT EXISTS "ENDPOINT_TYPE_CLUSTER" ( "CLUSTER_REF" integer, "SIDE" text, "ENABLED" integer default false, - foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) on delete cascade, - foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID), + foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE(ENDPOINT_TYPE_REF, CLUSTER_REF, SIDE) ); @@ -1211,9 +1211,9 @@ CREATE TABLE IF NOT EXISTS "ENDPOINT_TYPE_ATTRIBUTE" ( "MIN_INTERVAL" integer default 1, "MAX_INTERVAL" integer default 65534, "REPORTABLE_CHANGE" integer default 0, - foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) on delete cascade, - foreign key (ENDPOINT_TYPE_CLUSTER_REF) references ENDPOINT_TYPE_CLUSTER(ENDPOINT_TYPE_CLUSTER_ID), - foreign key (ATTRIBUTE_REF) references ATTRIBUTE(ATTRIBUTE_ID), + foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (ENDPOINT_TYPE_CLUSTER_REF) references ENDPOINT_TYPE_CLUSTER(ENDPOINT_TYPE_CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (ATTRIBUTE_REF) references ATTRIBUTE(ATTRIBUTE_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE( ENDPOINT_TYPE_REF, ATTRIBUTE_REF, @@ -1903,9 +1903,9 @@ CREATE TABLE IF NOT EXISTS "ENDPOINT_TYPE_COMMAND" ( "COMMAND_REF" integer, "IS_INCOMING" integer default false, "IS_ENABLED" integer default false, - foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) on delete cascade, - foreign key (ENDPOINT_TYPE_CLUSTER_REF) references ENDPOINT_TYPE_CLUSTER(ENDPOINT_TYPE_CLUSTER_ID), - foreign key (COMMAND_REF) references COMMAND(COMMAND_ID), + foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (ENDPOINT_TYPE_CLUSTER_REF) references ENDPOINT_TYPE_CLUSTER(ENDPOINT_TYPE_CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (COMMAND_REF) references COMMAND(COMMAND_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE( ENDPOINT_TYPE_REF, COMMAND_REF, @@ -2649,9 +2649,9 @@ CREATE TABLE IF NOT EXISTS "ENDPOINT_TYPE_EVENT" ( "ENDPOINT_TYPE_CLUSTER_REF" integer, "EVENT_REF" integer, "INCLUDED" integer default false, - foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) on delete cascade, - foreign key (ENDPOINT_TYPE_CLUSTER_REF) references ENDPOINT_TYPE_CLUSTER(ENDPOINT_TYPE_CLUSTER_ID), - foreign key (EVENT_REF) references EVENT(EVENT_ID), + foreign key (ENDPOINT_TYPE_REF) references ENDPOINT_TYPE(ENDPOINT_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (ENDPOINT_TYPE_CLUSTER_REF) references ENDPOINT_TYPE_CLUSTER(ENDPOINT_TYPE_CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (EVENT_REF) references EVENT(EVENT_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE( ENDPOINT_TYPE_REF, EVENT_REF, @@ -2670,8 +2670,8 @@ CREATE TABLE IF NOT EXISTS "PACKAGE_EXTENSION_VALUE" ( "ENTITY_CODE" integer, "PARENT_CODE" integer, "VALUE" text, - foreign key (PACKAGE_EXTENSION_REF) references PACKAGE_EXTENSION(PACKAGE_EXTENSION_ID) on delete cascade, - foreign key (SESSION_REF) references SESSION(SESSION_ID), + foreign key (PACKAGE_EXTENSION_REF) references PACKAGE_EXTENSION(PACKAGE_EXTENSION_ID) ON DELETE CASCADE ON UPDATE CASCADE, + foreign key (SESSION_REF) references SESSION(SESSION_ID) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE( PACKAGE_EXTENSION_REF, SESSION_REF, @@ -2990,7 +2990,7 @@ CREATE TABLE IF NOT EXISTS "SESSION_NOTICE" ( "NOTICE_ID" integer primary key autoincrement, "DISPLAY" integer, "SEEN" integer, - foreign key (SESSION_REF) references SESSION(SESSION_ID) on delete cascade + foreign key (SESSION_REF) references SESSION(SESSION_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* Trigger to prevent any null message entries into the session notice table during endpoint creation. @@ -3054,6 +3054,6 @@ CREATE TABLE IF NOT EXISTS "PACKAGE_NOTICE" ( "NOTICE_MESSAGE" text, "NOTICE_SEVERITY" integer, "NOTICE_ID" integer primary key autoincrement, - foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) on delete cascade + foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); /* EO SCHEMA */