1 -- Some base data to prime the database...
3 -- FIXME: Only insert the rows if they are not there already.
4 INSERT INTO roles ( role_no, role_name ) VALUES( 1, 'Admin');
5 INSERT INTO roles ( role_no, role_name ) VALUES( 2, 'Group');
6 INSERT INTO roles ( role_no, role_name ) VALUES( 3, 'Public');
7 INSERT INTO roles ( role_no, role_name ) VALUES( 4, 'Resource');
9 -- Set the insert sequence to the next number, with a minimum of 10
10 SELECT setval('roles_role_no_seq', (SELECT 10 UNION SELECT role_no FROM roles ORDER BY 1 DESC LIMIT 1) );
12 INSERT INTO principal_type (principal_type_id, principal_type_desc) VALUES( 1, 'Person' );
13 INSERT INTO principal_type (principal_type_id, principal_type_desc) VALUES( 2, 'Resource' );
14 INSERT INTO principal_type (principal_type_id, principal_type_desc) VALUES( 3, 'Group' );
16 -- Create the administrator record.
17 INSERT INTO usr ( user_no, active, email_ok, updated, username, password, fullname, email )
18 VALUES ( 1, TRUE, current_date, current_date, 'admin', '**nimda', 'DAViCal Administrator', 'calendars@example.net' );
19 INSERT INTO principal ( principal_id, type_id, user_no, displayname, default_privileges )
20 VALUES ( 1, 1, 1, 'DAViCal Administrator', 0::BIT(24) );
22 INSERT INTO role_member (user_no, role_no) VALUES(1, 1);
25 -- Set the usr & dav_id sequence to the next number, with a minimum of 1000
26 SELECT setval('usr_user_no_seq', 1000 );
27 SELECT setval('dav_id_seq', 1000 );
29 INSERT INTO relationship_type ( rt_id, rt_name, confers, bit_confers )
30 VALUES( 1, 'Administers', 'A', privilege_to_bits('DAV::all') );
32 INSERT INTO relationship_type ( rt_id, rt_name, confers, bit_confers )
33 VALUES( 2, 'Can read/write to', 'RW', privilege_to_bits( ARRAY['DAV::read','DAV::write']) );
35 INSERT INTO relationship_type ( rt_id, rt_name, confers, bit_confers )
36 VALUES( 3, 'Can read from', 'R', privilege_to_bits( 'DAV::read') );
38 INSERT INTO relationship_type ( rt_id, rt_name, confers, bit_confers )
39 VALUES( 4, 'Can see free/busy time of', 'F', privilege_to_bits( 'caldav:read-free-busy') );
42 -- Set the insert sequence to the next number, with a minimum of 1000
43 SELECT setval('relationship_type_rt_id_seq', (SELECT 10 UNION SELECT rt_id FROM relationship_type ORDER BY 1 DESC LIMIT 1) );