duckduckgo/community-platform — pull request #243 by jbarrett (2014-10-17 14:18:27+00:00)
Title: IA Page <-> Users many_to_many relationship.

DDL:

```sql
CREATE TABLE "instant_answer_users" (
"instant_answer_id" text NOT NULL,
"users_id" bigint NOT NULL,
PRIMARY KEY ("instant_answer_id", "users_id")
);

ALTER TABLE "instant_answer_users" ADD CONSTRAINT "instant_answer_users_fk_instant_answer_id" FOREIGN KEY ("instant_answer_id")
REFERENCES "instant_answer" ("id") ON DELETE RESTRICT ON UPDATE CASCADE DEFERRABLE;

ALTER TABLE "instant_answer_users" ADD CONSTRAINT "instant_answer_users_fk_users_id" FOREIGN KEY ("users_id")
REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE DEFERRABLE;
```

Demo:

```perl
$ use lib 'lib'; use DDGC; my $d = DDGC->new
$DDGC1 = DDGC=HASH(0x2d52408);

$ my $ia = $d->rs('InstantAnswer')->first;
DDGC::DB::Result::InstantAnswer #laser_ship

$ $ia->users

$ my $user = $d->rs('User')->first;
DDGC::DB::Result::User #1

$ $ia->add_to_users($user)
DDGC::DB::Result::User #1

$ $ia->users
DDGC::DB::Result::User #1

$ $user->instant_answers
DDGC::DB::Result::InstantAnswer #laser_ship
```