Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. create table blog_posts (
  2. id uuid not null,
  3. tenant_id uuid not null,
  4. title text not null,
  5. content text not null,
  6. primary key (id)
  7. );
  8.  
  9. create unique index blog_posts_tenant_id_id_idx on blog_posts (tenant_id, id);
  10.  
  11. create table comments (
  12. id uuid not null,
  13. tenant_id uuid not null,
  14. blog_post_id uuid not null references blog_posts (id),
  15. content text not null,
  16. primary key (id)
  17. );
  18.  
  19. alter table comments add foreign key (tenant_id, blog_post_id)
  20. references blog_posts (tenant_id, id)
  21. on update cascade;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement