
jbe@0: -- NOTE: This file requires that sequence generators have not been used.
jbe@0: -- (All new rows need to start with id '1'.)
jbe@0: 
jbe@0: BEGIN;
jbe@0: 
jbe@0: INSERT INTO "member" ("login", "name") VALUES
jbe@0:   ('user1',  'User #1'),   -- id  1
jbe@0:   ('user2',  'User #2'),   -- id  2
jbe@0:   ('user3',  'User #3'),   -- id  3
jbe@0:   ('user4',  'User #4'),   -- id  4
jbe@0:   ('user5',  'User #5'),   -- id  5
jbe@0:   ('user6',  'User #6'),   -- id  6
jbe@0:   ('user7',  'User #7'),   -- id  7
jbe@0:   ('user8',  'User #8'),   -- id  8
jbe@0:   ('user9',  'User #9'),   -- id  9
jbe@0:   ('user10', 'User #10'),  -- id 10
jbe@0:   ('user11', 'User #11'),  -- id 11
jbe@0:   ('user12', 'User #12'),  -- id 12
jbe@0:   ('user13', 'User #13'),  -- id 13
jbe@0:   ('user14', 'User #14'),  -- id 14
jbe@0:   ('user15', 'User #15'),  -- id 15
jbe@0:   ('user16', 'User #16'),  -- id 16
jbe@0:   ('user17', 'User #17'),  -- id 17
jbe@0:   ('user18', 'User #18'),  -- id 18
jbe@0:   ('user19', 'User #19'),  -- id 19
jbe@0:   ('user20', 'User #20'),  -- id 20
jbe@0:   ('user21', 'User #21'),  -- id 21
jbe@0:   ('user22', 'User #22'),  -- id 22
jbe@0:   ('user23', 'User #23');  -- id 23
jbe@0: 
jbe@0: UPDATE "member" SET "password" = "login";
jbe@0: 
jbe@0: INSERT INTO "policy" (
jbe@0:         "name",
jbe@0:         "admission_time", "discussion_time", "voting_time",
jbe@0:         "issue_quorum_num", "issue_quorum_den",
jbe@0:         "initiative_quorum_num", "initiative_quorum_den"
jbe@0:     ) VALUES (
jbe@0:         'Default policy',
jbe@0:         '1 hour', '1 hour', '1 hour',
jbe@0:         25, 100,
jbe@0:         20, 100 );
jbe@0: 
jbe@0: INSERT INTO "area" ("name") VALUES
jbe@0:   ('Area #1'),  -- id 1
jbe@0:   ('Area #2'),  -- id 2
jbe@0:   ('Area #3'),  -- id 3
jbe@0:   ('Area #4');  -- id 4
jbe@0: 
jbe@0: INSERT INTO "membership" ("area_id", "member_id", "autoreject") VALUES
jbe@0:   (1,  9, FALSE),
jbe@0:   (1, 19, FALSE),
jbe@0:   (2,  9, TRUE),
jbe@0:   (2, 10, TRUE),
jbe@0:   (2, 17, TRUE),
jbe@0:   (3,  9, FALSE),
jbe@0:   (3, 11, FALSE),
jbe@0:   (3, 12, TRUE),
jbe@0:   (3, 14, FALSE),
jbe@0:   (3, 20, FALSE),
jbe@0:   (3, 21, TRUE),
jbe@0:   (3, 22, TRUE),
jbe@0:   (4,  6, FALSE),
jbe@0:   (4,  9, FALSE),
jbe@0:   (4, 13, FALSE),
jbe@0:   (4, 22, TRUE);
jbe@0: 
jbe@0: -- global delegations
jbe@0: INSERT INTO "delegation"
jbe@0:   ("truster_id", "trustee_id") VALUES
jbe@0:   ( 1,  9),
jbe@0:   ( 2, 11),
jbe@0:   ( 3, 12),
jbe@0:   ( 4, 13),
jbe@0:   ( 5, 14),
jbe@0:   ( 6,  7),
jbe@0:   ( 7,  8),
jbe@0:   ( 8,  6),
jbe@0:   (10,  9),
jbe@0:   (11,  9),
jbe@0:   (12, 21),
jbe@0:   (15, 10),
jbe@0:   (16, 17),
jbe@0:   (17, 19),
jbe@0:   (18, 19),
jbe@0:   (23, 22);
jbe@0: 
jbe@0: -- delegations for topics
jbe@0: INSERT INTO "delegation"
jbe@0:   ("area_id", "truster_id", "trustee_id") VALUES
jbe@0:   (1,  3, 17),
jbe@0:   (2,  5, 10),
jbe@0:   (2,  9, 10),
jbe@0:   (3,  4, 14),
jbe@0:   (3, 16, 20),
jbe@0:   (3, 19, 20),
jbe@0:   (4,  5, 13),
jbe@0:   (4, 12, 22);
jbe@0: 
jbe@0: INSERT INTO "issue" ("area_id", "policy_id") VALUES
jbe@0:   (3, 1);  -- id 1
jbe@0: 
jbe@0: INSERT INTO "initiative" ("issue_id", "name") VALUES
jbe@0:   (1, 'Initiative #1'),  -- id 1
jbe@0:   (1, 'Initiative #2'),  -- id 2
jbe@0:   (1, 'Initiative #3'),  -- id 3
jbe@0:   (1, 'Initiative #4'),  -- id 4
jbe@0:   (1, 'Initiative #5'),  -- id 5
jbe@0:   (1, 'Initiative #6'),  -- id 6
jbe@0:   (1, 'Initiative #7');  -- id 7
jbe@0: 
jbe@0: INSERT INTO "draft" ("initiative_id", "author_id", "content") VALUES
jbe@0:   (1, 17, 'Lorem ipsum...'),  -- id 1
jbe@0:   (2, 20, 'Lorem ipsum...'),  -- id 2
jbe@0:   (3, 20, 'Lorem ipsum...'),  -- id 3
jbe@0:   (4, 20, 'Lorem ipsum...'),  -- id 4
jbe@0:   (5, 14, 'Lorem ipsum...'),  -- id 5
jbe@0:   (6, 11, 'Lorem ipsum...'),  -- id 6
jbe@0:   (7, 12, 'Lorem ipsum...');  -- id 7
jbe@0: 
jbe@0: INSERT INTO "initiator" ("initiative_id", "member_id") VALUES
jbe@0:   (1, 17),
jbe@0:   (1, 19),
jbe@0:   (2, 20),
jbe@0:   (3, 20),
jbe@0:   (4, 20),
jbe@0:   (5, 14),
jbe@0:   (6, 11),
jbe@0:   (7, 12);
jbe@0: 
jbe@0: INSERT INTO "supporter" ("member_id", "initiative_id", "draft_id") VALUES
jbe@0:   ( 7,  4,  4),
jbe@0:   ( 8,  2,  2),
jbe@0:   (11,  6,  6),
jbe@0:   (12,  7,  7),
jbe@0:   (14,  1,  1),
jbe@0:   (14,  2,  2),
jbe@0:   (14,  3,  3),
jbe@0:   (14,  4,  4),
jbe@0:   (14,  5,  5),
jbe@0:   (14,  6,  6),
jbe@0:   (14,  7,  7),
jbe@0:   (17,  1,  1),
jbe@0:   (17,  3,  3),
jbe@0:   (19,  1,  1),
jbe@0:   (19,  2,  2),
jbe@0:   (20,  1,  1),
jbe@0:   (20,  2,  2),
jbe@0:   (20,  3,  3),
jbe@0:   (20,  4,  4),
jbe@0:   (20,  5,  5);
jbe@0: 
jbe@0: INSERT INTO "suggestion" ("initiative_id", "author_id", "name", "description") VALUES
jbe@0:   (1, 19, 'Suggestion #1', 'Lorem ipsum...');  -- id 1
jbe@0: INSERT INTO "opinion" ("member_id", "suggestion_id", "degree", "fulfilled") VALUES
jbe@0:   (14, 1, 2, FALSE);
jbe@0: INSERT INTO "opinion" ("member_id", "suggestion_id", "degree", "fulfilled") VALUES
jbe@0:   (19, 1, 2, FALSE);
jbe@0: 
jbe@0: UPDATE "issue" SET "created" = "created" - '3 hour 3 minute'::INTERVAL;
jbe@0: SELECT check_everything();
jbe@0: UPDATE "issue" SET "accepted" = "accepted" - '2 hour 2 minute'::INTERVAL;
jbe@0: SELECT check_everything();
jbe@0: 
jbe@0: INSERT INTO "direct_voter" ("member_id", "issue_id") VALUES
jbe@0:   ( 8, 1),
jbe@0:   ( 9, 1),
jbe@0:   (11, 1),
jbe@0:   (12, 1),
jbe@0:   (14, 1),
jbe@0:   (19, 1),
jbe@0:   (20, 1),
jbe@0:   (21, 1);
jbe@0: 
jbe@0: INSERT INTO "vote" ("member_id", "issue_id", "initiative_id", "grade") VALUES
jbe@0:   ( 8, 1, 1,  1),
jbe@0:   ( 8, 1, 2,  1),
jbe@0:   ( 8, 1, 3,  1),
jbe@0:   ( 8, 1, 4,  1),
jbe@0:   ( 8, 1, 5,  1),
jbe@0:   ( 8, 1, 6, -1),
jbe@0:   ( 8, 1, 7, -1),
jbe@0:   ( 9, 1, 1, -2),
jbe@0:   ( 9, 1, 2, -3),
jbe@0:   ( 9, 1, 3, -2),
jbe@0:   ( 9, 1, 4, -2),
jbe@0:   ( 9, 1, 5, -2),
jbe@0:   ( 9, 1, 6, -1),
jbe@0:   (11, 1, 1, -1),
jbe@0:   (11, 1, 2, -1),
jbe@0:   (11, 1, 3, -1),
jbe@0:   (11, 1, 4, -1),
jbe@0:   (11, 1, 5, -1),
jbe@0:   (11, 1, 6,  2),
jbe@0:   (11, 1, 7,  1),
jbe@0:   (12, 1, 1, -1),
jbe@0:   (12, 1, 3, -1),
jbe@0:   (12, 1, 4, -1),
jbe@0:   (12, 1, 5, -1),
jbe@0:   (12, 1, 6, -2),
jbe@0:   (12, 1, 7,  1),
jbe@0:   (14, 1, 1,  1),
jbe@0:   (14, 1, 2,  3),
jbe@0:   (14, 1, 3,  1),
jbe@0:   (14, 1, 4,  2),
jbe@0:   (14, 1, 5,  1),
jbe@0:   (14, 1, 6,  1),
jbe@0:   (14, 1, 7,  1),
jbe@0:   (19, 1, 1,  3),
jbe@0:   (19, 1, 2,  4),
jbe@0:   (19, 1, 3,  2),
jbe@0:   (19, 1, 4,  2),
jbe@0:   (19, 1, 5,  2),
jbe@0:   (19, 1, 7,  1),
jbe@0:   (20, 1, 1,  1),
jbe@0:   (20, 1, 2,  2),
jbe@0:   (20, 1, 3,  1),
jbe@0:   (20, 1, 4,  1),
jbe@0:   (20, 1, 5,  1),
jbe@0:   (21, 1, 5, -1);
jbe@0: 
jbe@0: UPDATE "issue" SET
jbe@0:   "snapshot" = "snapshot" - '1 hour 1 minute'::INTERVAL,
jbe@0:   "frozen" = "frozen" - '1 hour 1 minute'::INTERVAL;
jbe@0: SELECT check_everything();
jbe@0: 
jbe@0: END;
jbe@0: 




