CRM-16173 - xml/schema/Cxn - Schema + upgrade for storing connections
authorTim Otten <totten@civicrm.org>
Sun, 22 Mar 2015 05:55:21 +0000 (22:55 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 14 Jul 2015 04:00:06 +0000 (21:00 -0700)
.gitignore
CRM/Upgrade/Incremental/sql/4.6.5.mysql.tpl
xml/schema/Cxn/Cxn.xml [new file with mode: 0644]
xml/schema/Cxn/files.xml [new file with mode: 0644]
xml/schema/Schema.xml

index 2b816aa5a04e87d1010bfe04f285f9d776c25556..a4646d878137867f525a9fc8b2bd37bae2072097 100644 (file)
@@ -93,6 +93,7 @@ CRM/Core/DAO/Website.php
 CRM/Core/DAO/WordReplacement.php
 CRM/Core/DAO/Worldregion.php
 CRM/Core/I18n/SchemaStructure.php
+CRM/Cxn/DAO
 CRM/Dedupe/DAO
 CRM/Event/Cart/DAO
 CRM/Event/DAO
index 32f4a6952d8d65a8bef9a289e48ac81f80fe096e..dff020fd354f4e3c299ca7e8404f3e68b4c536ab 100644 (file)
@@ -1,4 +1,27 @@
 {* file to handle db changes in 4.6.5 during upgrade *}
+
+-- CRM-16173
+CREATE TABLE `civicrm_cxn` (
+     `id` int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'Connection ID',
+     `app_guid` varchar(128)    COMMENT 'Application GUID',
+     `app_meta` text    COMMENT 'Application Metadata (JSON)',
+     `cxn_guid` varchar(128)    COMMENT 'Connection GUID',
+     `secret` text    COMMENT 'Shared secret',
+     `perm` text    COMMENT 'Permissions approved for the service (JSON)',
+     `options` text    COMMENT 'Options for the service (JSON)',
+     `is_active` tinyint   DEFAULT 1 COMMENT 'Is connection currently enabled?',
+     `created_date` timestamp NULL  DEFAULT NULL COMMENT 'When was the connection was created.',
+     `modified_date` timestamp NULL  DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the connection was created or modified.',
+     `fetched_date` timestamp NULL  DEFAULT NULL COMMENT 'The last time the application metadata was fetched.' ,
+    PRIMARY KEY ( `id` )
+    ,     UNIQUE INDEX `UI_appid`(
+        app_guid
+  )
+  ,     UNIQUE INDEX `UI_keypair_cxnid`(
+        cxn_guid
+  )
+)  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;
+
 -- CRM-16417 add failed payment activity type
 SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
 SELECT @option_group_id_act_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
diff --git a/xml/schema/Cxn/Cxn.xml b/xml/schema/Cxn/Cxn.xml
new file mode 100644 (file)
index 0000000..8d945de
--- /dev/null
@@ -0,0 +1,111 @@
+<table>
+  <base>CRM/Cxn</base>
+  <class>Cxn</class>
+  <name>civicrm_cxn</name>
+  <add>4.6</add>
+  <field>
+    <name>id</name>
+    <type>int unsigned</type>
+    <required>true</required>
+    <comment>Connection ID</comment>
+    <add>4.6</add>
+  </field>
+  <primaryKey>
+    <name>id</name>
+    <autoincrement>false</autoincrement>
+  </primaryKey>
+
+  <!-- Application identification -->
+
+  <field>
+    <name>app_id</name>
+    <title>Application GUID</title>
+    <type>varchar</type>
+    <length>128</length>
+    <comment>Application GUID</comment>
+    <add>4.6</add>
+  </field>
+  <index>
+    <name>UI_appid</name>
+    <fieldName>app_id</fieldName>
+    <unique>true</unique>
+    <add>4.6</add>
+  </index>
+  <field>
+    <name>app_meta</name>
+    <title>Application Metadata (JSON)</title>
+    <type>text</type>
+    <comment>Application Metadata (JSON)</comment>
+    <add>4.6</add>
+  </field>
+
+  <!-- Connection details -->
+  
+  <field>
+    <name>cxn_id</name>
+    <title>Connection GUID</title>
+    <type>varchar</type>
+    <length>128</length>
+    <comment>Connection GUID</comment>
+    <add>4.6</add>
+  </field>
+  <index>
+    <name>UI_keypair_cxnid</name>
+    <fieldName>cxn_id</fieldName>
+    <unique>true</unique>
+    <add>4.6</add>
+  </index>
+  <field>
+    <name>secret</name>
+    <type>text</type>
+    <comment>Shared secret</comment>
+    <add>4.6</add>
+  </field>
+  <field>
+    <name>perm</name>
+    <type>text</type>
+    <comment>Permissions approved for the service (JSON)</comment>
+    <add>4.6</add>
+  </field>
+  <field>
+    <name>options</name>
+    <type>text</type>
+    <comment>Options for the service (JSON)</comment>
+    <add>4.6</add>
+  </field>
+  
+  <!-- Connection lifecycle -->
+  
+  <field>
+    <name>is_active</name>
+    <title>Is Active</title>
+    <type>boolean</type>
+    <default>1</default>
+    <comment>Is connection currently enabled?</comment>
+    <add>4.6</add>
+  </field>
+  <field>
+    <name>created_date</name>
+    <type>timestamp</type>
+    <comment>When was the connection was created.</comment>
+    <required>false</required>
+    <default>NULL</default>
+    <add>4.6</add>
+  </field>
+  <field>
+    <name>modified_date</name>
+    <type>timestamp</type>
+    <comment>When the connection was created or modified.</comment>
+    <required>false</required>
+    <default>CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP</default>
+    <add>4.6</add>
+  </field>
+  <field>
+    <name>fetched_date</name>
+    <type>timestamp</type>
+    <comment>The last time the application metadata was fetched.</comment>
+    <required>false</required>
+    <default>NULL</default>
+    <add>4.6</add>
+  </field>
+</table>
diff --git a/xml/schema/Cxn/files.xml b/xml/schema/Cxn/files.xml
new file mode 100644 (file)
index 0000000..d11fb7d
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+
+<tables xmlns:xi="http://www.w3.org/2001/XInclude">
+  <xi:include href="Cxn.xml"      parse="xml" />
+</tables>
index d9af1181be0a25b670aa454f99f1b7170dc21be2..19def883b4fd321349e46dc50aa499a7e895dd83 100644 (file)
@@ -30,4 +30,5 @@
 <xi:include href="Report/files.xml"            parse="xml" />
 <xi:include href="Price/files.xml"             parse="xml" />
 <xi:include href="PCP/files.xml"             parse="xml" />
+<xi:include href="Cxn/files.xml"              parse="xml" />
 </database>