From: Michael J. Rubinsky Date: Wed, 6 Oct 2010 19:44:18 +0000 (-0400) Subject: Turba migrations, remove legacy upgrade files and creation scripts X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=57f93ce2147ea1bbc8bfe66c3403ae20e864059b;p=horde.git Turba migrations, remove legacy upgrade files and creation scripts --- diff --git a/turba/migration/1_turba_base_tables.php b/turba/migration/1_turba_base_tables.php new file mode 100644 index 000000000..fce2b2035 --- /dev/null +++ b/turba/migration/1_turba_base_tables.php @@ -0,0 +1,140 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package Turba + */ +class TurbaBaseTables extends Horde_Db_Migration_Base +{ + /** + * Upgrade. + */ + public function up() + { + $tableList = $this->tables(); + + if (!in_array('turba_objects', $tableList)) { + $t = $this->createTable('turba_objects', array('primaryKey' => false)); + $t->column('object_id', 'string', array('limit' => 32, 'null' => false)); + $t->column('owner_id', 'string', array('limit' => 255, 'null' => false)); + $t->column('object_type', 'string', array('limit' => 255, 'default' => 'Object', 'null' => false)); + $t->column('object_uid', 'string', array('limit' => 255)); + $t->column('object_members', 'text'); + $t->column('object_firstname', 'string', array('limit' => 255)); + $t->column('object_lastname', 'string', array('limit' => 255)); + $t->column('object_middlenames', 'string', array('limit' => 255)); + $t->column('object_nameprefix', 'string', array('limit' => 32)); + $t->column('object_namesuffix', 'string', array('limit' => 32)); + $t->column('object_alias', 'string', array('limit' => 32)); + $t->column('object_photo', 'binary'); + $t->column('object_phototype', 'string', array('limit' => 10)); + $t->column('object_bday', 'string', array('limit' => 10)); + $t->column('object_homestreet', 'string', array('limit' => 255)); + $t->column('object_homepob', 'string', array('limit' => 10)); + $t->column('object_homecity', 'string', array('limit' => 255)); + $t->column('object_homeprovince', 'string', array('limit' => 255)); + $t->column('object_homepostalcode', 'string', array('limit' => 10)); + $t->column('object_homecountry', 'string', array('limit' => 255)); + $t->column('object_workstreet', 'string', array('limit' => 255)); + $t->column('object_workpob', 'string', array('limit' => 10)); + $t->column('object_workcity', 'string', array('limit' => 255)); + $t->column('object_workprovince', 'string', array('limit' => 255)); + $t->column('object_workpostalcode', 'string', array('limit' => 10)); + $t->column('object_workcountry', 'string', array('limit' => 255)); + $t->column('object_tz', 'string', array('limit' => 32)); + $t->column('object_geo', 'string', array('limit' => 255)); + $t->column('object_email', 'string', array('limit' => 255)); + $t->column('object_homephone', 'string', array('limit' => 25)); + $t->column('object_workphone', 'string', array('limit' => 25)); + $t->column('object_cellphone', 'string', array('limit' => 25)); + $t->column('object_fax', 'string', array('limit' => 25)); + $t->column('object_pager', 'string', array('limit' => 25)); + $t->column('object_title', 'string', array('limit' => 255)); + $t->column('object_role', 'string', array('limit' => 255)); + $t->column('object_logo', 'binary'); + $t->column('object_logo_type', 'string', array('limit' => 10)); + $t->column('object_company', 'string', array('limit' => 255)); + $t->column('object_category', 'string', array('limit' => 80)); + $t->column('object_notes', 'text'); + $t->column('object_url', 'string', array('limit' => 255)); + $t->column('object_freebusyurl', 'string', array('limit' => 255)); + $t->column('object_pgppublickey', 'text'); + $t->column('object_smimepublickey', 'text'); + $t->primaryKey(array('object_id')); + $t->end(); + + + $this->addIndex('turba_objects', array('owner_id')); + $this->addIndex('turba_objects', array('object_email')); + $this->addIndex('turba_objects', array('object_firstname')); + $this->addIndex('turba_objects', array('object_lastname')); + } + + if (!in_array('turba_shares', $tableList)) { + $t = $this->createTable('turba_shares', array('primaryKey' => false)); + $t->column('share_id', 'integer', array('null' => false)); + $t->column('share_name', 'string', array('limit' => 255, 'null' => false)); + $t->column('share_owner', 'string', array('limit' => 255, 'null' => false)); + $t->column('share_flags', 'integer', array('default' => 0, 'null' => false)); + $t->column('perm_creator', 'integer', array('default' => 0, 'null' => false)); + $t->column('perm_default', 'integer', array('default' => 0, 'null' => false)); + $t->column('perm_guest', 'integer', array('default' => 0, 'null' => false)); + $t->column('attribute_name', 'string', array('limit' => 255, 'null' => false)); + $t->column('attribute_desc', 'string', array('limit' => 255)); + $t->column('attribute_params', 'text'); + $t->primaryKey(array('share_id')); + $t->end(); + + $this->addIndex('turba_shares', 'share_name'); + $this->addIndex('turba_shares', 'share_owner'); + $this->addIndex('turba_shares', 'perm_creator'); + $this->addIndex('turba_shares', 'perm_default'); + $this->addIndex('turba_shares', 'perm_guest'); + } + + if (!in_array('turba_shares_groups', $tableList)) { + $t = $this->createTable('turba_shares_groups'); + $t->column('share_id', 'integer', array('null' => false)); + $t->column('group_uid', 'string', array('limit' => 255, 'null' => false)); + $t->column('perm', 'integer', array('null' => false)); + $t->end(); + + $this->addIndex('turba_shares_groups', 'share_id'); + $this->addIndex('turba_shares_groups', 'group_uid'); + $this->addIndex('turba_shares_groups', 'perm'); + } + + if (!in_array('turba_shares_users', $tableList)) { + $t = $this->createTable('turba_shares_users'); + + $t->column('share_id', 'integer', array('null' => false)); + $t->column('user_uid', 'string', array('limit' => 255)); + $t->column('perm', 'integer', array('null' => false)); + $t->end(); + + $this->addIndex('turba_shares_users', 'share_id'); + $this->addIndex('turba_shares_users', 'user_uid'); + $this->addIndex('turba_shares_users', 'perm'); + } + } + + /** + * Downgrade to 0 + */ + public function down() + { + $this->dropTable('turba_objects'); + $this->dropTable('turba_shares'); + $this->dropTable('turba_shares_users'); + $this->dropTable('turba_shares_groups'); + } + +} \ No newline at end of file diff --git a/turba/migration/2_turba_upgrade_autoincrement.php b/turba/migration/2_turba_upgrade_autoincrement.php new file mode 100644 index 000000000..5ce04d64f --- /dev/null +++ b/turba/migration/2_turba_upgrade_autoincrement.php @@ -0,0 +1,33 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package Turba + */ +class TurbaUpgradeAutoIncrement extends Horde_Db_Migration_Base +{ + /** + * Upgrade. + */ + public function up() + { + $this->changeColumn('turba_shares', 'share_id', 'integer', array('null' => false, 'autoincrement' => true)); + } + + /** + * Downgrade + */ + public function down() + { + $this->changeColumn('turba_shares', 'share_id', 'integer', array('null' => false)); + } + +} \ No newline at end of file diff --git a/turba/scripts/sql/test.xml b/turba/scripts/sql/test.xml deleted file mode 100644 index 2a11a2f0a..000000000 --- a/turba/scripts/sql/test.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - - name - false - false - - - - hordetest_turba_objects - - - - - object_id - text - 32 - true - - - - owner_id - text - 255 - true - - - - object_type - text - 255 - true - Object - - - - object_uid - text - 255 - - - - object_members - clob - - - - object_name - text - 255 - - - - object_alias - text - 32 - - - - object_email - text - 255 - - - - object_homeaddress - text - 255 - - - - object_workaddress - text - 255 - - - - object_homephone - text - 25 - - - - object_workphone - text - 25 - - - - object_cellphone - text - 25 - - - - object_fax - text - 25 - - - - object_title - text - 255 - - - - object_company - text - 255 - - - - object_notes - clob - - - - object_pgppublickey - clob - - - - object_smimepublickey - clob - - - - object_freebusyurl - text - 255 - - - - hordetest_turba_objects_primary - true - - object_id - - - - - hordetest_turba_objects_owner - - owner_id - ascending - - - - - -
- -
diff --git a/turba/scripts/sql/turba.mssql.sql b/turba/scripts/sql/turba.mssql.sql deleted file mode 100644 index 357197b5d..000000000 --- a/turba/scripts/sql/turba.mssql.sql +++ /dev/null @@ -1,94 +0,0 @@ -CREATE TABLE turba_objects ( - object_id VARCHAR(32) NOT NULL, - owner_id VARCHAR(255) NOT NULL, - object_type VARCHAR(255) DEFAULT 'Object' NOT NULL, - object_uid VARCHAR(255), - object_members IMAGE, - object_firstname VARCHAR(255), - object_lastname VARCHAR(255), - object_middlenames VARCHAR(255), - object_nameprefix VARCHAR(32), - object_namesuffix VARCHAR(32), - object_alias VARCHAR(32), - object_photo IMAGE, - object_phototype VARCHAR(10), - object_bday VARCHAR(10), - object_homestreet VARCHAR(255), - object_homepob VARCHAR(10), - object_homecity VARCHAR(255), - object_homeprovince VARCHAR(255), - object_homepostalcode VARCHAR(10), - object_homecountry VARCHAR(255), - object_workstreet VARCHAR(255), - object_workpob VARCHAR(10), - object_workcity VARCHAR(255), - object_workprovince VARCHAR(255), - object_workpostalcode VARCHAR(10), - object_workcountry VARCHAR(255), - object_tz VARCHAR(32), - object_geo VARCHAR(255), - object_email VARCHAR(255), - object_homephone VARCHAR(25), - object_workphone VARCHAR(25), - object_cellphone VARCHAR(25), - object_fax VARCHAR(25), - object_pager VARCHAR(25), - object_title VARCHAR(255), - object_role VARCHAR(255), - object_logo IMAGE, - object_logotype VARCHAR(10), - object_company VARCHAR(255), - object_category VARCHAR(80), - object_notes VARCHAR(MAX), - object_url VARCHAR(255), - object_freebusyurl VARCHAR(255), - object_pgppublickey VARCHAR(MAX), - object_smimepublickey VARCHAR(MAX), --- - PRIMARY KEY(object_id) -); - -CREATE INDEX turba_owner_idx ON turba_objects (owner_id); -CREATE INDEX turba_email_idx ON turba_objects (object_email); -CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname); -CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname); - -CREATE TABLE turba_shares ( - share_id INT NOT NULL, - share_name VARCHAR(255) NOT NULL, - share_owner VARCHAR(255) NOT NULL, - share_flags SMALLINT DEFAULT 0 NOT NULL, - perm_creator SMALLINT DEFAULT 0 NOT NULL, - perm_default SMALLINT DEFAULT 0 NOT NULL, - perm_guest SMALLINT DEFAULT 0 NOT NULL, - attribute_name VARCHAR(255) NOT NULL, - attribute_desc VARCHAR(255), - attribute_params VARCHAR(MAX), - PRIMARY KEY (share_id) -); - -CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name); -CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner); -CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator); -CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default); -CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest); - -CREATE TABLE turba_shares_groups ( - share_id INT NOT NULL, - group_uid VARCHAR(255) NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id); -CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid); -CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm); - -CREATE TABLE turba_shares_users ( - share_id INT NOT NULL, - user_uid VARCHAR(255) NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id); -CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid); -CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm); diff --git a/turba/scripts/sql/turba.oci8.sql b/turba/scripts/sql/turba.oci8.sql deleted file mode 100644 index 6322affa3..000000000 --- a/turba/scripts/sql/turba.oci8.sql +++ /dev/null @@ -1,93 +0,0 @@ -CREATE TABLE turba_objects ( - object_id VARCHAR2(32) NOT NULL, - owner_id VARCHAR2(255) NOT NULL, - object_type VARCHAR2(255) DEFAULT 'Object' NOT NULL, - object_uid VARCHAR2(255), - object_members CLOB, - object_firstname VARCHAR2(255), - object_lastname VARCHAR2(255), - object_middlenames VARCHAR2(255), - object_nameprefix VARCHAR2(32), - object_namesuffix VARCHAR2(32), - object_alias VARCHAR2(32), - object_photo BLOB, - object_phototype VARCHAR2(10), - object_bday VARCHAR2(10), - object_homestreet VARCHAR2(255), - object_homepob VARCHAR2(10), - object_homecity VARCHAR2(255), - object_homeprovince VARCHAR2(255), - object_homepostalcode VARCHAR2(10), - object_homecountry VARCHAR2(255), - object_workstreet VARCHAR2(255), - object_workpob VARCHAR2(10), - object_workcity VARCHAR2(255), - object_workprovince VARCHAR2(255), - object_workpostalcode VARCHAR2(10), - object_workcountry VARCHAR2(255), - object_tz VARCHAR2(32), - object_geo VARCHAR2(255), - object_email VARCHAR2(255), - object_homephone VARCHAR2(25), - object_workphone VARCHAR2(25), - object_cellphone VARCHAR2(25), - object_fax VARCHAR2(25), - object_pager VARCHAR2(25), - object_title VARCHAR2(255), - object_role VARCHAR2(255), - object_logo BLOB, - object_logotype VARCHAR2(10), - object_company VARCHAR2(255), - object_category VARCHAR2(80), - object_notes CLOB, - object_url VARCHAR2(255), - object_freebusyurl VARCHAR2(255), - object_pgppublickey CLOB, - object_smimepublickey CLOB, - PRIMARY KEY(object_id) -); - -CREATE INDEX turba_owner_idx ON turba_objects (owner_id); -CREATE INDEX turba_email_idx ON turba_objects (object_email); -CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname); -CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname); - -CREATE TABLE turba_shares ( - share_id NUMBER(16) NOT NULL, - share_name VARCHAR2(255) NOT NULL, - share_owner VARCHAR2(255) NOT NULL, - share_flags NUMBER(8) DEFAULT 0 NOT NULL, - perm_creator NUMBER(8) DEFAULT 0 NOT NULL, - perm_default NUMBER(8) DEFAULT 0 NOT NULL, - perm_guest NUMBER(8) DEFAULT 0 NOT NULL, - attribute_name VARCHAR2(255) NOT NULL, - attribute_desc VARCHAR2(255), - attribute_params VARCHAR2(4000), - PRIMARY KEY (share_id) -); - -CREATE INDEX turba_shares_name_idx ON turba_shares (share_name); -CREATE INDEX turba_shares_owner_idx ON turba_shares (share_owner); -CREATE INDEX turba_shares_creator_idx ON turba_shares (perm_creator); -CREATE INDEX turba_shares_default_idx ON turba_shares (perm_default); -CREATE INDEX turba_shares_guest_idx ON turba_shares (perm_guest); - -CREATE TABLE turba_shares_groups ( - share_id NUMBER(16) NOT NULL, - group_uid VARCHAR2(255) NOT NULL, - perm NUMBER(8) NOT NULL -); - -CREATE INDEX turba_groups_share_id_idx ON turba_shares_groups (share_id); -CREATE INDEX turba_groups_group_uid_idx ON turba_shares_groups (group_uid); -CREATE INDEX turba_groups_perm_idx ON turba_shares_groups (perm); - -CREATE TABLE turba_shares_users ( - share_id NUMBER(16) NOT NULL, - user_uid VARCHAR2(255) NOT NULL, - perm NUMBER(8) NOT NULL -); - -CREATE INDEX turba_users_share_id_idx ON turba_shares_users (share_id); -CREATE INDEX turba_users_user_uid_idx ON turba_shares_users (user_uid); -CREATE INDEX turba_users_perm_idx ON turba_shares_users (perm); diff --git a/turba/scripts/sql/turba.pgsql.sql b/turba/scripts/sql/turba.pgsql.sql deleted file mode 100644 index f6bfd6b47..000000000 --- a/turba/scripts/sql/turba.pgsql.sql +++ /dev/null @@ -1,95 +0,0 @@ -CREATE TABLE turba_objects ( - object_id VARCHAR(32) NOT NULL, - owner_id VARCHAR(255) NOT NULL, - object_type VARCHAR(255) DEFAULT 'Object' NOT NULL, - object_uid VARCHAR(255), - object_members TEXT, - object_firstname VARCHAR(255), - object_lastname VARCHAR(255), - object_middlenames VARCHAR(255), - object_nameprefix VARCHAR(32), - object_namesuffix VARCHAR(32), - object_alias VARCHAR(32), - object_photo TEXT, - object_phototype VARCHAR(10), - object_bday VARCHAR(10), - object_homestreet VARCHAR(255), - object_homepob VARCHAR(10), - object_homecity VARCHAR(255), - object_homeprovince VARCHAR(255), - object_homepostalcode VARCHAR(10), - object_homecountry VARCHAR(255), - object_workstreet VARCHAR(255), - object_workpob VARCHAR(10), - object_workcity VARCHAR(255), - object_workprovince VARCHAR(255), - object_workpostalcode VARCHAR(10), - object_workcountry VARCHAR(255), - object_tz VARCHAR(32), - object_geo VARCHAR(255), - object_email VARCHAR(255), - object_homephone VARCHAR(25), - object_workphone VARCHAR(25), - object_cellphone VARCHAR(25), - object_fax VARCHAR(25), - object_pager VARCHAR(25), - object_title VARCHAR(255), - object_role VARCHAR(255), - object_logo TEXT, - object_logotype VARCHAR(10), - object_company VARCHAR(255), - object_category VARCHAR(80), - object_notes TEXT, - object_url VARCHAR(255), - object_freebusyurl VARCHAR(255), - object_pgppublickey TEXT, - object_smimepublickey TEXT, - - PRIMARY KEY(object_id) -); - -CREATE INDEX turba_owner_idx ON turba_objects (owner_id); -CREATE INDEX turba_email_idx ON turba_objects (object_email); -CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname); -CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname); - -CREATE TABLE turba_shares ( - share_id INT NOT NULL, - share_name VARCHAR(255) NOT NULL, - share_owner VARCHAR(255) NOT NULL, - share_flags SMALLINT DEFAULT 0 NOT NULL, - perm_creator SMALLINT DEFAULT 0 NOT NULL, - perm_default SMALLINT DEFAULT 0 NOT NULL, - perm_guest SMALLINT DEFAULT 0 NOT NULL, - attribute_name VARCHAR(255) NOT NULL, - attribute_desc VARCHAR(255), - attribute_params TEXT, - PRIMARY KEY (share_id) -); - -CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name); -CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner); -CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator); -CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default); -CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest); - -CREATE TABLE turba_shares_groups ( - share_id INT NOT NULL, - group_uid VARCHAR(255) NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id); -CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid); -CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm); - -CREATE TABLE turba_shares_users ( - share_id INT NOT NULL, - user_uid VARCHAR(255) NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id); -CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid); -CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm); - diff --git a/turba/scripts/sql/turba.sql b/turba/scripts/sql/turba.sql deleted file mode 100644 index baa7fcc0b..000000000 --- a/turba/scripts/sql/turba.sql +++ /dev/null @@ -1,93 +0,0 @@ -CREATE TABLE turba_objects ( - object_id VARCHAR(32) NOT NULL, - owner_id VARCHAR(255) NOT NULL, - object_type VARCHAR(255) DEFAULT 'Object' NOT NULL, - object_uid VARCHAR(255), - object_members BLOB, - object_firstname VARCHAR(255), - object_lastname VARCHAR(255), - object_middlenames VARCHAR(255), - object_nameprefix VARCHAR(32), - object_namesuffix VARCHAR(32), - object_alias VARCHAR(32), - object_photo BLOB, - object_phototype VARCHAR(10), - object_bday VARCHAR(10), - object_homestreet VARCHAR(255), - object_homepob VARCHAR(10), - object_homecity VARCHAR(255), - object_homeprovince VARCHAR(255), - object_homepostalcode VARCHAR(10), - object_homecountry VARCHAR(255), - object_workstreet VARCHAR(255), - object_workpob VARCHAR(10), - object_workcity VARCHAR(255), - object_workprovince VARCHAR(255), - object_workpostalcode VARCHAR(10), - object_workcountry VARCHAR(255), - object_tz VARCHAR(32), - object_geo VARCHAR(255), - object_email VARCHAR(255), - object_homephone VARCHAR(25), - object_workphone VARCHAR(25), - object_cellphone VARCHAR(25), - object_fax VARCHAR(25), - object_pager VARCHAR(25), - object_title VARCHAR(255), - object_role VARCHAR(255), - object_logo BLOB, - object_logotype VARCHAR(10), - object_company VARCHAR(255), - object_category VARCHAR(80), - object_notes TEXT, - object_url VARCHAR(255), - object_freebusyurl VARCHAR(255), - object_pgppublickey TEXT, - object_smimepublickey TEXT, - PRIMARY KEY(object_id) -); - -CREATE INDEX turba_owner_idx ON turba_objects (owner_id); -CREATE INDEX turba_email_idx ON turba_objects (object_email); -CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname); -CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname); - -CREATE TABLE turba_shares ( - share_id INT NOT NULL, - share_name VARCHAR(255) NOT NULL, - share_owner VARCHAR(255) NOT NULL, - share_flags SMALLINT DEFAULT 0 NOT NULL, - perm_creator SMALLINT DEFAULT 0 NOT NULL, - perm_default SMALLINT DEFAULT 0 NOT NULL, - perm_guest SMALLINT DEFAULT 0 NOT NULL, - attribute_name VARCHAR(255) NOT NULL, - attribute_desc VARCHAR(255), - attribute_params TEXT, - PRIMARY KEY (share_id) -); - -CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name); -CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner); -CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator); -CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default); -CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest); - -CREATE TABLE turba_shares_groups ( - share_id INT NOT NULL, - group_uid VARCHAR(255) NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id); -CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid); -CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm); - -CREATE TABLE turba_shares_users ( - share_id INT NOT NULL, - user_uid VARCHAR(255) NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id); -CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid); -CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm); diff --git a/turba/scripts/sql/turba.xml b/turba/scripts/sql/turba.xml deleted file mode 100644 index fa859d63c..000000000 --- a/turba/scripts/sql/turba.xml +++ /dev/null @@ -1,578 +0,0 @@ - - - - name - false - false - - - - turba_objects - - - - - object_id - text - 32 - true - - - - owner_id - text - 255 - true - - - - object_type - text - 255 - true - Object - - - - object_uid - text - 255 - - - - object_members - clob - - - - object_firstname - text - 255 - - - - object_lastname - text - 255 - - - - object_middlenames - text - 255 - - - - object_nameprefix - text - 32 - - - - object_namesuffix - text - 32 - - - - object_alias - text - 32 - - - - object_photo - blob - - - - object_phototype - text - 10 - - - - object_bday - text - 10 - - - - object_homestreet - text - 255 - - - - object_homepob - text - 10 - - - - object_homecity - text - 255 - - - - object_homeprovince - text - 255 - - - - object_homepostalcode - text - 10 - - - - object_homecountry - text - 255 - - - - object_workstreet - text - 255 - - - - object_workpob - text - 10 - - - - object_workcity - text - 255 - - - - object_workprovince - text - 255 - - - - object_workpostalcode - text - 10 - - - - object_workcountry - text - 255 - - - - object_tz - text - 32 - - - - object_geo - text - 255 - - - - object_email - text - 255 - - - - object_homephone - text - 25 - - - - object_workphone - text - 25 - - - - object_cellphone - text - 25 - - - - object_fax - text - 25 - - - - object_pager - text - 25 - - - - object_title - text - 255 - - - - object_role - text - 255 - - - - object_logo - blob - - - - object_logotype - text - 10 - - - - object_company - text - 255 - - - - object_category - text - 80 - - - - object_notes - clob - - - - object_url - text - 255 - - - - object_freebusyurl - text - 255 - - - - object_pgppublickey - clob - - - - object_smimepublickey - clob - - - - turba_primary - true - - object_id - - - - - turba_owner - - owner_id - ascending - - - - - turba_email - - object_email - ascending - - - - - turba_firstname - - object_firstname - ascending - - - - - turba_lastname - - object_lastname - ascending - - - - - -
- - - - turba_shares - - - - - share_id - integer - - true - 4 - - - - share_name - text - - true - 255 - - - - share_owner - text - - true - 255 - - - - share_flags - integer - 0 - true - 2 - - - - perm_creator - integer - 0 - true - 2 - - - - perm_default - integer - 0 - true - 2 - - - - perm_guest - integer - 0 - true - 2 - - - - attribute_name - text - - true - 255 - - - - attribute_desc - text - - false - 255 - - - - attribute_params - clob - - - - turba_shares_name - - share_name - ascending - - - - - turba_shares_owner - - share_owner - ascending - - - - - turba_shares_creator - - perm_creator - ascending - - - - - turba_shares_default - - perm_default - ascending - - - - - turba_shares_guest - - perm_guest - ascending - - - - - turba_shares_pKey - true - - share_id - ascending - - - - - -
- - - - turba_shares_groups - - - - - share_id - integer - - true - 4 - - - - group_uid - text - - true - 255 - - - - perm - integer - - true - 2 - - - - turba_groups_share_id - - share_id - ascending - - - - - turba_groups_group_uid - - group_uid - ascending - - - - - turba_groups_perm - - perm - ascending - - - - - -
- - - - turba_shares_users - - - - - share_id - integer - - true - 4 - - - - user_uid - text - - true - 255 - - - - perm - integer - - true - 2 - - - - turba_users_share_id - - share_id - ascending - - - - - turba_users_user_uid - - user_uid - ascending - - - - - turba_users_perm - - perm - ascending - - - - - -
- -
diff --git a/turba/scripts/upgrades/1.1_to_1.2.sql b/turba/scripts/upgrades/1.1_to_1.2.sql deleted file mode 100644 index e9001b9be..000000000 --- a/turba/scripts/upgrades/1.1_to_1.2.sql +++ /dev/null @@ -1,21 +0,0 @@ --- You can simply execute this file in your database. --- --- For MySQL run: --- --- $ mysql --user=root --password= < 1.1_to_1.2.sql --- --- Or, for PostgreSQL: --- --- $ psql -f 1.1_to_1.2.sql - -ALTER TABLE turba_objects CHANGE object_homeAddress object_homeaddress VARCHAR(255); -ALTER TABLE turba_objects CHANGE object_workAddress object_workaddress VARCHAR(255); -ALTER TABLE turba_objects CHANGE object_homePhone object_homephone VARCHAR(25); -ALTER TABLE turba_objects CHANGE object_workPhone object_workphone VARCHAR(25); -ALTER TABLE turba_objects CHANGE object_cellPhone object_cellphone VARCHAR(25); -ALTER TABLE turba_objects MODIFY object_title VARCHAR(255); -ALTER TABLE turba_objects MODIFY object_company VARCHAR(255); -ALTER TABLE turba_objects ADD object_type VARCHAR(255) DEFAULT 'Object' NOT NULL; -ALTER TABLE turba_objects ADD object_members BLOB; -CREATE INDEX turba_owner_idx ON turba_objects (owner_id); - diff --git a/turba/scripts/upgrades/1.2_to_2.0.oci8.sql b/turba/scripts/upgrades/1.2_to_2.0.oci8.sql deleted file mode 100644 index ea1292afa..000000000 --- a/turba/scripts/upgrades/1.2_to_2.0.oci8.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE turba_objects ADD object_uid VARCHAR2(255); -ALTER TABLE turba_objects ADD object_freebusyurl VARCHAR2(255); -ALTER TABLE turba_objects ADD object_smimepublickey CLOB; -ALTER TABLE turba_objects ADD object_pgppublickey CLOB; diff --git a/turba/scripts/upgrades/1.2_to_2.0.sql b/turba/scripts/upgrades/1.2_to_2.0.sql deleted file mode 100644 index 65b090e77..000000000 --- a/turba/scripts/upgrades/1.2_to_2.0.sql +++ /dev/null @@ -1,15 +0,0 @@ --- You can simply execute this file in your database. --- --- For MySQL run: --- --- $ mysql --user=root --password= < 1.2_to_2.0.sql --- --- Or, for PostgreSQL: --- --- $ psql -f 1.2_to_2.0.sql - - -ALTER TABLE turba_objects ADD COLUMN object_uid VARCHAR(255); -ALTER TABLE turba_objects ADD COLUMN object_freebusyurl VARCHAR(255); -ALTER TABLE turba_objects ADD COLUMN object_smimepublickey TEXT; -ALTER TABLE turba_objects ADD COLUMN object_pgppublickey TEXT; diff --git a/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.mssql.sql b/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.mssql.sql deleted file mode 100644 index eadf4d006..000000000 --- a/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.mssql.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE turba_shares ( - share_id INT NOT NULL, - share_name VARCHAR(255) NOT NULL, - share_owner VARCHAR(32) NOT NULL, - share_flags SMALLINT DEFAULT 0 NOT NULL, - perm_creator SMALLINT DEFAULT 0 NOT NULL, - perm_default SMALLINT DEFAULT 0 NOT NULL, - perm_guest SMALLINT DEFAULT 0 NOT NULL, - attribute_name VARCHAR(255) NOT NULL, - attribute_desc VARCHAR(255), - attribute_params VARCHAR(MAX), - PRIMARY KEY (share_id) -); - -CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name); -CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner); -CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator); -CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default); -CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest); - -CREATE TABLE turba_shares_groups ( - share_id INT NOT NULL, - group_uid INT NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id); -CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid); -CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm); - -CREATE TABLE turba_shares_users ( - share_id INT NOT NULL, - user_uid VARCHAR(32) NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id); -CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid); -CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm); diff --git a/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.oci8.sql b/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.oci8.sql deleted file mode 100644 index f0eba9e82..000000000 --- a/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.oci8.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE turba_shares ( - share_id NUMBER(16) NOT NULL, - share_name VARCHAR2(255) NOT NULL, - share_owner VARCHAR2(32) NOT NULL, - share_flags NUMBER(8) DEFAULT 0 NOT NULL, - perm_creator NUMBER(8) DEFAULT 0 NOT NULL, - perm_default NUMBER(8) DEFAULT 0 NOT NULL, - perm_guest NUMBER(8) DEFAULT 0 NOT NULL, - attribute_name VARCHAR2(255) NOT NULL, - attribute_desc VARCHAR2(255), - attribute_params VARCHAR2(4000), - PRIMARY KEY (share_id) -); - -CREATE INDEX turba_shares_name_idx ON turba_shares (share_name); -CREATE INDEX turba_shares_owner_idx ON turba_shares (share_owner); -CREATE INDEX turba_shares_creator_idx ON turba_shares (perm_creator); -CREATE INDEX turba_shares_default_idx ON turba_shares (perm_default); -CREATE INDEX turba_shares_guest_idx ON turba_shares (perm_guest); - -CREATE TABLE turba_shares_groups ( - share_id NUMBER(16) NOT NULL, - group_uid NUMBER(16) NOT NULL, - perm NUMBER(8) NOT NULL -); - -CREATE INDEX turba_groups_share_id_idx ON turba_shares_groups (share_id); -CREATE INDEX turba_groups_group_uid_idx ON turba_shares_groups (group_uid); -CREATE INDEX turba_groups_perm_idx ON turba_shares_groups (perm); - -CREATE TABLE turba_shares_users ( - share_id NUMBER(16) NOT NULL, - user_uid VARCHAR2(32) NOT NULL, - perm NUMBER(8) NOT NULL -); - -CREATE INDEX turba_users_share_id_idx ON turba_shares_users (share_id); -CREATE INDEX turba_users_user_uid_idx ON turba_shares_users (user_uid); -CREATE INDEX turba_users_perm_idx ON turba_shares_users (perm); diff --git a/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.pgsql.sql b/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.pgsql.sql deleted file mode 100644 index 7ea262429..000000000 --- a/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.pgsql.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE turba_shares ( - share_id SMALLINT NOT NULL, - share_name VARCHAR(255) NOT NULL, - share_owner VARCHAR(32) NOT NULL, - share_flags SMALLINT DEFAULT 0 NOT NULL, - perm_creator SMALLINT DEFAULT 0 NOT NULL, - perm_default SMALLINT DEFAULT 0 NOT NULL, - perm_guest SMALLINT DEFAULT 0 NOT NULL, - attribute_name VARCHAR(255) NOT NULL, - attribute_desc VARCHAR(255), - attribute_params TEXT, - PRIMARY KEY (share_id) -); - -CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name); -CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner); -CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator); -CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default); -CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest); - -CREATE TABLE turba_shares_groups ( - share_id SMALLINT NOT NULL, - group_uid SMALLINT NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id); -CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid); -CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm); - -CREATE TABLE turba_shares_users ( - share_id SMALLINT NOT NULL, - user_uid VARCHAR(32) NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id); -CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid); -CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm); diff --git a/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.sql b/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.sql deleted file mode 100644 index 42045f4b2..000000000 --- a/turba/scripts/upgrades/2.1_to_2.2_add_sql_share_tables.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE turba_shares ( - share_id INT NOT NULL, - share_name VARCHAR(255) NOT NULL, - share_owner VARCHAR(32) NOT NULL, - share_flags SMALLINT DEFAULT 0 NOT NULL, - perm_creator SMALLINT DEFAULT 0 NOT NULL, - perm_default SMALLINT DEFAULT 0 NOT NULL, - perm_guest SMALLINT DEFAULT 0 NOT NULL, - attribute_name VARCHAR(255) NOT NULL, - attribute_desc VARCHAR(255), - attribute_params TEXT, - PRIMARY KEY (share_id) -); - -CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name); -CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner); -CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator); -CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default); -CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest); - -CREATE TABLE turba_shares_groups ( - share_id INT NOT NULL, - group_uid INT NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id); -CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid); -CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm); - -CREATE TABLE turba_shares_users ( - share_id INT NOT NULL, - user_uid VARCHAR(32) NOT NULL, - perm SMALLINT NOT NULL -); - -CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id); -CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid); -CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm); - diff --git a/turba/scripts/upgrades/2.1_to_2.2_sql_schema.php b/turba/scripts/upgrades/2.1_to_2.2_sql_schema.php deleted file mode 100755 index 56ccb474b..000000000 --- a/turba/scripts/upgrades/2.1_to_2.2_sql_schema.php +++ /dev/null @@ -1,288 +0,0 @@ -#!/usr/bin/php - 'none', 'cli' => true)); - -require_once 'Horde/Form.php'; - -$db = $injector->getInstance('Horde_Db_Pear')->getDb(); - -if (!$for_real) { - $cli->message('No changes will done to the existing data. Please read the comments in the code, then set the $for_real flag to true before running.', 'cli.message'); -} - -/* Define how to transform the address book table */ -$queries = array( - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_firstname VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_lastname VARCHAR(255)', - 'UPDATE ' . $db_table . ' SET object_lastname = object_name', - 'ALTER TABLE ' . $db_table . ' DROP COLUMN object_name', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_middlenames VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_nameprefix VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_namesuffix VARCHAR(32)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_phototype VARCHAR(10)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_bday VARCHAR(10)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homestreet VARCHAR(255)', - 'UPDATE ' . $db_table . ' SET object_homestreet = object_homeaddress', - 'ALTER TABLE ' . $db_table . ' DROP COLUMN object_homeaddress', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homepob VARCHAR(10)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homecity VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homeprovince VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homepostalcode VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homecountry VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workstreet VARCHAR(255)', - 'UPDATE ' . $db_table . ' SET object_workstreet = object_workaddress', - 'ALTER TABLE ' . $db_table . ' DROP COLUMN object_workaddress', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workpob VARCHAR(10)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workcity VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workprovince VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workpostalcode VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workcountry VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_tz VARCHAR(32)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_geo VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_pager VARCHAR(25)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_role VARCHAR(255)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_logotype VARCHAR(10)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_category VARCHAR(80)', - 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_url VARCHAR(255)', - 'CREATE INDEX turba_email_idx ON ' . $db_table . ' (object_email)', - 'CREATE INDEX turba_firstname_idx ON ' . $db_table . ' (object_firstname)', - 'CREATE INDEX turba_lastname_idx ON ' . $db_table . ' (object_lastname)', -); - -switch ($config['phptype']) { -case 'mssql': - $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_photo VARBINARY(MAX)'; - $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_logo VARBINARY(MAX)'; - break; - -case 'pgsql': - $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_photo TEXT'; - $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_logo TEXT'; - break; - -default: - $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_photo BLOB'; - $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_logo BLOB'; - break; -} - -/* Perform the queries */ -/* @TODO - Better error handling */ -$error = false; -foreach ($queries as $query) { - if ($config['phptype'] == 'oci8') { - $query = str_replace('ADD COLUMN', 'ADD', $query); - } - if ($for_real) { - $results = $db->query($query); - if ($results instanceof PEAR_Error) { - $cli->message($results->toString(), 'cli.error'); - $error = true; - continue; - } - } - $cli->message($query, 'cli.success'); -} -if ($error && - $cli->prompt('Continue?', array('y' => 'Yes', 'n' => 'No'), 'n') != 'y') { - exit(1); -} - -/* Attempt to transform the fullname into lastname and firstname */ -if ($do_name) { - require_once HORDE_BASE . '/turba/lib/Turba.php'; - $sql = 'SELECT object_id, ' . ($for_real ? 'object_lastname' : 'object_name') . ' FROM ' . $db_table; - $names = $db->getAssoc($sql); - if ($names instanceof PEAR_Error) { - $cli->message($names->toString(), 'cli.error'); - exit(1); - } - $insert_query = 'UPDATE ' . $db_table . ' SET object_firstname = ?, object_lastname = ? WHERE object_id = ?'; - if (!$for_real) { - $cli->writeln($insert_query); - } - $insert = $db->prepare($insert_query); - foreach ($names as $id => $name ) { - $lastname = Turba::guessLastName($name); - $firstname = ''; - if (strpos($name, ',') !== false) { - $firstname = preg_replace('/' . preg_quote($lastname, '/') . ',\s*/', '', $name); - } elseif ($name != $lastname) { - $firstname = preg_replace('/\s+' . preg_quote($lastname, '/') . '/', '', $name); - } - if ($for_real) { - $db->execute($insert, array($firstname, $lastname, $id)); - } else { - $cli->writeln("ID=$id\nFirst name: $firstname; Last name: $lastname; Name: $name\n"); - } - } - $cli->message('Contact name fields parsed.', 'cli.success'); -} else { - $cli->message('Contact name fields SKIPPED.', 'cli.success'); -} - -if ($do_home) { - $sql = 'SELECT object_id, ' . ($for_real ? 'object_homestreet' : 'object_homeaddress') . ' FROM ' . $db_table; - $addresses = $db->getAssoc($sql); - if ($addresses instanceof PEAR_Error) { - $cli->message($addresses->toString(), 'cli.error'); - exit(1); - } - $insert_query = 'UPDATE ' . $db_table . ' SET object_homestreet = ?, object_homecity = ?, object_homeprovince = ?, object_homepostalcode = ?, object_homecountry = ? WHERE object_id = ?'; - if (!$for_real) { - $cli->writeln($insert_query); - } - $insert = $db->prepare($insert_query); - parseAddress($addresses, $insert, $for_real); - $cli->message('Home address fields parsed.', 'cli.success'); -} else { - $cli->message('Home address fields SKIPPED.', 'cli.success'); -} - -if ($do_work) { - $sql = 'SELECT object_id, ' . ($for_real ? 'object_workstreet' : 'object_workaddress') . ' FROM ' . $db_table; - $addresses = $db->getAssoc($sql); - if ($addresses instanceof PEAR_Error) { - $cli->message($addresses->toString(), 'cli.error'); - exit(1); - } - $insert_query = 'UPDATE ' . $db_table . ' SET object_workstreet = ?, object_workcity = ?, object_workprovince = ?, object_workpostalcode = ?, object_workcountry = ? WHERE object_id = ?'; - if (!$for_real) { - $cli->writeln($insert_query); - } - $insert = $db->prepare($insert_query); - parseAddress($addresses, $insert, $for_real); - $cli->message('Work address fields parsed.', 'cli.success'); -} else { - $cli->message('Work address fields SKIPPED.', 'cli.success'); -} - -if ($do_email) { - $sql = 'SELECT object_id, object_email FROM ' . $db_table; - $emails = $db->getAssoc($sql); - if ($emails instanceof PEAR_Error) { - $cli->message($emails->toString(), 'cli.error'); - exit(1); - } - $insert_query = 'UPDATE ' . $db_table . ' SET object_email = ? WHERE object_id = ?'; - if (!$for_real) { - $cli->writeln($insert_query); - } - if ($for_real) { - $insert = $db->prepare($insert_query); - foreach ($emails as $id => $email) { - $db->execute($insert, array(getBareEmail($email), $id)); - } - } else { - $cli->writeln($insert_query); - } -} - -/** - * Helper function to parse out freeform addresses - * - * Try to parse out the free form addresses. - * Assumptions we make to fit into our schema: - * - Postal code is on the same line as state/province information - * - If there is a line following the state/province/postal code line, - * it is taken as a country. - * - Any lines before the postal code are treated as street address. - * - * @param array $addresses An array of addresses to parse. - * @param object $insert A prepared update query to write the results. - * @param boolean $for_real Whether to really change any data. - */ -function parseAddress($addresses, $insert, $for_real) -{ - global $countries; - - foreach ($addresses as $id => $address) { - if (empty($address)) { - continue; - } - $city = $state = $postalCode = $street = $country = ''; - $p_address = Horde_Form_Type_address::parse($address); - if (!count($p_address)) { - $street = $address; - } else { - if (!empty($p_address['street'])) { - $street = $p_address['street']; - } - if (!empty($p_address['city'])) { - $city = $p_address['city']; - } - if (!empty($p_address['state'])) { - $state = $p_address['state']; - } - if (!empty($p_address['zip'])) { - $postalCode = $p_address['zip']; - } - if (!empty($p_address['country'])) { - $country = isset($countries[Horde_String::upper($p_address['country'])]) - ? $countries[Horde_String::upper($p_address['country'])] - : Horde_String::upper($p_address['country']); - } - } - if ($for_real) { - $GLOBALS['db']->execute($insert, array($street, $city, $state, $postalCode, $country, $id)); - } else { - $GLOBALS['cli']->writeln("ID: $id\nStreet: $street\nCity: $city\nState: $state\nPostal Code: $postalCode\nCountry: $country\nAddress:\n$address\n"); - } - } -} - -/** - * Static function to make a given email address rfc822 compliant. - * - * @param string $address An email address. - * - * @return string The RFC822-formatted email address. - */ -function getBareEmail($address) -{ - // Empty values are still empty. - if (!$address) { - return $address; - } - - $rfc822 = new Horde_Mail_Rfc822(); - $rfc822->validateMailbox($address); - return Horde_Mime_Address::writeAddress($address->mailbox, $address->host); -} diff --git a/turba/scripts/upgrades/2.2.1_to_2.3.oci8.sql b/turba/scripts/upgrades/2.2.1_to_2.3.oci8.sql deleted file mode 100644 index 1d58677df..000000000 --- a/turba/scripts/upgrades/2.2.1_to_2.3.oci8.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE turba_shares MODIFY share_owner VARCHAR2(255); -ALTER TABLE turba_shares_users MODIFY user_uid VARCHAR2(255); -ALTER TABLE turba_shares_groups MODIFY group_uid VARCHAR2(255); diff --git a/turba/scripts/upgrades/2.2.1_to_2.3.pgsql.sql b/turba/scripts/upgrades/2.2.1_to_2.3.pgsql.sql deleted file mode 100644 index e809eaf99..000000000 --- a/turba/scripts/upgrades/2.2.1_to_2.3.pgsql.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE turba_shares ALTER share_owner TYPE VARCHAR(255); -ALTER TABLE turba_shares_users ALTER user_uid TYPE VARCHAR(255); -ALTER TABLE turba_shares_groups ALTER group_uid TYPE VARCHAR(255); diff --git a/turba/scripts/upgrades/2.2.1_to_2.3.sql b/turba/scripts/upgrades/2.2.1_to_2.3.sql deleted file mode 100644 index 2429538d3..000000000 --- a/turba/scripts/upgrades/2.2.1_to_2.3.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE turba_shares CHANGE share_owner share_owner VARCHAR(255); -ALTER TABLE turba_shares_users CHANGE user_uid user_uid VARCHAR(255); -ALTER TABLE turba_shares_groups CHANGE group_uid group_uid VARCHAR(255); diff --git a/turba/scripts/upgrades/2.3_to_2.3.3.pgsql.sql b/turba/scripts/upgrades/2.3_to_2.3.3.pgsql.sql deleted file mode 100644 index bbbb3683c..000000000 --- a/turba/scripts/upgrades/2.3_to_2.3.3.pgsql.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE turba_shares_users ALTER share_id TYPE integer; -ALTER TABLE turba_shares_groups ALTER share_id TYPE integer; -ALTER TABLE turba_shares ALTER share_id TYPE integer; - diff --git a/turba/scripts/upgrades/2005-09-23_flat_comments.php b/turba/scripts/upgrades/2005-09-23_flat_comments.php deleted file mode 100755 index ad4c1dc6b..000000000 --- a/turba/scripts/upgrades/2005-09-23_flat_comments.php +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/php - - */ - -// Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../lib/Application.php'; -Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true)); - -// Instantiate DataTree. -require_once 'Horde/DataTree.php'; -$driver = $conf['datatree']['driver']; -$params = array_merge(Horde::getDriverConfig('datatree', $driver), - array('group' => 'agora.forums.turba')); -$datatree = DataTree::singleton($driver, $params); - -// Load comments. -$forums = $datatree->get(DATATREE_FORMAT_TREE, DATATREE_ROOT); -if (!is_array($forums[DATATREE_ROOT])) { - exit("No comments.\n"); -} - -// Loop through comments. -$converted = 0; -foreach ($forums[DATATREE_ROOT] as $source => $comments) { - if (!is_array($comments)) { - exit("Comments have already been flattened.\n"); - } - $source_name = $datatree->getName($source); - foreach (array_keys($comments) as $comment) { - $name = $datatree->getName($comment); - $datatree->rename($name, $source_name . '.' . $datatree->getShortName($name)); - $converted++; - } -} -$forums = $datatree->get(DATATREE_FORMAT_TREE, DATATREE_ROOT, true); -foreach ($forums[DATATREE_ROOT] as $source => $comments) { - $source_name = $datatree->getName($source); - foreach (array_keys($comments) as $comment) { - $datatree->move($datatree->getName($comment)); - } - $datatree->remove($source_name); -} - -echo $converted . " comments flattened.\n"; diff --git a/turba/scripts/upgrades/2007-06-17_delete_old_vbooks.php b/turba/scripts/upgrades/2007-06-17_delete_old_vbooks.php deleted file mode 100755 index 334dd6b9f..000000000 --- a/turba/scripts/upgrades/2007-06-17_delete_old_vbooks.php +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env php - 'none', 'cli' => true)); - -// See if any of our sources are configured to use Horde_Share. -if (empty($_SESSION['turba']['has_share'])) { - echo "No shares to convert. Done.\n"; - exit(0); -} - -$datatree = $turba_shares->_storage; -$db = $datatree->_db; - -// Get the root vbook element. -$sql = "SELECT datatree_id FROM horde_datatree WHERE group_uid = 'horde.shares.turba' AND datatree_name = 'vbook'"; -$vbook_parent = $db->getOne($sql); -if ($vbook_parent instanceof PEAR_Error) { - var_dump($vbook_parent); - exit(1); -} -$vbook_parent = (int)$vbook_parent; - -// Get child vbooks. -$sql = "SELECT datatree_id FROM horde_datatree WHERE group_uid = 'horde.shares.turba' AND (datatree_parents = ':$vbook_parent' OR datatree_parents LIKE ':$vbook_parent:%')"; -$vbook_children = $db->getCol($sql); -if ($vbook_children instanceof PEAR_Error) { - var_dump($vbook_children); - exit(1); -} - -// Build list of ids to delete. -$datatree_ids = array($vbook_parent); -foreach ($vbook_children as $child) { - $datatree_ids[] = (int)$child; -} -$datatree_ids = implode(',', $datatree_ids); - -// Delete. -$db->query("DELETE FROM horde_datatree_attributes WHERE group_uid = 'horde.shares.turba' AND datatree_id IN ($datatree_ids)"); -$db->query("DELETE FROM horde_datatree WHERE group_uid = 'horde.shares.turba' AND datatree_id IN ($datatree_ids)"); - -// Done. -echo "Successfully deleted old virtual address books.\n"; -exit(0); diff --git a/turba/scripts/upgrades/2007-06-17_flatten_shares.php b/turba/scripts/upgrades/2007-06-17_flatten_shares.php deleted file mode 100755 index 5496aefd7..000000000 --- a/turba/scripts/upgrades/2007-06-17_flatten_shares.php +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env php - 'none', 'cli' => true)); - -// Re-load source config. -require TURBA_BASE . '/config/backends.php'; - -// See if any of our sources are configured to use Horde_Share. -if (empty($_SESSION['turba']['has_share'])) { - echo "No shares to convert. Done.\n"; - exit(0); -} - -// Check for multiple share-enabled backends and use the first one -// as a 'primary' source - this is in case multiple backends would -// have children with the same datatree_name (like when using two -// SQL sources with shares for example -foreach ($cfgSources as $type => $config) { - if (!empty($config['use_shares'])) { - $sourceTypes[] = $type; - } -} -$primary_source = $sourceTypes[0]; -$datatree = $turba_shares->_datatree; -$db = $datatree->_db; - -// Get list of shares. -$sql = "SELECT datatree_id, datatree_name, datatree_parents FROM horde_datatree WHERE group_uid = 'horde.shares.turba'"; -$datatree_elts = $db->getAssoc($sql); - -$changed_dns = array(); - -// Look at each share, looking for orphans, old parent shares, etc. -foreach ($datatree_elts as $id => $datatree_elt) { - $id = (int)$id; - $attributes = $db->getAll("SELECT * FROM horde_datatree_attributes WHERE datatree_id = $id"); - - // If there are no attributes, this will be an orphan. Delete it. - if (!count($attributes)) { - $db->query("DELETE FROM horde_datatree_attributes WHERE datatree_id = $id"); - $db->query("DELETE FROM horde_datatree WHERE group_uid = 'horde.shares.turba' AND datatree_id = $id"); - continue; - } - - $datatree_name = $datatree_elt[0]; - $datatree_parents = $datatree_elt[1]; - - // If there are no parents, this share is already flattened; ignore it. - if (empty($datatree_parents)) { - continue; - } - - // Insert a new entry with the required params setting. - $source = $datatree_elts[substr($datatree_parents, 1)][0]; - - // I *really* don't like doing it this way, but I can't think of any other - // way to get the correct values for the 'name' param (at least without creating - // 'upgrade drivers' ;) - // In what way will this will affect kolab sources?? - switch ($cfgSources[$source]['type']) { - case 'imsp': - foreach ($attributes as $attribute) { - if ($attribute[1] == 'name') { - $name = $attribute[3]; - } - - if ($attribute[1] == 'owner') { - $owner = $attribute[3]; - } - } - $nameparam = $owner . '.' . $name; - break; - - case 'sql': - foreach ($attributes as $attribute) { - if ($attribute[1] == 'uid') { - $nameparam = $attribute[3]; - break; - } - } - break; - } - - $db->query('INSERT INTO horde_datatree_attributes (datatree_id, attribute_name, attribute_key, attribute_value) VALUES (?, ?, ?, ?)', - array($id, 'params', '', serialize(array('source' => $source, 'name' => $nameparam)))); - - // Need to check for attribute_name of description and change it desc - $db->query('ALTER horde_datatree_attributes SET attribute_name = ? WHERE datatree_id = ? AND attribute_name = ?', - array('desc', $id, 'description')); - - // See if we need to differentiate the datatree_name - // FIXME: Changing the datatree_name will break any contact lists - // with contacts from this source. We can update the SQL based lists here, - // but other sources will still break, and if we change the datatree_name - // here we will have no way to ever map contact list entries that broke - // to the correct list, since the original value is lost...maybe persist - // the original value somewhere in the share params then remove it after - // some sort of upgrade maint. is run after user's next login. - if ($source != $primary_source) { - $db->query('UPDATE horde_datatree SET datatree_name = ? WHERE datatree_id = ?', array($source . $datatree_name, $id)); - } - - // Delete old sourceType and uid settings. - $statement = $db->prepare('DELETE FROM horde_datatree_attributes WHERE datatree_id = ? AND attribute_name = ?'); - $db->execute($statement, array($id, 'uid')); - $db->execute($statement, array($id, 'sourceType')); - - // Get rid of the datatree_parents string. - $db->query('UPDATE horde_datatree SET datatree_parents = ? WHERE group_uid = ? AND datatree_id = ?', - array('', 'horde.shares.turba', $id)); - -} - -// Done with actual shares -echo "Successfully flattened shared address books.\n"; - -exit(0); diff --git a/turba/scripts/upgrades/2007-08-05_remove_lastname_null_constraint.sql b/turba/scripts/upgrades/2007-08-05_remove_lastname_null_constraint.sql deleted file mode 100644 index 27f425b07..000000000 --- a/turba/scripts/upgrades/2007-08-05_remove_lastname_null_constraint.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Simple upgrade script to remove the NOT NULL constraint on the --- default schema's object_lastname field. - -ALTER TABLE turba_objects MODIFY object_lastname VARCHAR(255); - --- For posgresql: --- ALTER TABLE turba_objects ALTER object_lastname DROP NOT NULL; diff --git a/turba/scripts/upgrades/2007-11-17_sql_schema.sql b/turba/scripts/upgrades/2007-11-17_sql_schema.sql deleted file mode 100644 index ecc781a17..000000000 --- a/turba/scripts/upgrades/2007-11-17_sql_schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -ALTER TABLE turba_objects ADD object_middlenames VARCHAR(255); -ALTER TABLE turba_objects ADD object_namesuffix VARCHAR(32); -ALTER TABLE turba_objects ADD object_homepob VARCHAR(10); -ALTER TABLE turba_objects ADD object_workpob VARCHAR(10); -ALTER TABLE turba_objects ADD object_tz VARCHAR(32); -ALTER TABLE turba_objects ADD object_geo VARCHAR(255); -ALTER TABLE turba_objects ADD object_logo BLOB; -ALTER TABLE turba_objects ADD object_logotype VARCHAR(10); - -ALTER TABLE turba_objects CHANGE object_blobtype object_phototype VARCHAR(10); - -CREATE INDEX turba_email_idx ON turba_objects (object_email); -CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname); -CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname); diff --git a/turba/scripts/upgrades/2008-06-17_fix_varchar_lengths.sql b/turba/scripts/upgrades/2008-06-17_fix_varchar_lengths.sql deleted file mode 100644 index e8b962fb8..000000000 --- a/turba/scripts/upgrades/2008-06-17_fix_varchar_lengths.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE turba_shares CHANGE share_owner share_owner VARCHAR(255); -ALTER TABLE turba_shares_users CHANGE user_uid user_uid VARCHAR(255); diff --git a/turba/scripts/upgrades/2008-09-23_fix_group_uid.sql b/turba/scripts/upgrades/2008-09-23_fix_group_uid.sql deleted file mode 100644 index 6724d8f4f..000000000 --- a/turba/scripts/upgrades/2008-09-23_fix_group_uid.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE turba_shares_groups CHANGE group_uid group_uid VARCHAR(255);