|
|
@ -519,9 +519,9 @@ def create_database(cur, con): |
|
|
|
cur.execute(sql) |
|
|
|
|
|
|
|
sql = "Create table forums_status (forum_id integer NOT NULL, date_inserted date NOT NULL, " \ |
|
|
|
"listings integer NOT NULL, descriptions integer NOT NULL, status bit(1) NOT NULL, date_reference date NOT NULL " \ |
|
|
|
"CONSTRAINT forums_log_pkey PRIMARY KEY (forum_id, date_inserted), " \ |
|
|
|
"CONSTRAINT forums_fk FOREIGN KEY (forum_id) REFERENCES forums (forum_id))" |
|
|
|
"listings integer NOT NULL, descriptions integer NOT NULL, status bit(1) NOT NULL, date_reference date NOT NULL, " \ |
|
|
|
"constraint forums_status_pk PRIMARY KEY (forum_id, date_inserted), " \ |
|
|
|
"constraint forums_status_fk FOREIGN KEY (forum_id) REFERENCES forums (forum_id))" |
|
|
|
cur.execute(sql) |
|
|
|
|
|
|
|
sql = "create table users (user_id integer NOT NULL, forum_id integer NOT NULL, name_user character varying(" \ |
|
|
@ -529,7 +529,7 @@ def create_database(cur, con): |
|
|
|
"interest_user character varying(5000) null, signature_user character varying(1000) null, " \ |
|
|
|
"image_user character varying(10000000) null, dateinserted_user timestamp(6) with time zone NOT NULL, " \ |
|
|
|
"constraint users_pk primary key (user_id), " \ |
|
|
|
"constraint users_forum_id_fkey foreign key (forum_id) references forums (forum_id))" |
|
|
|
"constraint users_forum_id_fk foreign key (forum_id) references forums (forum_id))" |
|
|
|
cur.execute(sql) |
|
|
|
|
|
|
|
sql = "create unique index unique_user ON users USING btree (forum_id ASC NULLS LAST, name_user ASC NULLS LAST)" |
|
|
@ -541,17 +541,17 @@ def create_database(cur, con): |
|
|
|
"signature_user character varying(1000) null, image_user character varying(10000000) null, " \ |
|
|
|
"dateinserted_user timestamp(6) with time zone NOT NULL, " \ |
|
|
|
"constraint users_history_pk primary key (user_id, version_user), " \ |
|
|
|
"constraint users_history_user_id_fkey foreign key (user_id) references " \ |
|
|
|
"users (user_id), constraint users_history_forum_id_fkey foreign key (forum_id) references forums (forum_id))" |
|
|
|
"constraint users_history_user_id_fk foreign key (user_id) references users (user_id), " \ |
|
|
|
"constraint users_history_forum_id_fk foreign key (forum_id) references forums (forum_id))" |
|
|
|
cur.execute(sql) |
|
|
|
|
|
|
|
sql = "create table topics(topic_id integer NOT NULL, forum_id integer NOT NULL, author_id integer NOT NULL, " \ |
|
|
|
"title_topic character varying(255) NOT NULL, board_topic character varying(255) NOT NULL, views_topic integer null, " \ |
|
|
|
"posts_topic integer null, href_topic character varying(255) NOT null, dateadded_topic timestamp(6) with time zone null, " \ |
|
|
|
"dateinserted_topic timestamp(6) with time zone NOT NULL, classification_topic double precision NOT NULL, " \ |
|
|
|
"constraint topics_pk primary key (topic_id), constraint topics_author_id_fkey " \ |
|
|
|
"foreign key (author_id) references users (user_id), constraint topics_forum_id_fkey foreign key (" \ |
|
|
|
"forum_id) references forums (forum_id))" |
|
|
|
"constraint topics_pk primary key (topic_id), " \ |
|
|
|
"constraint topics_author_id_fk foreign key (author_id) references users (user_id), " \ |
|
|
|
"constraint topics_forum_id_fk foreign key (forum_id) references forums (forum_id))" |
|
|
|
cur.execute(sql) |
|
|
|
|
|
|
|
sql = "create unique index unique_topic ON topics USING btree (forum_id ASC NULLS LAST, author_id ASC NULLS LAST, " \ |
|
|
@ -564,9 +564,9 @@ def create_database(cur, con): |
|
|
|
"dateadded_topic timestamp(6) with time zone null, dateinserted_topic timestamp(6) with time zone NOT NULL, " \ |
|
|
|
"classification_topic double precision NOT NULL, " \ |
|
|
|
"constraint topics_history_pk primary key (topic_id, version_topic), " \ |
|
|
|
"constraint topics_history_topic_id_fkey foreign key (topic_id) references topics (topic_id), " \ |
|
|
|
"constraint topics_history_author_id_fkey foreign key (author_id) references users (user_id), " \ |
|
|
|
"constraint topics_history_board_id_fkey foreign key (forum_id) references forums (forum_id))" |
|
|
|
"constraint topics_history_topic_id_fk foreign key (topic_id) references topics (topic_id), " \ |
|
|
|
"constraint topics_history_author_id_f foreign key (author_id) references users (user_id), " \ |
|
|
|
"constraint topics_history_board_id_fk foreign key (forum_id) references forums (forum_id))" |
|
|
|
cur.execute(sql) |
|
|
|
|
|
|
|
sql = "create table posts(post_id integer NOT NULL, topic_id integer NOT NULL, " \ |
|
|
@ -574,8 +574,8 @@ def create_database(cur, con): |
|
|
|
"image_post character varying(10000000) null, dateadded_post timestamp(6) with time zone NOT NULL, " \ |
|
|
|
"dateinserted_post timestamp(6) with time zone NOT NULL, " \ |
|
|
|
"constraint posts_pk primary key (post_id), " \ |
|
|
|
"constraint posts_user_id_fkey foreign key (user_id) references users (user_id), constraint " \ |
|
|
|
"posts_topic_id_fkey foreign key (topic_id) references topics (topic_id))" |
|
|
|
"constraint posts_user_id_fk foreign key (user_id) references users (user_id), " \ |
|
|
|
"constraint posts_topic_id_fk foreign key (topic_id) references topics (topic_id))" |
|
|
|
cur.execute(sql) |
|
|
|
|
|
|
|
sql = "create unique index unique_post ON posts USING btree (topic_id ASC NULLS LAST, user_id ASC NULLS LAST, " \ |
|
|
@ -587,9 +587,9 @@ def create_database(cur, con): |
|
|
|
"image_post character varying(10000000) null, dateadded_post timestamp(6) with time zone NOT NULL, " \ |
|
|
|
"dateinserted_post timestamp(6) with time zone NOT NULL, " \ |
|
|
|
"constraint posts_history_pk primary key (post_id, version_post), " \ |
|
|
|
"constraint posts_history_user_id_fkey foreign key (user_id) references users (user_id), " \ |
|
|
|
"constraint posts_history_topic_id_fkey foreign key (topic_id) references topics (topic_id), " \ |
|
|
|
"constraint posts_history_post_id_fkey foreign key (post_id) references posts (post_id))" |
|
|
|
"constraint posts_history_user_id_fk foreign key (user_id) references users (user_id), " \ |
|
|
|
"constraint posts_history_topic_id_fk foreign key (topic_id) references topics (topic_id), " \ |
|
|
|
"constraint posts_history_post_id_fk foreign key (post_id) references posts (post_id))" |
|
|
|
cur.execute(sql) |
|
|
|
|
|
|
|
con.commit() |
|
|
|