Skip to content

Commit a081fe6

Browse files
committed
Update test data schema inline with recent RP changes
1 parent 91e5c59 commit a081fe6

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

Diff for: backends/rapidpro/schema.sql

+14-11
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,35 @@ CREATE TABLE msgs_optin (
6666

6767
DROP TABLE IF EXISTS msgs_msg CASCADE;
6868
CREATE TABLE msgs_msg (
69-
id bigserial primary key,
70-
uuid uuid NULL,
69+
id bigserial PRIMARY KEY,
70+
uuid uuid NOT NULL,
71+
org_id integer NOT NULL REFERENCES orgs_org(id) ON DELETE CASCADE,
72+
channel_id integer REFERENCES channels_channel(id) ON DELETE CASCADE,
73+
contact_id integer NOT NULL REFERENCES contacts_contact(id) ON DELETE CASCADE,
74+
contact_urn_id integer REFERENCES contacts_contacturn(id) ON DELETE CASCADE,
75+
--broadcast_id integer REFERENCES msgs_broadcast(id) ON DELETE CASCADE,
76+
--flow_id integer REFERENCES flows_flow(id) ON DELETE CASCADE,
77+
--ticket_id integer REFERENCES tickets_ticket(id) ON DELETE CASCADE,
78+
--created_by_id integer REFERENCES auth_user(id) ON DELETE CASCADE,
7179
text text NOT NULL,
7280
attachments character varying(255)[] NULL,
7381
quick_replies character varying(64)[] NULL,
82+
optin_id integer REFERENCES msgs_optin(id) ON DELETE CASCADE,
7483
locale character varying(6) NULL,
75-
high_priority boolean NULL,
7684
created_on timestamp with time zone NOT NULL,
77-
modified_on timestamp with time zone,
85+
modified_on timestamp with time zone NOT NULL,
7886
sent_on timestamp with time zone,
87+
msg_type character varying(1) NOT NULL,
7988
direction character varying(1) NOT NULL,
8089
status character varying(1) NOT NULL,
8190
visibility character varying(1) NOT NULL,
82-
msg_type character varying(1) NOT NULL,
8391
msg_count integer NOT NULL,
92+
high_priority boolean NULL,
8493
error_count integer NOT NULL,
8594
next_attempt timestamp with time zone NOT NULL,
8695
failed_reason character varying(1),
8796
external_id character varying(255),
88-
channel_id integer references channels_channel(id) on delete cascade,
89-
contact_id integer NOT NULL references contacts_contact(id) on delete cascade,
90-
contact_urn_id integer NOT NULL references contacts_contacturn(id) on delete cascade,
91-
org_id integer NOT NULL references orgs_org(id) on delete cascade,
9297
metadata text,
93-
optin_id integer references msgs_optin(id) on delete cascade,
94-
delete_from_counts boolean,
9598
log_uuids uuid[]
9699
);
97100

Diff for: backends/rapidpro/testdata.sql

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ INSERT INTO msgs_optin(id, uuid, org_id, name) VALUES
4444

4545
/** Msg with id 10000 */
4646
DELETE FROM msgs_msg;
47-
INSERT INTO msgs_msg("id", "text", "high_priority", "created_on", "modified_on", "sent_on", "direction", "status", "visibility", "msg_type",
47+
INSERT INTO msgs_msg("id", "uuid", "text", "high_priority", "created_on", "modified_on", "sent_on", "direction", "status", "visibility", "msg_type",
4848
"msg_count", "error_count", "next_attempt", "external_id", "channel_id", "contact_id", "contact_urn_id", "org_id")
49-
VALUES(10000, 'test message', True, now(), now(), now(), 'O', 'W', 'V', 'T',
49+
VALUES(10000, 'b10fff91-4ff6-46d4-b237-caed786e09d3', 'test message', True, now(), now(), now(), 'O', 'W', 'V', 'T',
5050
1, 0, now(), 'ext1', 10, 100, 1000, 1);
5151

52-
INSERT INTO msgs_msg("id", "text", "high_priority", "created_on", "modified_on", "sent_on", "direction", "status", "visibility", "msg_type",
52+
INSERT INTO msgs_msg("id", "uuid", "text", "high_priority", "created_on", "modified_on", "sent_on", "direction", "status", "visibility", "msg_type",
5353
"msg_count", "error_count", "next_attempt", "external_id", "channel_id", "contact_id", "contact_urn_id", "org_id")
54-
VALUES(10001, 'test message without external', True, now(), now(), now(), 'O', 'W', 'V', 'T',
54+
VALUES(10001, '452adaa9-1e4d-4ff3-a3c6-d3867ff2adfb', 'test message without external', True, now(), now(), now(), 'O', 'W', 'V', 'T',
5555
1, 0, now(), '', 10, 100, 1000, 1);
5656

57-
INSERT INTO msgs_msg("id", "text", "high_priority", "created_on", "modified_on", "sent_on", "direction", "status", "visibility", "msg_type",
57+
INSERT INTO msgs_msg("id", "uuid", "text", "high_priority", "created_on", "modified_on", "sent_on", "direction", "status", "visibility", "msg_type",
5858
"msg_count", "error_count", "next_attempt", "external_id", "channel_id", "contact_id", "contact_urn_id", "org_id")
59-
VALUES(10002, 'test message incoming', True, now(), now(), now(), 'I', 'P', 'V', 'T',
59+
VALUES(10002, '0ee51bf5-b285-4c39-95d6-c85d18b23f1e', 'test message incoming', True, now(), now(), now(), 'I', 'P', 'V', 'T',
6060
1, 0, now(), 'ext2', 10, 100, 1000, 1);
6161

6262
INSERT INTO msgs_media("id", "uuid", "org_id", "content_type", "url", "path", "size", "duration", "width", "height", "original_id")

0 commit comments

Comments
 (0)