]>
git.datanom.net - pwp.git/blob - app/DB/db_mysql.sql
1 DROP TABLE IF EXISTS photo
,format
,album
,portfolio
,accessright
,role,user;
4 id integer NOT NULL AUTO_INCREMENT
,
5 name varchar(255) NOT NULL,
6 email
varchar(150) NOT NULL,
7 username
varchar(150) NOT NULL,
8 password varchar(255) NOT NULL,
9 CONSTRAINT user_pkey
PRIMARY KEY (id)
12 DROP INDEX IF EXISTS ix_user_email
ON user;
13 CREATE UNIQUE INDEX ix_user_email
ON user (email
);
15 DROP INDEX IF EXISTS ix_user_username
ON user;
16 CREATE UNIQUE INDEX ix_user_username
ON user (username
);
20 id integer NOT NULL AUTO_INCREMENT
,
22 CONSTRAINT role_pkey
PRIMARY KEY (id)
24 insert into role (role) values ('read');
25 insert into role (role) values ('write');
26 insert into role (role) values ('admin');
28 CREATE TABLE accessright
30 id integer NOT NULL AUTO_INCREMENT
,
31 perm
integer NOT NULL,
32 user integer NOT NULL,
33 CONSTRAINT accessright_pkey
PRIMARY KEY (id),
34 CONSTRAINT accessright_userid_fkey
FOREIGN KEY (user)
35 REFERENCES user (id) MATCH SIMPLE
36 ON UPDATE CASCADE ON DELETE CASCADE,
37 CONSTRAINT accessright_perm_fkey
FOREIGN KEY (perm
)
38 REFERENCES role (id) MATCH SIMPLE
39 ON UPDATE CASCADE ON DELETE CASCADE
42 CREATE TABLE portfolio
44 id integer NOT NULL AUTO_INCREMENT
,
46 user integer NOT NULL,
47 public boolean NOT NULL DEFAULT true,
48 visible
boolean NOT NULL DEFAULT true,
49 CONSTRAINT portfolio_pkey
PRIMARY KEY (id),
50 CONSTRAINT portfolio_userid_fkey
FOREIGN KEY (user)
51 REFERENCES user (id) MATCH SIMPLE
52 ON UPDATE CASCADE ON DELETE CASCADE
57 id integer NOT NULL AUTO_INCREMENT
,
59 visible
boolean NOT NULL,
60 public boolean NOT NULL,
61 portfolioid
integer NOT NULL,
62 CONSTRAINT album_pkey
PRIMARY KEY (id),
63 CONSTRAINT album_portfolioid_fkey
FOREIGN KEY (portfolioid
)
64 REFERENCES portfolio (id) MATCH SIMPLE
65 ON UPDATE CASCADE ON DELETE CASCADE
70 id integer NOT NULL AUTO_INCREMENT
,
72 CONSTRAINT format_pkey
PRIMARY KEY (id)
74 insert into format (format
) values ('jpg');
75 insert into format (format
) values ('raw');
76 insert into format (format
) values ('tiff');
80 id integer NOT NULL AUTO_INCREMENT
,
84 format
integer NOT NULL,
85 albumid
integer NOT NULL,
86 visible
boolean NOT NULL,
87 public boolean NOT NULL,
88 CONSTRAINT photo_pkey
PRIMARY KEY (id),
89 CONSTRAINT photo_albumid_fkey
FOREIGN KEY (albumid
)
90 REFERENCES album (id) MATCH SIMPLE
91 ON UPDATE CASCADE ON DELETE CASCADE,
92 CONSTRAINT photo_format_fkey
FOREIGN KEY (format
)
93 REFERENCES format (id) MATCH SIMPLE
94 ON UPDATE CASCADE ON DELETE CASCADE
This page took 0.095485 seconds and 6 git commands to generate.