File: 200403252.sql

package info (click to toggle)
gforge 4.5.14-22etch13
  • links: PTS
  • area: main
  • in suites: etch
  • size: 13,004 kB
  • ctags: 11,918
  • sloc: php: 36,047; sql: 29,050; sh: 10,538; perl: 6,496; xml: 3,810; makefile: 341; python: 263; ansic: 256
file content (18 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ALTER TABLE users ADD COLUMN theme_id INT;
--ALTER TABLE users ALTER COLUMN theme_id SET DEFAULT NOT NULL 1;
--UPDATE users SET theme_id=1
--	WHERE NOT EXISTS (select user_theme FROM theme_prefs WHERE user_id=users.user_id);
UPDATE users SET theme_id=
	(select user_theme FROM theme_prefs WHERE user_id=users.user_id)
	WHERE EXISTS (select user_theme FROM theme_prefs WHERE user_id=users.user_id);
--
--	If there is no theme_id=1 in the themes table, we could have a problem
--
UPDATE users SET theme_id=(SELECT min(theme_id) FROM themes WHERE enabled=true LIMIT 1)
	WHERE theme_id IS NULL;
ALTER TABLE users ADD CONSTRAINT users_themeid
        FOREIGN KEY (theme_id) REFERENCES themes(theme_id) MATCH FULL;
ALTER TABLE users ADD CONSTRAINT users_ccode
        FOREIGN KEY (ccode) REFERENCES country_code(ccode) MATCH FULL;
DROP TABLE theme_prefs;