diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-12-14 12:11:13 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-12-15 00:11:06 +0000 |
commit | ff06783c6dc50321100a54b4d4a624fde2212689 (patch) | |
tree | 38d7f914f841a6ba8ea3225bae3cacbabc80dbf9 /db | |
parent | bb356c880412db8bad655e081ad6d68f25ae3ff7 (diff) |
Make from_body a foreign key.
Diffstat (limited to 'db')
-rw-r--r-- | db/schema.sql | 2 | ||||
-rw-r--r-- | db/schema_0032-add-from_body-reference.sql | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/db/schema.sql b/db/schema.sql index 1608b08ba..8045ca6c4 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -111,7 +111,7 @@ create table users ( name text, phone text, password text not null default '', - from_body integer, -- id of body user is from or null/0 if not + from_body integer references body(id), -- id of body user is from or null/0 if not flagged boolean not null default 'f', title text ); diff --git a/db/schema_0032-add-from_body-reference.sql b/db/schema_0032-add-from_body-reference.sql new file mode 100644 index 000000000..4fa526963 --- /dev/null +++ b/db/schema_0032-add-from_body-reference.sql @@ -0,0 +1,6 @@ +begin; + +ALTER TABLE users ADD CONSTRAINT users_from_body_fkey + FOREIGN KEY (from_body) REFERENCES body(id); + +commit; |