]> err.no Git - scalable-opengroupware.org/blob - OGoContentStore/sql/generate-folderinfo-sql-for-users-sqlite.sh
added SQLite scripts
[scalable-opengroupware.org] / OGoContentStore / sql / generate-folderinfo-sql-for-users-sqlite.sh
1 #!/bin/bash
2 #
3 # Usage: generate-folderinfo-sql-for-users user1 [user2] [user3] [...]
4 #
5
6 DB="/tmp/sogo-registry.sqlite"
7
8 while [ "$1" != "" ]; do
9 USER_ID=$1
10 USER_TABLE=`echo $USER_ID | tr -s [:punct:] _`
11 cat << EOF
12 DELETE FROM SOGo_folder_info WHERE c_path2 = '${USER_ID}';
13
14 INSERT INTO SOGo_folder_info 
15   ( c_path, c_path1, c_path2, c_path3, c_path4, c_foldername, 
16     c_location, c_quick_location, c_folder_type ) 
17 VALUES 
18   ( '/Users/${USER_ID}', 
19     'Users',
20     '${USER_ID}',
21     NULL,
22     NULL,
23     '${USER_ID}', 
24     'sqlite://localhost${DB}/SOGo_user_folder_blob', 
25     'sqlite://localhost${DB}/SOGo_user_folder_quick', 
26     'Container' );
27
28 INSERT INTO SOGo_folder_info 
29   ( c_path, c_path1, c_path2, c_path3, c_path4, c_foldername, 
30     c_location, c_quick_location, c_folder_type ) 
31 VALUES 
32   ( '/Users/${USER_ID}/Calendar', 
33     'Users',
34     '${USER_ID}',
35     'Calendar',
36      NULL,
37     'Calendar', 
38     'sqlite://localhost${DB}/SOGo_${USER_TABLE}_privcal_blob', 
39     'sqlite://localhost${DB}/SOGo_${USER_TABLE}_privcal_quick', 
40     'Appointment' );
41
42 INSERT INTO SOGo_folder_info 
43   ( c_path, c_path1, c_path2, c_path3, c_path4, c_foldername, 
44     c_location, c_quick_location, c_folder_type ) 
45 VALUES 
46   ( '/Users/${USER_ID}/Contacts', 
47     'Users',
48     '${USER_ID}',
49     'Contacts',
50      NULL,
51     'Contacts', 
52     'sqlite://localhost${DB}/SOGo_${USER_TABLE}_contacts_blob', 
53     'sqlite://localhost${DB}/SOGo_${USER_TABLE}_contacts_quick', 
54     'Contact' );
55
56 DROP TABLE SOGo_${USER_TABLE}_privcal_quick;
57 DROP TABLE SOGo_${USER_TABLE}_privcal_blob;
58
59 CREATE TABLE SOGo_${USER_TABLE}_privcal_quick (
60   c_name       VARCHAR(256)    NOT NULL PRIMARY KEY, /* the filename */
61   uid          VARCHAR(256)    NOT NULL,
62   startdate    INT             NOT NULL,
63   enddate      INT             NOT NULL,
64   title        VARCHAR(1000)   NOT NULL,
65   participants VARCHAR(100000) NOT NULL, /* the CNs of the participants */
66   isallday     INT             NULL,
67   iscycle      INT             NULL,     /* client needs to fetch to resolve */
68   ispublic     INT             NOT NULL,
69   status       INT             NOT NULL,
70   isopaque     INT             NULL,
71   location     VARCHAR(256)    NULL,
72   orgmail      VARCHAR(256)    NULL,
73   partmails    VARCHAR(100000) NOT NULL, /* the emails of the participants */
74   partstates   VARCHAR(256)    NOT NULL, /* the status of each participant */
75   sequence     INT             NULL      /* the iCal sequence */
76 );
77
78 CREATE TABLE SOGo_${USER_TABLE}_privcal_blob (
79   c_name         VARCHAR(256)    NOT NULL PRIMARY KEY, /* the filename */
80   c_content      VARCHAR(100000) NOT NULL, /* the BLOB */
81   c_creationdate INT             NOT NULL, /* creation date */
82   c_lastmodified INT             NOT NULL, /* last modification (UPDATE) */
83   c_version      INT             NOT NULL  /* version counter */
84 );
85
86 DROP TABLE SOGo_${USER_TABLE}_contacts_quick;
87 DROP TABLE SOGo_${USER_TABLE}_contacts_blob;
88
89 CREATE TABLE SOGo_${USER_TABLE}_contacts_quick (
90   c_name          VARCHAR(256)    NOT NULL PRIMARY KEY, /* the filename */
91   givenname       VARCHAR(256),
92   cn              VARCHAR(256),
93   sn              VARCHAR(256),
94   l               VARCHAR(256),
95   mail            VARCHAR(256),
96   o               VARCHAR(256),
97   ou              VARCHAR(256),
98   telephonenumber VARCHAR(256)
99 );
100
101 CREATE TABLE SOGo_${USER_TABLE}_contacts_blob (
102   c_name         VARCHAR(256)    NOT NULL PRIMARY KEY, /* the filename */
103   c_content      VARCHAR(100000) NOT NULL, /* the BLOB */
104   c_creationdate INT             NOT NULL, /* creation date */
105   c_lastmodified INT             NOT NULL, /* last modification (UPDATE) */
106   c_version      INT             NOT NULL  /* version counter */
107 );
108
109 EOF
110 shift
111 done