Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE new_schema."like"
  2. (
  3.     id integer DEFAULT nextval('new_schema.like_id_seq'::regclass) PRIMARY KEY NOT NULL,
  4.     post_id integer NOT NULL,
  5.     user_id integer NOT NULL,
  6.     CONSTRAINT like_post_id_fk FOREIGN KEY (post_id) REFERENCES new_schema.post (id),
  7.     CONSTRAINT like_user_id_fk FOREIGN KEY (user_id) REFERENCES new_schema."user" (id)
  8. );
  9. CREATE UNIQUE INDEX like_id_uindex ON new_schema."like" (id);
  10. INSERT INTO new_schema."like" (id, post_id, user_id) VALUES (2, 1, 3);
  11. INSERT INTO new_schema."like" (id, post_id, user_id) VALUES (3, 2, 3);
  12. INSERT INTO new_schema."like" (id, post_id, user_id) VALUES (4, 1, 1);
  13. INSERT INTO new_schema."like" (id, post_id, user_id) VALUES (5, 2, 1);
  14. CREATE TABLE new_schema.post
  15. (
  16.     id integer DEFAULT nextval('new_schema.post_id_seq'::regclass) PRIMARY KEY NOT NULL,
  17.     user_id integer NOT NULL,
  18.     text varchar(1024) NOT NULL,
  19.     cdate timestamp DEFAULT now(),
  20.     CONSTRAINT post_user_id_fk FOREIGN KEY (user_id) REFERENCES new_schema."user" (id)
  21. );
  22. CREATE UNIQUE INDEX post_id_uindex ON new_schema.post (id);
  23. INSERT INTO new_schema.post (id, user_id, text, cdate) VALUES (1, 1, 'My first post!!!', '2019-03-21 13:10:49.636925');
  24. INSERT INTO new_schema.post (id, user_id, text, cdate) VALUES (2, 1, 'My 2nd post.', '2019-03-21 15:49:17.680557');
  25. INSERT INTO new_schema.post (id, user_id, text, cdate) VALUES (4, 3, 'test', '2019-03-22 00:08:35.490726');
  26. CREATE TABLE new_schema."user"
  27. (
  28.     id integer DEFAULT nextval('new_schema.user_id_seq'::regclass) PRIMARY KEY NOT NULL,
  29.     username varchar(20) NOT NULL,
  30.     password varchar(255) NOT NULL,
  31.     email varchar(100) NOT NULL,
  32.     bdate timestamp,
  33.     country varchar(20) DEFAULT NULL::character varying,
  34.     gender integer DEFAULT 2 NOT NULL,
  35.     rdate timestamp DEFAULT now() NOT NULL,
  36.     name varchar(30) DEFAULT NULL::character varying
  37. );
  38. CREATE UNIQUE INDEX user_id_uindex ON new_schema."user" (id);
  39. CREATE UNIQUE INDEX user_username_uindex ON new_schema."user" (username);
  40. CREATE UNIQUE INDEX user_email_uindex ON new_schema."user" (email);
  41. INSERT INTO new_schema."user" (id, username, password, email, bdate, country, gender, rdate, name) VALUES (1, 'emilg1101', '123', 'emilyandro99@gmail.com', null, null, 2, '2019-03-20 05:26:58.123423', null);
  42. INSERT INTO new_schema."user" (id, username, password, email, bdate, country, gender, rdate, name) VALUES (3, 'admin', 'admin', 'admin@admin', null, null, 2, '2019-03-21 15:53:05.725781', null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement