Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. CREATE TABLE events (
  2. id uuid DEFAULT uuid_generate_v4() NOT NULL,
  3. sender_id uuid NOT NULL,
  4. recipient_id uuid NOT NULL,
  5. address character varying NOT NULL
  6. );
  7.  
  8. CREATE TABLE accounts (
  9. id uuid DEFAULT uuid_generate_v4() NOT NULL,
  10. address character varying NOT NULL
  11. );
  12.  
  13. CREATE TABLE accounts_sources (
  14. id uuid DEFAULT uuid_generate_v4() NOT NULL,
  15. source_id uuid NOT NULL,
  16. account_id uuid NOT NULL,
  17. );
  18.  
  19. CREATE TABLE sources (
  20. id uuid DEFAULT uuid_generate_v4() NOT NULL,
  21. source_id uuid,
  22. );
  23.  
  24. ALTER TABLE ONLY events
  25. ADD CONSTRAINT fk_rails_27b65ad5c4 FOREIGN KEY (sender_id) REFERENCES accounts(id);
  26.  
  27. ALTER TABLE ONLY events
  28. ADD CONSTRAINT fk_rails_e3b3f6fd6c FOREIGN KEY (recipient_id) REFERENCES accounts(id);
  29.  
  30. ALTER TABLE ONLY accounts_sources
  31. ADD CONSTRAINT fk_rails_3825abd5e3 FOREIGN KEY (source_id) REFERENCES sources(id);
  32.  
  33. ALTER TABLE ONLY accounts_sources
  34. ADD CONSTRAINT fk_rails_d1c491b354 FOREIGN KEY (account_id) REFERENCES accounts(id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement