Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE extension hstore;
- CREATE TABLE users {
- id serial PRIMARY KEY,
- username text NOT NULL,
- email text NOT NULL,
- password BINARY,
- attributes hstore
- };
- CREATE TABLE forums {
- id serial PRIMARY KEY,
- name text,
- attributes hstore
- };
- CREATE TABLE threads {
- id serial PRIMARY KEY,
- forumid INTEGER REFERENCES forums(id) NOT NULL,
- userid INTEGER REFERENCES users(id) NOT NULL,
- subject text NOT NULL,
- TIME TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- attributes hstore
- };
- CREATE TABLE posts {
- id serial PRIMARY KEY,
- threadid INTEGER REFERENCES threads(id) NOT NULL,
- userid INTEGER REFERENCES users(id) NOT NULL,
- TIME TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- text text NOT NULL,
- attributes hstore
- };
- CREATE TABLE messages {
- id serial PRIMARY KEY,
- fromid INTEGER REFERENCES users(id) NOT NULL,
- toid INTEGER REFERENCES users(id) NOT NULL,
- TIME TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- subject text NOT NULL,
- text text NOT NULL,
- viewed BOOLEAN,
- attributes hstore
- };
- CREATE TABLE thread_subscription {
- id serial PRIMARY KEY,
- threadid INTEGER REFERENCES threads(id) NOT NULL,
- userid INTEGER REFERENCES users(id) NOT NULL,
- lastseenid INTEGER REFERENCES posts(id) NOT NULL,
- attributes hstore
- };
- CREATE TABLE forum_subscription {
- id serial PRIMARY KEY,
- forumid INTEGER REFERENCES forums(id) NOT NULL,
- lastseenid INTEGER REFERENCES forums(id) NOT NULL,
- attributes hstore
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement